Created
December 10, 2010 14:03
-
-
Save mattash/736228 to your computer and use it in GitHub Desktop.
A bash script to interact with project directory structure
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
# Changes into the project's directory. All of my projects are stored in | |
# $PROJECTDIR/. Some of them are still on subversion, thus the need for all | |
# of the checks on "trunk". They often have one or more of the following | |
# subdirectories: application, prototype, mockups, artwork, or website. | |
# The command takes to parameters: the name of the project and the sub- | |
# directory. The application subdirectory is assumed if nothing is passed. | |
PROJECTDIR=/Volumes/MEDIA/projects | |
project () | |
{ | |
if [[ -e $PROJECTDIR/$1/trunk ]] | |
then | |
if [ $2 ] | |
then | |
cd $PROJECTDIR/$1/trunk/$2 | |
else | |
if [[ -e $PROJECTDIR/$1/trunk/$1 ]] | |
then | |
cd $PROJECTDIR/$1/trunk/$1 | |
else | |
cd $PROJECTDIR/$1/trunk | |
fi | |
fi | |
else | |
if [ $2 ] | |
then | |
if [[ -e $PROJECTDIR/$1/assets/$2 ]] | |
then | |
cd $PROJECTDIR/$1/assets/$2 | |
else | |
cd $PROJECTDIR/$1/$2 | |
fi | |
else | |
if [[ -e $PROJECTDIR/$1/application ]] | |
then | |
cd $PROJECTDIR/$1/application | |
else | |
cd $PROJECTDIR/$1 | |
fi | |
fi | |
fi | |
} | |
alias pr=project | |
alias prs="cd $PROJECTDIR; ls" | |
_projectsCompletion() { | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
local ff=$(\ls -d $PROJECTDIR/*/ | cut -d "/" -f5) | |
COMPREPLY=( $(compgen -W "${ff}" -- ${cur}) ) | |
return | |
} | |
complete -o bashdefault -F _projectsCompletion pr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment