A Code Monkey's Blog

Make apt like zypper

apt is one of the reasons that I like Debian/Ubuntu, but type apt-cache search, apt-cache show, apt-get install, apt-get update, apt-get upgrade is so verbose. To make life easier, I have stolen some ideas from zypper from OpenSUSE by adding the following lines into my .bashrc:

apt() {
 if [ "$1" = "se" ]; then
 apt-cache search $2
 fi

 if [ "$1" = "if" ]; then
 apt-cache show $2
 fi

 if [ "$1" = "up" ]; then
 sudo apt-get update
 fi

 if [ "$1" = "upgrade" ]; then
 sudo apt-get upgrade
 fi

 if [ "$1" = "in" ]; then
 sudo apt-get install $2
 fi

 if [ "$1" = "rm" ]; then
 sudo apt-get remove $2
 fi
 }

Now you can just type 'apt se', 'apt up', 'apt upgrade', 'apt in' and 'apt if' to do the similar things.