3

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

6

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.

6
  • 1
    This is as close as you can get IMO without creating a function in BASH that would take an argument.
    – Mark
    Sep 21 '17 at 20:44
  • Sorry, what do you mean exactly? What does IMO mean? This is how I am doing it on my online VPS.
    – Peshmerge
    Sep 21 '17 at 20:45
  • @dessert would you please clarify
    – Kayote
    Sep 21 '17 at 21:41
  • 1
    @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. :)
    – dessert
    Sep 21 '17 at 21:48
  • @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
    – Mark
    Sep 21 '17 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.