Lots of my projects are source-controlled with git and while I’ve got a git-compatible gui application installed, many a time I still find myself literally ‘cd’-ing into the working directory instead.
That’s why I just did myself a favour and have this shell script placed right in my home folder:
#!/bin/bash [ ! -z “$1” ] && echo “Going to $1” || echo “Please specify a destination” case $1 in “destination1”) cd /path/to/destination/1 ;; “destination2”) cd /path/to/destination/2 ;; *) esac
Assuming that script is saved as ‘my_script.sh’ in my home directory (with proper execution permission applied), every time the machine is started up, I’ll just have to type, for example:
. my_script.sh destination1
Please notice the little dot character (.) before the script name because that’s what makes your current interactive shell window actually ‘cd’ into the desired directory.
Kinda wonder why i’ve never done something like this before. My keyboards should last much longer from now on thanks to this..
Updated on Apr 7th 2014
A cousin of mine was saying he’d rather export the values into global variables, which is, of course, another approach, or in that sense, one can utilise alias for pretty much the same result, so yeah, this is mainly just my appetite as I simply don’t want my globals or bash profiles cluttered up with values I might totally have no idea about in 6 months’ time; hence, if I could just store everything in a bit of a “conspicuous” little script file in the home dir, my OCD on organisation might finally leave me alone with my work.