Back in 1994, when I had been using SunOS for three years and Linux for almost two years, people started talking about how you could make DOS command line abbreviations. What swill. By that time, I already had some very useful keystroke saving aliases for the command line because command line usage makes up a majority of my workday.
Here are some of my frequently-used aliases:
List your files with extra info, in columns:
alias ,=’ls -CFs’
Jump back a directory:
alias ..=’cd ..’
List what’s most recently changed:
alias r=’ls -ltr’
How much space do we have?
alias h=’df -h’
How much space are we using here?
alias d=’du -sh .’
What is using the most space here?
alias D=’du -s * |sort -n’
Plain old vi is hard to use:
alias vi=’vim’
Let’s edit our aliases and use them immediately:
alias va=’vi ~/.bash_aliases && . ~/.bash_aliases’
You know about [ctrl-r] right? That allows you to search your command history. Also, there is:
control-u : delete to start of line
control-e : jump to end of line
control-p : previous command
If you really want to use your “scroll back” efficiently, ignore those commands because they typically are noise in your shell history. So you can level up immediately by adding:
export HISTIGNORE=”,:..:r:h:d:D:vi:va”
This can clean up your command history and saves me a ton of typing. My current list of aliases is pretty long. I have to write a perl one-liner just to generate my HISTIGNORE variable.
alias | perl -ne '/alias (..?)=/ && print "$1:";',:..:00:B:Fw:G.:GC:GD:GP:GS:GU:Gt:H:L:NB:R:SS:Ss:d:h:l:la:ll:ls:r:s:sb:va:vf:vh:vi:vv:xx
So, sysadmin much? What’s your alias for sudo -s?
Featured photo on front page by zanaca
One that I find useful to put on friends systems is
rm=’rm -i’
Forces rm to run in interactive mode so they have a last ditch effort to not nuke things by accident.
I have lsl as an alias for “ls -l -group-directories-first.”
I guess that “alias D=’du -sh * |sort -h’” is kind of better 😉