Terminator Bash - How to create shortcut to folders

7,228

You can use the following command from the bash

alias yourAlias='cd /var/www/html'

Here is /var/www/html is the location you want. It could be anything else.

Then you have only to type

yourAlias

from your terminal to go to the desired location what you have already defined.

If you want to make your aliases permanent, add them to the .bash_aliases file in your home directory (create it if necessary), the changes apply for every terminal you open after changing the file.

Share:
7,228

Related videos on Youtube

Kayote
Author by

Kayote

A javascript fan

Updated on September 18, 2022

Comments

  • Kayote
    Kayote over 1 year

    I am using Terminator as my bash cli. Is there a way to create shortcut commands to relevant folders? e.g. We have the default cd ~ which takes us to Home folder.

    How can I create my own custom shortcuts to relevant folders? Reason for asking is that I would like to have shortcuts to various projects within my /var/www/* folders

  • Mark
    Mark over 6 years
    This is as close as you can get IMO without creating a function in BASH that would take an argument.
  • Peshmerge
    Peshmerge over 6 years
    Sorry, what do you mean exactly? What does IMO mean? This is how I am doing it on my online VPS.
  • Kayote
    Kayote over 6 years
    @dessert would you please clarify
  • dessert
    dessert over 6 years
    @Mark A function does not necessarily have to take an argument, yourAlias(){ cd /var/www/html;} gives the exact same result as the alias. Just that it's unnecessary here. :)
  • Mark
    Mark over 6 years
    @dessert Yes, thanks, I'm quite aware functions do not require arguments but the OP indicated cd ~ such that the argument passed was the Tilda. To reproduce the ability to have arguments that would vary, a function would be necessary, not an alias. @Peshmerge IMO=In My Opinion
  • dessert
    dessert over 6 years
    @Mark OK, but you can very well do alias a=cd and then a ~. In fact that's how some aliases are predefined in your ~/.bashrc file, e.g. alias grep='grep --color=auto' which enables colored output of grep by default – calling it as \grep disables the alias for this time.