Think of any command that is long that you have to type out regularly (and it bakes your banana to remember the entire command like it does me)
Wouldn't you rather type "sahara" than "ssh -qi /home/jj/.ssh/sahara/keypair/id_rsa-keypair root@xxx.xxx.xxx.xxx" ? I'm assuming you would.
Let's do some math on what may seem a trivial exercise, and you'll see what I mean.
Take the command "exit" (from your favorite terminal).
4 characters + 1 for the enter key = 5 keystrokes. 5 keys you have to hit every time you exit the terminal. No big deal? Let's see...
What if you have to type "exit" (never mind you type 400 WPM at 98% accuracy) 100 times a day. That's 500 keystrokes to exit 100 terminal windows every day. 500 keystrokes for 100 terminals-a-day for 365 days a year is 182,500 keystrokes a year. That's a LOT of repetitive keystrokes.
Using an alias you could cut that down to 500, for the whole year. Amazing. How? alias x=`exit` in your .bashrc
Using the "x" alias instead of the "exit" command, you are a couple of hundred times more proficient! Employers LOVE proficiency.
I have several alias files defined in my .bashrc
One for all my work ssh commands and another for my aliases that I use every day.
Here's a few that I used when I had LinuxMint installed and you should benefit from also. This will get this thread started.
The #s are comments and are NOT processed by your .bashrc or other alias file.
To use these in your .bashrc just open a terminal and type
Code: Select all
vi + .bashrc
Code: Select all
### apt-related
# alias install="sudo apt-get install -y"
# alias search="sudo apt-cache search"
# alias remove="sudo apt-get remove"
# alias clean="sudo apt-get autoremove"
# alias update="sudo apt-get update"
# alias upgrade="sudo apt-get upgrade"
## end apt-related
alias reload='source ~/.bashrc'
Back at the prompt type
Code: Select all
source ~/.bashrc
Next time you have to edit your .bashrc to add another alias, just ESC > ZZ from vi and type
Code: Select all
reload
Edit: Mon Jul 18, 2011
Tips and Tricks I have learned:
Use double quotes around complex aliases
If the alias contains a double-quoted command or string, use a \ to escape the first 'inner' double-quote and the last 'outer' double-quote.
Example:
Code: Select all
alias workssh="alias | grep ssh | cut -d= -f1 | egrep -v \"workssh|go"\"
My actual alias for workssh is
Code: Select all
alias workssh="alias | \grep ssh | cut -d= -f1 | \egrep -v \"workssh|go"\"
To list the aliases construction type
Code: Select all
alias <alias_name>
Code: Select all
alias
To unset an alias (they can get unwieldy) type
Code: Select all
unset <alias_name>