This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Linux terminal shortcuts support in python shell
Type: enhancement Stage: resolved
Components: IDLE, Interpreter Core, IO Versions: Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder: IDLE: Patch to make PyShell behave more like a Terminal interface
View: 2704
Assigned To: terry.reedy Nosy List: r.david.murray, sebastin, steven.daprano, terry.reedy
Priority: normal Keywords:

Created on 2018-06-18 04:49 by sebastin, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (7)
msg319857 - (view) Author: sebastin (sebastin) Date: 2018-06-18 04:49
simple linux terminal support in python shell,
like clear, ctrl + r, up arrow would be really good to have.
msg319860 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-06-18 05:13
Are you talking about the python shell, run in a text console window, or IDLE's GUI shell?  The components you mark include both.

If the former, do you mean only on linux or all systems?  You and Python are more or less at the mercy of the console you use + readline.

If you mean IDLE's Shell, you must give details: what key, what action.  Is so, I suspect that at least some of your requests are either rejected or open issues.
msg319865 - (view) Author: sebastin (sebastin) Date: 2018-06-18 06:54
I meant this on Python IDLE across all platforms.
basic necessary enhancements for seamless use of IDLE should atleast have below feature supported.

clear(used in MAC/LINUX TERMINAL) or cls(used in WINDOWS CMD PROMPT) - clear the PYTHON IDLE screen.

up arrow - for the search history.

If this enhancements is in progress/open state then its good, if rejected this be reconsidered ?
msg319870 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-06-18 08:44
These issues are not as simple as you think.  But anyway, clearing the shell in #6143.

Shell is a modified editor.  Currently, the arrows move the cursor around just as in the editor.  For multiline statements, this is essential, and even for single-line statements, not as useless as some claim.  Single-line command consoles can get away with changing the meaning of Up and Down.  This is discussed in #2704, and what I said above is explained more in msg243140 of May 2015.

I have a question about Linux consoles.  Windows Command Prompt is strictly a command *line* console.  It sees

>>> def fib(n):
...    if n >= 2:
...        return fib(n-2) + fib(n-1)
...    else:
...        return n

as 5 commands.  Its history mechanism retrieves a line at a time.  Does a Linux console retrieve all 5 at once, as IDLE does?
msg319878 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2018-06-18 11:32
Terry asked: 
> I have a question about Linux consoles. [...] Does a Linux console retrieve all 5 at once, as IDLE does?

Not typically. Like the Windows console, Linux consoles are also line-oriented, and hitting up-arrow cycles through each line, one at a time.

The bash shell offers a special "operate-and-go-next" command to operate on a particular history line and then immediately retrieve the next history line:

http://web.mit.edu/gnu/doc/html/features_7.html

but I think that's about as close as any standard Linux console gets to the ability to retrieve multiple lines from history at once.
msg319887 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-06-18 15:16
zsh lets you edit multiline shell commands as a unit.  If you up-arrow, you get all the lines of the block popped up, with the cursor on the last line.  Further arrow keys will navigate within the multiline text block, with an up-arrow from the first line taking you to the next previous shell command, and enter within the block will re-execute the entire modified multiline command.  I haven't used IDLE recently enough to remember how that compares to how IDLE works.
msg319899 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-06-18 17:07
Thanks. I have presumed that Linux consoles are also line oriented, but hesitated to say so without really knowing so.
History
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 78074
2018-06-18 17:07:14terry.reedysetmessages: + msg319899
2018-06-18 15:16:26r.david.murraysetnosy: + r.david.murray
messages: + msg319887
2018-06-18 11:32:06steven.dapranosetnosy: + steven.daprano
messages: + msg319878
2018-06-18 08:44:55terry.reedysetsuperseder: IDLE: Patch to make PyShell behave more like a Terminal interface
2018-06-18 08:44:37terry.reedysetstatus: open -> closed
resolution: duplicate
messages: + msg319870

stage: test needed -> resolved
2018-06-18 06:54:54sebastinsetmessages: + msg319865
2018-06-18 05:13:33terry.reedysetmessages: + msg319860
stage: test needed
2018-06-18 04:49:48sebastincreate