Create your own commands….

I was reading an interesting article the other day about Ken Thompson. One of the creators of UNIX. The thing that struck me was he did not always have the commands he wanted, so started creating his own. Grep is one example of a command he created, something I use often in a terminal.

Ok so what if you wanted to create a command of your own?

Well it is not that difficult and their are a couple of ways to do this. I will start with one I use all the time and that is alias. Open ~/.bashrc and you will see an example of an alias.

# Package sizes
alias pkg_size="expac -H M '%m\t%n' | sort -h"

Looks quite complicated but it basically list all packages and their sizes, smallest to largest. Handy for when I wish to find a large package that has crept into GreenBANG.

Here are some that I use on a daily basis, based around pacman

# Pacman
alias rub="yay -Scc"
alias update="sudo pacman -Syu"
alias load="sudo pacman -S"
alias orphan="sudo pacman -Qtdq | sudo pacman -Rns -"
alias look="pacman -Ss"

Most are really quite simple and easy to understand what they do, up side is I get to perform tasks faster and type less. Sure I could shorten commands even more but then I get confused as to what does this or that.

Well I got you covered, in a terminal simply run:

alias

It will list out all your aliases that are in .bashrc

Once you create or modify an alias just run this to access them:

source .bashrc

They can be as simple or as complicated as you like, for larger more complex items I tend to use a small script instead. Not really visible by alias, but I store then in ~/bin in my home directory.

This is very brief overview of what you can do to make your everyday tasks easier.

If want any help creating an alias of your own drop me an email be sure to include a $10 bill 😉

Enjoy the rest of your weekend

Stay safe…