I am attempting to simplify repetitive work procedures. In doing so, I am trying to write a .bashrc script which will set global path variables that aliases can refer to. Disclaimer: I'm new to linux and scripting in general so I don't know if the approach I've taken to this point is correct.
Here is what I've written so far.
SET_DIR=/var/www/
#Set the current site's root directory
function sroot (){
SET_DIR=/var/www/$1
setaliases
echo $SET_DIR
}
#Reinitialize aliases with new sroot
function setaliases(){
alias chk="echo $SET_DIR"
alias rt="cd $SET_DIR"
alias thm="cd $SET_DIR/sites/all/themes/"
alias mod="cd $SET_DIR/sites/all/modules"
}
setaliases
What I would like to do is expand this Idea to define sites in an array or a file. Then use a function that will check the value passed to the sroot function. This will in turn set variables in other functions.
#myfile or array
site=example1.com
theme=alpha
shortcut=x1
site=example2.com
theme=beta
shortcut=x2
So for example "sroot x1" would affect
SET_DIR=/var/www/$site
# and
alias thm="cd $SET_DIR/sites/all/themes/$theme"
How do I configure the function to check for a value in an array then use it's variables?