Nothing like a terminal, its ease, its efficiency and its speed help us in our day to day solve tasks basic or even complex, from renaming large sets of files, or even converting our music library to vorbis format. It all does in a period of much less time than their graphic 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 was that command to mount the usb key? I have put him wrong and above it has given me an error»
Or read something almost inevitable:
maxwell@triskel $> sudo aptt-get install foo
bash: aptt-get: orden no encontrada
And unless we have a good "cheat sheet" with all our commands, or failing that a good memory, we could hardly get out of it. 100% to our console. If you tend to use a terminal intensively, you will not deny that after writing so many commands they can confuse us, and even annoy us. Luckily we have the alias, we took a long and extensive command and assigned it a smaller, abbreviated shortcut, much easier to remember and write.
For example, we have these commands:
sudo apt-get install
sudo apt-get remove
sudo apt-get update
Surely it will be faster and easier for you to type this:
To do this, all you have to do is open your file in a text editor. .bashrc (if you use a shell as bashif 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 through "echo" and even relate sound events to them via mpg321 o 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'
Although, to do something very complex, the most appropriate would be write a separate script, so as not to saturate our file so much .bashrc.
Finally I leave you some of my personal aliases, very personal:
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'
alias format?='sudo mkfs.vfat -F 32 -n'
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'
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?
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:
To remove an alias.
To remove all aliases in the .bashrc.
Although, if one abuses them it can happen that you end up forgetting the actual commands (like me) so best to use them sparingly.
I hope that now if you can get a little more juice from your terminals, now saving at least a little time. Have an excellent weekend, we will read later.