public
Description: bash scripts, aliases, other misc things go here
Homepage: http://opensource.thinkrelevance.com
Clone URL: git://github.com/relevance/etc.git
etc / bash / project_aliases.sh
100644 22 lines (19 sloc) 0.722 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# In ~/.bash_profile define a PROJECT_PARENT_DIRS array and source this script. e.g.
# PROJECT_PARENT_DIRS[0]="$HOME/src"
# PROJECT_PARENT_DIRS[1]="$HOME/work"
# source ~/.project_aliases.sh
 
if [ -z "${PROJECT_PARENT_DIRS[*]}" ]; then
echo "Define a PROJECT_PARENT_DIRS array in ~/.bash_profile"
fi
 
for PARENT_DIR in ${PROJECT_PARENT_DIRS[@]} ; do
if [ -d "$PARENT_DIR" ]; then
for PROJECT_DIR in $(/bin/ls $PARENT_DIR); do
if [ ! -z `which $PROJECT_DIR` ]; then
continue # don't set alias if there is something already a command on the path with the same name
      fi
if [ -d "$PARENT_DIR/$PROJECT_DIR" ]; then
alias "$PROJECT_DIR"="cd $PARENT_DIR/$PROJECT_DIR"
fi
done
fi
done