Created
April 19, 2014 21:15
-
-
Save thirdreplicator/11097740 to your computer and use it in GitHub Desktop.
to switch working on different projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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