Aliases: Shortcuts for Terminal

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.

shortcut

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
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 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:

##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.

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.

Greetings.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

10 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Abel said

    Blessed aliases that make life a little easier for us, make us more lazy. xD

    I used to have too many but as you say, in the end you end up forgetting the actual commands so now I only use a few to set preferences.

    Greetings and good article.

    1.    KZKG ^ Gaara said

      The same thing happened to me ... I ended up forgetting command, because I used aliases for everything haha ​​...
      Now I only use one to mount ISOs and to extract the audio from a video file, two things that I rarely do hehe 😉

      Greetings and good article 😀

      1.    Maxwell said

        Thank you, I am glad that it has been useful.

        Greetings.

  2.   ren434 said

    If it's true, one ends up forgetting many of the real commands hahaha xD, that's why I only use them now to omit sudo, and I think that I will never forget that one.
    Although if I forgot some 'apropos' command it is salvation.

    1.    ren434 said

      oops! How curious, and great are these chops, I did not know them.

      And ducking xD, I find that there are chops even for emacs, but I don't see anything for Chakra. I'm going to see if I can make one and share it here.

    2.    KZKG ^ Gaara said

      In fact we put some some time ago here hehe: https://blog.desdelinux.net/cubos-comandos-para-distros-gnulinux/

  3.   proper said

    bash-4.1 $ cat .bashrc
    sh / usr / bin / screenfetch-dev
    alias ls = »ls -p –color = auto»
    bash-4.1 $

    That's my .bashrc xD

    1.    KZKG ^ Gaara said

      O_O … WTF !!!

  4.   auroszx said

    I used to use aliases quite a bit, but not to the point of forgetting the original commands… They are certainly very useful 🙂