Alias … Not the Television Show

Alias was a television show where Sydney Bristow took on various aliases to do spy things and to kick butt while she was at it. But the aliases were important. She had names like Julia Thorne, Kate Jones, Sharleen…all kinds of names she hid behind.
bash has aliases too, but it’s not names to hide behind because you’re spying, it’s more names to hide that long command behind so you don’t have to remember it. Remember in the post about bash history where I said it should be named thingsIdid or whatIdid? Now we can make that happen!

Alpha:~ computerlamp$ alias whatIdid="history"

 

Now when you type whatIdid, you get the results of the history command.

There’s the more command and the  less command. I don’t like the more command but I love the less command. So what do I do to keep from typing more by accident? Well, I don’t stop myself from typing it, I just make it run the less command:

Alpha:~ computerlamp$ alias more="less"

The bash shell has history, so there’s got to be a way for me to see what commands I’ve aliased aside from using that history command (which I could, if I combined it with grep!). And there is… just type:

Alpha:~ computerlamp$ alias
alias whatIdid="history"
alias more="less"

Since I can add them and I can list them, there’s got to be a way to remove them… and there is! It’s the imaginatively named unalias command.

Alpha:~ computerlamp$ unalias more

That removes the alias for more from my list of aliases.

Alpha:~ computerlamp$ alias
alias whatIdid="history"

What happens if I type the wrong thing?

Alpha:~ computerlamp$ unalias jedi
-bash: unalias: jedi: not found

I guess the alias command doesn’t know where Luke Skywalker is hiding at either.  Which is good for him, right?  He can hide from Snoke and Kylo Ren a little longer.

 

One thought on “Alias … Not the Television Show

  1. Pingback: The bashrc file - ComputerLamp

Leave a Reply

Your email address will not be published. Required fields are marked *