Terminator Bash - How to create shortcut to folders
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.
Related videos on Youtube
Comments
-
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 over 6 yearsThis is as close as you can get IMO without creating a function in
BASH
that would take an argument. -
Peshmerge over 6 yearsSorry, what do you mean exactly? What does IMO mean? This is how I am doing it on my online VPS.
-
Kayote over 6 years@dessert would you please clarify
-
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 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 over 6 years@Mark OK, but you can very well do
alias a=cd
and thena ~
. In fact that's how some aliases are predefined in your~/.bashrc
file, e.g.alias grep='grep --color=auto'
which enables colored output ofgrep
by default – calling it as\grep
disables the alias for this time.