Using Command Line Aliases – Frequently

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

Jed Reynolds
Jed Reynolds has been known to void warranties and super glue his fingers together. When he is not doing photography or fixing his bike, he can be found being a grey beard programmer analyst for Candela Technologies. Start stalking him at https://about.me/jed_reynolds.

Leave a Reply