Osx terminal uses almost all of the emacs movement keys by default. Ctrl-a and ctrl-e are useful but I find the meta movement keys to be the most helpful. (usually alt or ESC)
Meta-f jump forward a word Meta-b jump backwards a word
It's up to the process running in Terminal.app to support the key sequences sent to it. I doubt that M-f would work if your shell (bash, zsh, etc) were in Vi-mode rather than the default of Emacs-mode.
IIRC, someone mentioned to me once that bash doesn't link against libreadline, but uses libreadline (the source is directly in the Bash repo), so it's possible that it's using GNU readline, while Apple's libreadline is a BSD flavour.
Terminal may be using some kind of Readline, I dunno. But text objects in other OS X applications use emacs keybindings because NeXTSTEP has had them since time immemorial. Like 1990 or so. Doesn't have anything to do with GNU Readline so far as I know.
Terminal.app passes the key sequences to the application running inside of the terminal. The default shell (bash) uses GNU readline, which has an emacs-mode and a vi-mode (emacs is the default). Terminal.app does not use any Cocoa text fields, so has nothing to do with the Emacs keybindings inherited from NeXTSTEP.
It at least used to be the case that GNU Readline was GPL-licensed, instead of LGPL, as to make readline a "carrot" to encourage GPL adoption. That shouldn't be an issue for bash, which is also GPL licensed.
Ctrl-x, Ctrl-e will pop open your EDITOR so you can edit the command. Saving and closing the editor brings the command back in your terminal and automatically executes it. fc will bring up your EDITOR with the last typed command. (You can use fc -l to see a list of commands)
The basic Emacs key-bindings should work in all Cocoa apps. For instance, the URL bar of your web browser, while text editing in just about any editor (maybe even in Office, but I have not tired in a while), etc. Basically, anywhere you have a cursor, the basic line-editing key bindings should work.
So, in practical terms, this means you have 1 + n clipboards[1]. The main global GUI clipboard (using the command key), and then an app-specific clipboard (using the control key with Emacs bindings). As a developer, it is extremely helpful to have two clipboards in TextMate, for instance. [1] Technically, the clipboard in OS X maintains a history (not sure what the limit is), but the OS X GUI only exposes the last cut/copied item.
* ⌘ + ` (tilde key) to switch between different windows of your current application * ⌘ + l (lowercase L) in most web browsers to highlight the address bar
to piggyback off of this... (not sure if this is in the thread already)
⌘ + ` to switch between different windows of current application ⌘ + SHIFT + ` to switch between different windows of current application (reverse order) same for the general application switcher: ⌘ + TAB to switch between different windows of current application ⌘ + SHIFT + TAB to switch between different windows of current application (reverse order)
ctrl-arrow (which breaks with Lion's Spaces default keys), or shift Home/End in Terminal.
It's not that Macs are crappy, they just have different key bindings. I regularly work with Macs, Windows, and Linux for development and I've just learned to use the different key mappings. I don't think I'm quite as proficient in any one system because of that, though. For example, I have avoided learning the Emacs key bindings for use in Mac/Terminal. (I don't want to try to remember TWO bindings for Mac, plus I learned vim first so usually avoid Emacs.)
ctrl-arrow jumps to the next word boundary under Linux.
Yes, other systems have other key bindings, but why do common things like jumping to the begin/end of a line need a key combination? And why aren't the characters written onto the keys? Every time I have to type some code on a Mac I have to press all the keys in order to find { } [ ] etc. At leas I learned not to quit the terminal when I want to enter a @ by now. Whose brilliant idea was that?
Not sure if I have it set up differently but mine is Cmd-Left or Cmd-Right to move to the beginning of a line...? Easier to reach than fn (I'm using a real wired BIG Apple keyboard, the RSI inducing one...)
I love how osx supports emacs key-bindings by default for any text field.
I miss this feature a lot when I switch back to windows. I find myself pressing ctrl-n in my browser's address bar, expecting to view my URL history, and instead I get a new windows. If anyone knows of a way to get similar functionality in windows, I would love to hear about it!
Comments (395) 107 threads
Earlier commentsMeta-f jump forward a word
Meta-b jump backwards a word
It's up to the process running in Terminal.app to support the key sequences sent to it. I doubt that M-f would work if your shell (bash, zsh, etc) were in Vi-mode rather than the default of Emacs-mode.
The shortcuts also work in every text field in the OS.
Terminal.app passes the key sequences to the application running inside of the terminal. The default shell (bash) uses GNU readline, which has an emacs-mode and a vi-mode (emacs is the default).
Terminal.app does not use any Cocoa text fields, so has nothing to do with the Emacs keybindings inherited from NeXTSTEP.
Ctrl-x, Ctrl-e will pop open your EDITOR so you can edit the command. Saving and closing the editor brings the command back in your terminal and automatically executes it.
fc will bring up your EDITOR with the last typed command. (You can use fc -l to see a list of commands)
* Ctrl-a to go to beginning of line
* Ctrl-e to go to end of line
so Ctrl-A Ctrl-K will clear a given field
Continue this thread — 1 reply
Continue this thread — 1 reply
So, in practical terms, this means you have 1 + n clipboards[1]. The main global GUI clipboard (using the command key), and then an app-specific clipboard (using the control key with Emacs bindings). As a developer, it is extremely helpful to have two clipboards in TextMate, for instance.
[1] Technically, the clipboard in OS X maintains a history (not sure what the limit is), but the OS X GUI only exposes the last cut/copied item.
Continue this thread — 2 replies
* ⌘ + ` (tilde key) to switch between different windows of your current application
* ⌘ + l (lowercase L) in most web browsers to highlight the address bar
Woohoo, love me some Linux, let choice reign ;-)
⌘ + ` to switch between different windows of current application
⌘ + SHIFT + ` to switch between different windows of current application (reverse order)
same for the general application switcher:
⌘ + TAB to switch between different windows of current application
⌘ + SHIFT + TAB to switch between different windows of current application (reverse order)
It's not that Macs are crappy, they just have different key bindings. I regularly work with Macs, Windows, and Linux for development and I've just learned to use the different key mappings.
I don't think I'm quite as proficient in any one system because of that, though. For example, I have avoided learning the Emacs key bindings for use in Mac/Terminal. (I don't want to try to remember TWO bindings for Mac, plus I learned vim first so usually avoid Emacs.)
Yes, other systems have other key bindings, but why do common things like jumping to the begin/end of a line need a key combination? And why aren't the characters written onto the keys? Every time I have to type some code on a Mac I have to press all the keys in order to find { } [ ] etc. At leas I learned not to quit the terminal when I want to enter a @ by now. Whose brilliant idea was that?
Continue this thread — 2 replies
Continue this thread — 2 replies
I miss this feature a lot when I switch back to windows. I find myself pressing ctrl-n in my browser's address bar, expecting to view my URL history, and instead I get a new windows.
If anyone knows of a way to get similar functionality in windows, I would love to hear about it!
All comments shown.
Couldn't load more comments. Check your connection and try again.