I want a shell where I can edit commands the same way I edit every other text on MacOs. Where shift left means "add letter to the left of cursor to selection" not "type the letter D"; where "command right" means "go to the end of the line" not "go to the next word"; where I can click on any character in the command to move the cursor there; where I can use up/down keys to edit multiline commands instead of up/down doing something bizarre when they retrieve a multiline command from history....

Does anyone know of such thing?

PS, please don't recommend that I 1) learn keybindings of the s 2) that I just copy paste from textedit. That's not what this question is about.

  • A commercial (free to try) text editor BBEdit has a feature like that. I’m not a shell guy but it’s pretty good Commented Feb 16 at 18:04
  • Are you looking for a shell running on macOS or for one running on Linux?
    – nohillside
    Commented Feb 16 at 18:15
  • What shell do you use on Linux? If you are using bash, it has extensive keybinding support through the readline library. Commented Feb 18 at 16:05
  • @SteveChambers, I'm talking about key bindings in the shell, not in an application. Commented Feb 19 at 18:13
  • @nohillside, zsh Commented Feb 19 at 18:13

2 Answers 2


You can use Emacs. Emacs is primarily an editor, but it also includes many related features that let you benefit from the Emacs's capabilities when doing things other than editing files. One of these features is Shell mode, where you edit a command with Emacs then press ⏎ Enter to run it.

You can download Emacs from Emacs For Mac OS X or from package managers such as Homebrew, MacPorts or Fink.

Emacs has its own editing commands that are completely different from Mac's, but at least the Emacs For Mac OS X comes with the standard Mac commands predefined.

To start Emacs and just use it to run a shell:

emacs -e shell -e delete-other-windows

See the Manual for shell-related commands such as navigating history. You can also use F1 m to see a list of key bindings that apply specifically to Shell mode.

Shell mode gives you Emacs's command line editing and infinite scrollback. It does have some downsides: full-screen terminal applications won't work, and you only get basic filename completion rather than context-sensitive completion. Shell mode supports colored output, but applications might not be able to detect it, for example /bin/ls doesn't (you can trick it with alias ls='TERM=xterm-256color ls -G').

Exiting the shell doesn't close Emacs, because using Emacs only to run a shell is unusual. It would be possible to set it up so that exiting the shell exits Emacs if it's not doing anything else, but that would be material for a separate question on Emacs SE.

Alternatively, you may prefer Term to Shell. Term is a full-blown terminal emulator. This means that Emacs transmits most key presses to the underlying shell. For example, ⇥ Tab invokes the shell's completion mechanism. However, Emacs keeps handling some commands internally, in particular all ⌘ Command bindings such as copy-paste. Also, Control+C invokes Term mode commands. On the other hand, Shift+arrow is sent to the shell. It would be possible to have Emacs handle it, but that's not straightforward given that it would de-synchronize the cursor position between Emacs and the shell. I don't know if there's an Emacs package out there that solves this.

If all you want is mouse support and Shift+arrow, there are zsh plugins for that:

Unfortunately neither handles copying the selection to the clipboard with ⌘C. The command Meta+W (Meta is usually ⌥ option, but it depends on your terminal configuration) copies to zsh's own clipboard. See [zsh copy and paste like emacs](See https://unix.stackexchange.com/questions/51933/zsh-copy-and-paste-like-emacs) for how to synchronize zsh's clipboard with the system.


The closest thing to what you are asking for is a UI REPL editor like Jupyter Notebooks. When in the command line your cursor is limited in its movement and many shells can compute using bash, c, or other loaded computer languages. In order to move around as you want the closest tool is Jupyter notebook, which edits like a text editor and compiles each cell as you enter it.

  • Does this work with a shell like bash or zsh, or only with Python?
    – nohillside
    Commented Feb 19 at 22:03
  • @DoglGreat, interesting software but maybe way overkill. Upvoting. Commented Feb 28 at 16:21
  • There are similar languages that are closed source (ie. Mathematica) that have similar tools. But you need to look into REPL editors and the languages that work with them.
    – DogIsGreat
    Commented Feb 29 at 20:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .