0% found this document useful (0 votes)
19 views

Terminal-Keys-and-Commands-Reference

Uploaded by

17.amar1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Terminal-Keys-and-Commands-Reference

Uploaded by

17.amar1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

TERMINAL KEYS AND COMMANDS

Symbols Recall History


⌘ command or cmd ⇧ shift up ↑/down ↓ arrow recall previous/next command from history
⌥ option or alt ⌃ control or ctrl ctrl-R, then type search history for what you type
⇥ tab ↩︎ return ctrl-G cancel history search

Navigating the Prompt esc, then . (dot) inserts last argument of previous command

left ←/right → arrow move the cursor left/right Marks and Bookmarks
⌥←, ⌥→ move left/right by word ⌘ up ↑/down ↓ scroll to previous/next mark
ctrl-A move to beginning of line ⌘L clear to previous mark
ctrl-E move to end of line ⌘⌥ L clear to previous bookmark
ctrl-XX (twice) toggle between beginning of line ⌘U set mark manually
and current position ⌘⌥ U set bookmark
ctrl-U clear line left of cursor to the beginning ⌘⌥ up ↑/down ↓ scroll to previous/next bookmark
ctrl-K clear line right of cursor to the end ⌘⇧ ↩︎ send return without marking
ctrl-W delete word left of cursor ⌘ ↩︎ send return with marking
⌥ click move cursor to click (when automatic marking is disabled)

ctrl-L or ⌘⌃ L clear screen (but not current prompt line)


Selection
⌘K clear to start (screen and scroll buffer)
⌘⇧ double-click select path or URL
Completion
⌘⇧ V paste selection (no need to copy)
tab ⇥ complete current command or path ⌘⌃ V paste and escape text
tab (twice) ⇥⇥ list possible completions ⌘⇧ up ↑/down ↓ select to previous/next mark
esc (twice) replaces globbing characters (~, ?, *, etc.), ⌘⇧A select output of previous command
lists possible paths if not unique

Armin Briegel —scriptingosx.com/books


TERMINAL KEYS AND COMMANDS
The Open Command Finder Terminal Interaction
$ open . drag folder on Terminal icon:
Open current working directory in a new Finder window open new window and change to directory
$ open path/to/dir drag executable on Terminal icon:
Opens path/to/dir in a new Finder window open new window, run executable, then exit
(may open and close window very quickly)
$ open file.ext
Opens file.ext in default application (same as double-clicking) drag item(s) on Terminal window:
insert escaped path(s) to item(s) at cursor
$ open -a AppName file.ext
Opens file.ext with application AppName command-drag folder on Terminal window:
$ open -e file.txt changes directory to dragged folder
Opens file.txt in Text Editor command-drag file on Terminal window:
$ open -t file.txt changes directory to enclosing folder of file
Opens file.txt in default application for txt files
Clipboard Commands
$ some_cmd | open -f
copy output of a command to clipboard
Opens stdin to newText Editor document
$ some_cmd | pbcopy
$ some_cmd | open -tf
copy contents of file.txt to the clipboard
Opens stdin in new document in default application for txt files $ cat file.txt | pbcopy
$ open -R file.ext copy output of a command and print to stdout
reveals (shows and selects) file.ext in Finder window $ some_cmd | pbcopy; pbpaste
$ open http://scriptingosx.com print clipboard contents to stdout
Opens URL in default application (works with vnc, smb etc.) $ pbpaste

write clipboard contents to file.txt


$ pbpaste > file.txt

append clipboard contents to file.txt


$ pbpaste >> file.txt

Armin Briegel —scriptingosx.com/books

You might also like