Utilizing aliases

Since my transition to fish I have started using aliases more and more, and I think you should too.

By standard, the .bashrc file has the following piece of code:

In layman’s terms: If the file .bash_aliases exists in the user’s home folder, parse all lines in it as bash commands. This is a perfect container for all your aliases.

fish doesn’t really have a good config file in the beginning, so you’ll have to create your own file. If you’re (planning on) using fish, I highly recommend you to use my config.fish file which you can download from Scripts and Stuff, which comes with the following snippet:

This does exactly the same as the snippet from .bashrc mentioned above, except it searches for the file aliases.fish in fish‘s configuration folder instead of .bashrc in the home folder. Since I use fish as my primary interactive shell, I won’t be giving much guidance regarding bash, but you should be able to translate most of my code fairly easily.

My aliases.fish looks like this:

I personally find all my aliases self-explanatory, but I put comments everywhere for the sake of it.

Changing to the parent directory is a very common, but surprisingly annoying, task. I’ve seen many people having “..” and/or “cd..” aliased to “cd ..“, but I prefer a simple c.
Since I have switched from screen to tmux I’ve gotten used to typing something as simple as tmux -L irssi attach. For some reason, tmux doesn’t want me to use 256 colors, so I have to force it with the -2 switch.

When I was new to crontab I was very fond of using crontab -r for absolutely no reason at all. I can’t even remember why, but I think I wanted it to simply print the current crontab, and -r would mean “read” and be the correct switch. It was not. crontab -r removes the user’s crontab immediately and without warning. To stop myself from screwing up further, I’ve added a backup task of crontab, in crontab, should I ever delete it again, but I have also made crontab aliased to crontab -i. This means I will be asked for a confirmation if I attempt to use crontab -r again.


As you see, the last three lines are not aliases per se, but rather a single function. Alises are after all very simple functions. Anyway, the function please repeats the last command with sudo prepended, like so:


This is a very useful function, commonly used by me.

Of course, everyone has their preferences, but these are my favorite aliases and I hope I have inspired you somewhat.

Leave a comment if you have any suggestions or ideas for new aliases that you wish to share!

Stefan Persson

Stefan is the owner, maintainer and writer of this website. Computer technology has been in his interest since forever, which has led him to studies and a career in the networking field.

You may also like...

Leave a Reply

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