3 ms·
Happy to help! I am certainly not a master of bash/awk/sed scripting but I do find the ability to express very complex file operations in minimal characters ver
by samwilliams 13y ago
Happy to help! I am certainly not a master of bash/awk/sed scripting but I do find the ability to express very complex file operations in minimal characters very rewarding :).
You will probably have to alias the script[0], as cd'ing in the script won't change the outside environment by default. I cut out a 'function' to make it one line, but I have attached the full source[1]. If you don't pass it any arguments it will tell you all of the available projects :).
[0] Add something like this to your .bashrc
alias project='. project'
[1] The full source:
#!/bin/bash
if [[ $# -eq 0 ]] ; then
awk '{print $1;}' ~/.projects
exit 0
fi
cd $(awk -v proj=$1 '$1 == proj { print $2; }' ~/.projects)