Great link, I spent a good while digging through there when I first found it. My favorite is using mdfind to leverage Spotlight for file search. Results come up instantly.
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.
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?
Well, you don't have to follow that glossy mainstream. Just get yourself a new linux desktop with lots of RAM, couple of nice matte monitors, mouse and a good full size keyboard.
That's what I always do. My new PC should be delivered any minute, actually (16 GB RAM; at one intensive work session my current 8 GB where almost a bit scantly - is that the right English word?).
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!
bash uses GNU readline, while ZSH has it's own readline. IIRC the Emacs-/Vi-modes in bash are support from readline. (this is also why you configure some of these things via .inputrc for Bash rather than .bashrc).
set -o vi does the trick for vim. Most vi commands work, but when you type <ESC>v this will open vi to edit your command line, in case you feel any command is missing.
I've b een using vi-mode in the shell for a while,but haven't been able to get the <ESC>v behavior you described. Did you have to do anything to make that behave?
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)
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.
Useful when copy/pasting things to share with other people in email and such:
$ pbpaste | pbcopy
takes the current contents of the copy/paste buffer and removes color/font/background color rich formatting and puts just plain text back into the paste buffer.
And of course pbcopy and pbpaste are also very useful on their own.
Be warned, though, that these do not work inside of a tmux session without special steps being taken. I believe that they work in screen, but tmux requires some additional work.
I use Plain Clip (http://www.bluem.net/en/mac/plain-clip/) for this. It also gives you optional text processing steps (e.g., remove all trailing whitespace) which are super useful.
Actually, natch's trick does just the opposite. It strips out any formatting information that may accompany the text on the clipboard.
I've used the same trick on occasion when copying text from web pages into Gmail. When you paste such text into a Gmail draft, Gmail tries to duplicate the format of the original, which is often not what you want. pbpaste | pbcopy solves the problem nicely.
Edit: But Shift-Option-Cmd-V is easier. Thanks, Janteh!
I like checking the box in preferences to use Option as Meta, and then option + left/right will jump a word at a time, and option + backspace will delete the previous word, just like in most Cocoa apps.
Lovely, thanks. Also, is it common knowledge that CMD+click on a URL opens that URL in your default browser? Useful for the "Running on http://127.0.0.1:5000/" messages.
Perhaps it's simply personal preference, but I do find that limiting my mouse usage has resulted in real, tangible gains. I don't know how feasible that is in GUI-first operating systems like OS X, though.
I wish there was a way to make the mouse cursor stand out more when (and only when) it's over the terminal. Maybe it's because I use a dark terminal background, I can hardly ever see the thing.
There's a system wide setting to make the cursor huge, but I don't want a huge cursor everywhere. And there's a terminal preference to make the insertion cursor different, but that's a different cursor, not the mouse cursor.
When do I want to see the mouse cursor? It's useful for things like highlighting a git hash or a few lines of text for copy/paste.
in windows theres something where you can press controll and it will shoot circles out from your mouse which is pretty useful, not sure if there is anything like that in osx
405 comments
[ 6.0 ms ] story [ 483 ms ] thread* 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
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.
For the most in depth info on the Cocoa Text System: http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html
* ⌘ + ` (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?
In contrast a German PC keyboard: http://www.buypcsupplies.com/images/cat/38568_xlargenss_ndo4...
However, I prefer a Microsoft Comfort Curve keyboard, but I can't find an image of the German version right now.
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!
Thanks for sharing!
Ctrl-e: go to the end of the line Ctrl-r: search backwards (input the text)
and you go to the point where the search begins.
bindkey -v
Now be happy, hit <ESC> and, use ^ and $ but also f<letter> t<letter> and also ,;.
You can copy/paste with dd, Y, etc...
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.
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.
If you use Spotlight to find something and then want to see the file in Finder, Cmd+click the item in the Spotlight dropdown.
Edited from Cmd+shift+click due to note in child comment :-)
And of course pbcopy and pbpaste are also very useful on their own.
Just make a new shortcut under the All Applications group named exactly the same as the one you want to replace. http://i.imgur.com/JqBncTy.png
I've also had to add an entry for "Paste as Quotation" because that's Mail's default use of Command-V.
Then you need to add the following to .tmux.conf
There's a good writeup on what and why here, https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/...pbpaste |sed 's/FIND/REPLACE/g' | pbcopy
Maybe make this into a script you can run from alfred. ;)
Also if you want to have access to pbcopy remotely, try this:
http://evolvingweb.ca/blog/exposing-your-clipboard-over-ssh
I've used the same trick on occasion when copying text from web pages into Gmail. When you paste such text into a Gmail draft, Gmail tries to duplicate the format of the original, which is often not what you want. pbpaste | pbcopy solves the problem nicely.
Edit: But Shift-Option-Cmd-V is easier. Thanks, Janteh!
/s
/s
http://www.bashguru.com/2010/04/how-to-handle-cursor-movemen...
There's a system wide setting to make the cursor huge, but I don't want a huge cursor everywhere. And there's a terminal preference to make the insertion cursor different, but that's a different cursor, not the mouse cursor.
When do I want to see the mouse cursor? It's useful for things like highlighting a git hash or a few lines of text for copy/paste.