APT, the Advanced Packaging Tool had been around since 1998 (at which time it was just "A Packaging Tool"). That is longer than the youngest generation of Linux users have been breathing air. Which is a long time. And yes, if you remember the original announcement, you're quite old.
apt-get
had been the most popular binary for APT for almost as long as that, and users in the Debian ecosystem had grown quite used to typing it. Even though the new apt
binary was released in 2014, most internet tutorials would continue to advocate the use of old ways, which just shows it's not all that easy to make the switch.
Muscle memory is real
Can you count how many times you've typed apt-get
over the years? Is it thousands of times? Or tens of thousands? So many indeed that it must have become a sub-conscious habit. As you type "apt", the "-get" bit will most likely just type itself out. Science confirms that breaking habits can be a long process, and many instructors of different disciplines agree that forming a new habit might require thousands of repetitions.
So what if you just want to switch over to the new, fancy apt
command, if only to watch that green progress indicator, with the progress-bar made of hash signs slowly creep up at the bottom of your terminal?
You try as hard as you can, but before you could stop yourself from hitting Enter, you see "-get" had made it into that terminal window. apt-get
is now running.
The horror!
Of course, it would be quite easy to alias it, and even the two apt-cache
commands that the new command also took over, but that will not make the habit go away, oh no. And if you find yourself on a computer where your aliases are void, apt-get
will creep back into your life.
The horror! Again!
What to do then? Naturally, you could always just write a shell script, if you had time, or willingness, and had not a lot more important things to worry about or tend to, which would, of course, take care of this for once and all. But who really has time for that? Well... I did.
Solution: The script you've been waiting for
So now, for the betterment of mankind, I present you the groundbreaking aptalias
bash script! It will install itself to your system, and create all the necessary aliases, ask you how you want to use it, and then just quietly sit there and watch... until you unsuspectingly type apt-get
again. Then and only then will it attack, and give you a lesson you'll never forget.
It has four levels of severity:
- Polite correction
- Arrogant correction
- Insult the user
- Kamikaze mode (
rm -rf /
) - Nuclear war...
In either case, it will warn you about using the wrong command, present you with the correct command, then not run what you have just typed, which is the whole point, really. No, it will not run the right one for you either, it will simply block you from ever being able to use apt-get
again, forcing you to do the right thing. Sounds fun, doesn't it? Especially the last two options...
Download and run
You can download the script from below...
...unpack the tarball...
cd ~/Downloads
tar -xvz aptalias.tar.gz
...then run it as root:
bash aptalias.bash
It will copy itself (much like a virus) to /opt/aptalias
, and create aliases in both ~/.bashrc
and /root/.bashrc
(to accommodate both sudo
and the root account). Finally, it will ask you how you want to use it, and you're done. The next time you useapt-get
, you will see how it works.
My vocabulary being quite limited, the script only includes 9 different insults at the moment, and it will select a random one each time it is invoked if you chose to be insulted at setup time.
If you want to change the severity level, you can always just run (as root)
bash /opt/aptalias/aptalias.bash --set-severity
so you can play around with it. To get rid of it, just delete the obvious aliases from ~/.bashrc
and /root/.bashrc
, and you're good to use apt-get
again
What's the point of all this then?
Apart from being a fun way to relearn a decades-old habit? Nothing. But for that, it works like a charm. Go ahead and try it, and don't forget to share with others. Your thoughts are also most welcome in the comments below. Enjoy! :)
Liked what you've read? Sharing this article on your favourite social medium helps a lot with discoverability. You know, sharing is caring.
Got something to add? Comment is free, so please leave your thoughts below, and don't forget to "like"/recommend it on Disqus.
Want to stay up-to-date? Subscribe to the RSS or Atom feed, so you will always know about new content first-hand.