1

I use the following procedure to set up a shortcut for accessing directory

$ pwd
$ user/home/somefolder/somefolder1
$ export SHORTCUT=$PWD

Now if I am in my home directory and type

$ pwd
$ user/home
$ cd $SHORTCUT
$ pwd
$ user/home/somefolder/somefolder1

But this method works only for one session and if I restart the terminal the above set shortcut does not seem to work. Is this the way it's supposed to happen or am I doing something wrong? Also if it works this way, is there a way to permanently set this shortcut?

2 Answers 2

2

Type the following from the terminal

gedit ~/.bashrc

This will open a window

Type this as the last line and save the file and close gedit.

export SHORTCUT=user/home/somefolder/somefolder1

Now close the terminal and open it again.

You can straight away do cd $SHORTCUT

0

if the directory is fixed, use an alias

alias cdshortcut='cd user/...'

If you want to be able to set an arbitrary directory and have it persist:

shortcut   () { pwd > ~/.shortcut; }
cdshortcut () { cd "$(< ~/.shortcut)"; }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .