Nothing beats a terminal; its ease of use, efficiency, and speed help us in our daily lives to solve basic or even complex tasks, from renaming large sets of files to converting our music library to the Vorbis format. It does all this in a much shorter time than its graphical counterparts.
But what do we do when we have to memorize large amounts of commands?
Let's think like an average user: They can feel very overwhelmed by the amount of commands to use, by their complexity and their different functions (and I really don't blame them). At first glance things like this can throw you back when you start using the terminal. Just count the times we've heard something like:
" Hey, how did that command go for mounting the USB drive? Oh, I entered it wrong and it gave me an error ."
Or read something almost inevitable:
maxwell@triskel $> sudo aptt-get install foo
bash: aptt-get: orden no encontrada
Unless we have a good cheat sheet with all our commands, or failing that, a good memory, we can hardly get the most out of our console . If you're a frequent user of the terminal, you'll know that typing so many commands can be confusing and even frustrating. Luckily, we have aliases . We take a long, complex command and assign it a shorter, abbreviated shortcut that's much easier to remember and type.
For example, we have these commands:
sudo apt-get install
sudo apt-get remove
sudo apt-get update
apt-cache search
Surely it will be faster and easier for you to type this:
apt-sys
apt-ren
apt-up
apt-find
To do this, all you have to do is open your .bashrc file in a text editor (if you use bash as your shell ; if you use zhs , they go in .zshrc ), and add something like:
alias apt-sys='sudo apt-get install'
alias apt-ren='sudo apt-get remove'
alias apt-up='sudo apt-get update'
alias apt-find='apt-cache search'
And that's not all, we can add many useful functions, from unzipping, listening to music randomly from a directory, compressing, knowing the date, reminders, moving between directories, etc.
It is also possible to add some color to them using "echo" and even link sound events to them via mpg321 or ogg123.
Some basic examples with directory navigation:
## Dir shortcuts
alias atras='cd ..'
alias documentos='cd ~/documentos'
alias descargas='cd ~/descargas'
alias imagenes='cd ~/imagenes'
alias videos='cd ~/videos'
However, to do something very complex, it would be more appropriate to write a separate script , so as not to overload our .bashrc file.
Finally, here are some of my personal, very personal, aliases :
##Actualizar Trisquel
alias apt-dist!!='echo -e "\e[1;31mPeligro, peligro, que vas \e[1;37ma actualizar la distro entera o_o" && sudo apt-get update;apt-get -f -y dist-upgrade'
##Formatear
alias format?='sudo mkfs.vfat -F 32 -n'
##Editar bashrc
alias bash?='ne ~/.bashrc'
##Ver versión de Trisquel
alias trisquel?='cat /etc/lsb-release'
##Abrir navegador w3m
alias galeon?='echo -e "\e[0;32m:: :: ::\e[1;37mGaleon iniciado\e[0;32m:: :: ::" && sleep 2 && w3m http://trisquel.info/es'
##Salir
alias e?='exit'
##Dispositivos conectados
alias usb?='dmesg | grep sd'
##Saber el dÃa y la hora
alias hoy?='echo -e "\e[1;31mPor favor deja de ser \e[1;37mtan vago, \e[1;33mmira que hoy es\e[1;32m:" && date "+%Y-%m-%d %A %T %Z" && echo -e "\e[1;37m Además yo no soy tu niñera -__-"'
And do you have some good aliases to share?
Efficient launchers
And with this we conclude this small review on aliases and their uses, remember that if you want to eliminate any aliases you can use the utility Unalias:
unalias mi-alias
To remove an alias.
unalias a
To remove all aliases in the .bashrc file.
However, if you overuse them you might end up forgetting the real commands (like I did), so it's best to use them in moderation.
I hope you can now get a little more out of your devices, saving at least some time . Have a great weekend, and we'll talk again later.
Greetings.