I'm currently using bash on Ubuntu, and I work a lot with a directory saved at /home/me/path/to/project_dir. It is a nuisance to change to the directory every time I open bash. So I'd like to save the path to a variable, say projdir, so that I can just do cd projdir. If my working directory changes, I should be able to change the path by overwriting the variable. I want to be able to update the variable easily, preferably with one command, without messing with .bashrc.One important thing is that this variable should persist even if I restart bash. How do I do this? I'd still like to see my home directory when I start up bash, so changing the default starting directory to project_dir is not an option.
Creating a variable to a directory that persists until deletion
bash
Have a look at CDPATH in man bash maybe that is already enough.Otherwise define some alias in .bashrc. I would suggest:alias setp='pwd >~/.projectdir'alias gop='cd $(cat ~/.projectdir)'