Saturday, 19 November 2011

Create persistent Bash aliases


Having recently updated to Xubuntu I found that the command "l" no longer showed a colourised 'ls' output, which was rather irritating. The solution is, of course, to re-create the bash alias so that the command 'l' executes what I expect it to. I'm unsure whether or not I managed to remove this functionality myself at some point, or whether it's simply not a default alias in Xubuntu.

In any case, I didn't have a .bashrc file in my home directory, so the first thing I did was to copy the default one to it:

cp /etc/skel/.bashrc ~/
It turns out this is enough to get the 'l' command back, as it already exists in that bashrc. Having had a look through this default .bashrc though, I couldn't resist the temptation to add another alias for convenience!

Simply append the following to the end of your ~/.bashrc to have the terminal update and upgrade when you type 'update'
alias update='sudo apt-get update && sudo apt-get dist-upgrade'
It's tempting to go nuts and start adding aliases left right and centre for mundane tasks, this is something that should probably be resisted for anything that isn't both genuinely useful, and frequently executed however.

1 comment:

  1. Thank you for this tip! I was wondering where the "l" allias is after upgrade to 11.10. Now it's back thank to you.

    ReplyDelete