Skip to content

Instantly share code, notes, and snippets.

@philkuz
Created June 8, 2016 21:27
Show Gist options
  • Save philkuz/68ddec2a967cc08454dde81d4451d34a to your computer and use it in GitHub Desktop.
Save philkuz/68ddec2a967cc08454dde81d4451d34a to your computer and use it in GitHub Desktop.
Manages a current project as a script
# Function that sets the current project
function set-project() {
if [ $# -ne 1 ]; then
echo "command should be formatted as 'set-project <project-dir>'"
exit 1
fi
if [ "$1" = "." ]; then
dir=$(pwd)
else
dir="$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
fi
echo $dir >| $PROJECT_CONFIG
}
function get-project() {
projdir=$(<$PROJECT_CONFIG)
echo $projdir
}
alias project="cd $(get-project)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment