This in-depth article clarifies how your shell deals with word-splitting, quoting, and expansion. Well worth the read if you do any work in the shell.
The easiest way to speed up your workflow in your shell is to create aliases for your most frequently used applications and their configuration settings. If you use zsh, these aliases can go into
~/.zshrc, but if you use bash they should go in
A few sample aliases from my for git:
alias ga='git add'
alias gc='git commit -m'
alias gac='git add -u && git commit -m "Auto commit"'
Now, when I’m on my prompt, the aliases will be expanded by my shell after I hit return to execute the command.
$ gc 'This is my commit message'
$ git commit -m 'This is my commit message'
Set Default Options
You can also use this to set default options for commonly used programs.
For example, let’s say you want to have
lsdisplay its output in list mode with color on OSX. I can just set up an alias like:
alias ls='ls -lG'
And now when I invoke
lson my prompt, it will automatically expand it as follows:
$ ls -a /path/to/foo
$ ls -lG -a /path/to/foo
alias s='cd -'
alias rcedit='mvim -f ~/.zshrc && source .zshrc'
alias hostedit='sudo mvim -f /etc/hosts && dscacheutil -flushcache'
Share your custom shell aliases and tips in the comments.