I'm trying to add an alias to my .bash_profile to do the following:
xx projname=>cd ~/folder_1/projnameand use node version 6 on nvm if nvm is currently using some other versionyy projname=>cd ~/folder_2/projnameand use node version 4 on nvm if nvm is currently using some other version
I have currently implemented everything except the last portion i.e. if nvm is currently using some other version like so:
function xx { cd ~/folder_1/"$1"; nvm use v6;}
function yy { cd ~/folder_2/"$1"; nvm use v4;}
What is the best way to handle the outstanding task? What I want is something like this:
run
nvm currentand see if index ofv6is false, and then runnvm use v6
But I'm really new to bash and can't seem to find a way to do this. TIA!
nvm run node --version?nvm currentgives the current node version. The output is normallyv6nvm use <node-version>switches node versionsnvm current 2>/dev/null. If it does show, it is stdout; otherwise, stderr.