Mac Terminal Tips
Magic I just learned: in Terminal, do a thing with output (like ls), then do cmd-shift-A.
This selects the output of the previous command.
Cmd-Ctrl-V. Pastes text fully escaped, including spaces.
Cmd-Up is still my favorite new (El Cap) Terminal feature.
This scrolls you back up to the previous command.
In Terminal, adding Shift for these commands extends the selection, just like in an editor.
Don’t forget that two-finger scrolling now works w/ less, man pages, etc…
Yup and you can toggle mouse reporting with ⌘R. I do it a lot with tmux.
You can also use the Fn modifier when clicking or dragging, to interact with the terminal view.
The basics of marking in Terminal.app. Explains those gutter marks!
an0:
Anyone knows what’s Paste Selection?
Seems to be more “Insert Selection”. Takes what’s selected and puts it at the cursor w/o changing clipboard.
an0:
So a selection-specific pasteboard in Terminal. Reminds me of selecting to copy during my linux days.
The selection pasteboard is named “com.apple.Terminal.selection” and is public.
Previously: Craig’s Terminal Tips.
13 Comments RSS · Twitter
Combine Cmd-Up and Cmd-Shift-A for even more fun (go back to the command you are interested in and press Cmd-Shift-A to select *its* output)
On a long command you can Option + click to have your cursor jump to that position (before you've pressed Return)
My favorite is command-double click on a URL: opens the URL. You don't even have to highlight the text for it to work.
Not exactly a terminal trick, but anywhere the Cocoa text system is in place -- which is just about anywhere there's text -- the standard emacs navigation key combos work.
One of my most often used commands is ctrl+r to enter history search mode. Then start typing the previously used command/path you are looking for, keep pressing ctrl+r until the specific invocation appears, press return to insert in the command prompt where you can edit the command before you hitting return to run.
I can never remember the parameters for ImageMagick, for example. It is easy to search the history for `convert', hit return, insert the relevant paths, done.
1) Copy the contents of a file to the clipboard with `cat file_name | pbcopy`
2) More of a bash tip: `cd -` will go to the previous directory (although there's no history)
I trying these, I stumbled on ESC then Delete to delete the word to the left. I then poked around the menus and found that ctl+cmd+? opens the man page for the word to the left in a separate window.
@Chris: Your use of cat is overkill. pbcopy is a standard Unix command that reads from standard input - which is why your construct works. But pbcopy file_name writes it to the given file.
Both commands have a couple of options to control format and even to control which paste buffer they use. man pbcopy will give you this information.
-- Jerry
At least since Mavericks, the standard search keys (Command F/Command G) work, searching the current terminal window and the entire scroll back buffer.
-- Jerry
An unusual one I've never actually used: Command-Shift-L (which is View>Show/Hide Alternate Screen - gives you two separate *output* windows pointing to the same terminal session. So you can execute a command writing stuff to the screen, shift to the other screen, and execute another command. The output of the first will remain where it was if you shift back. I'm not exactly sure what to do with this.
-- Jerry