Skip to content

Linux terminal shortcuts support in python shell #78074

Closed

Description

@sixstringseby
BPO 33893
Nosy @terryjreedy, @stevendaprano, @bitdancer, @sixstringseby
Superseder
  • bpo-2704: IDLE: Patch to make PyShell behave more like a Terminal interface
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2018-06-18.08:44:37.642>
    created_at = <Date 2018-06-18.04:49:48.251>
    labels = ['interpreter-core', 'expert-IDLE', 'type-feature', '3.8', 'expert-IO']
    title = 'Linux terminal shortcuts support in python shell'
    updated_at = <Date 2018-06-18.17:07:14.484>
    user = 'https://github.com/sixstringseby'

    bugs.python.org fields:

    activity = <Date 2018-06-18.17:07:14.484>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2018-06-18.08:44:37.642>
    closer = 'terry.reedy'
    components = ['IDLE', 'Interpreter Core', 'IO']
    creation = <Date 2018-06-18.04:49:48.251>
    creator = 'sebastin'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33893
    keywords = []
    message_count = 7.0
    messages = ['319857', '319860', '319865', '319870', '319878', '319887', '319899']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'steven.daprano', 'r.david.murray', 'sebastin']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '2704'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue33893'
    versions = ['Python 3.8']

    Activity

    1. sixstringseby commented on Jun 18, 2018

      sixstringsebymannequin
      MannequinAuthor

      simple linux terminal support in python shell,
      like clear, ctrl + r, up arrow would be really good to have.

    2. terryjreedy commented on Jun 18, 2018

      @terryjreedy
      Member

      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.

    3. sixstringseby commented on Jun 18, 2018

      sixstringsebymannequin
      MannequinAuthor

      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 ?

    4. terryjreedy commented on Jun 18, 2018

      @terryjreedy
      Member

      These issues are not as simple as you think. But anyway, clearing the shell in bpo-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 bpo-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?

    5. stevendaprano commented on Jun 18, 2018

      @stevendaprano
      Member

      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.

    6. bitdancer commented on Jun 18, 2018

      @bitdancer
      Member

      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.

    7. terryjreedy commented on Jun 18, 2018

      @terryjreedy
      Member

      Thanks. I have presumed that Linux consoles are also line oriented, but hesitated to say so without really knowing so.

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions