Favorite Terminal Commands
This is a list of my favorite terminal commands, aliases, and customizations for MacOS and Linux.
In MacOS, the open command will open files and directories just as if you had double-clicked the file's icon. The default application for that file type/extension will be used if you do not specify an app by using the -a flag.
Here are some examples
||Opens the current directory in Finder|
||Opens the specified website with the specified browser|
And here are some useful aliases for the open command
alias ff='open -a Firefox'
alias ffd='open -a FirefoxDeveloperEdition'
One of my favorite uses of the open command is combining it with a list and/or search function. For example, if I wanted to open the last file that I downloaded, I can use the following command:
$ open $(ls -t | head -n1)
The one caveat with using this type of command is that it will not work if the file's name has space in it.
Find more information and options for the open command here.
Provides copying and pasting to the pasteboard (the Clipboard) from the command line
Full usage of grep, and Regular Expressions in general, is way out of scope for this reference page, but creating an alias that will automatically turn on color output is very useful.
alias grep='grep --color=auto'
Changes the name of a file or files. Both the old and new must be of the same type, that is both must be either directories or files and must reside on the same file system.
Here is an example:
$ rename 's/text_to_find/been_renamed' *.txt