Skip to content

Instantly share code, notes, and snippets.

@thirdreplicator
Created April 19, 2014 21:15
Show Gist options
  • Save thirdreplicator/11097740 to your computer and use it in GitHub Desktop.
Save thirdreplicator/11097740 to your computer and use it in GitHub Desktop.
to switch working on different projects
# Usage example
~/Projects/foo> wol
foo
bar
~/Projects/foo> wop bar
source ~/.bashrc
~/Projects/bar>
# The net result is that whenever you open a new terminal, you'll be in your current working project's directory.
alias wo='work_on'
alias wol='work_on list'
alias wop='work_on project'
# Projects
export_project () { export $1=$2; }
export_project foo $HOME/Projects/foo
export_project bar $HOME/Projects/bar
current_project=$foo
cd $current_project
# Define set project function
set_project () { sed -i '' "s/current_project=\$.*$/current_project=\$$1/" ~/.bashrc; }
case "${1:-''}" in
'list')
grep export_project ~/.bashrc | grep -v "export_project ()" | cut -d' ' -f2
;;
'project')
set_project $2
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment