Skip to content

Commit

Permalink
let the cheat sheet function support additional local directories
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Apr 14, 2012
1 parent fca5775 commit 49901ba
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions bashrc
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,10 @@
export CLICOLOR=1 export CLICOLOR=1
export DOTFILES=$(cd `dirname "$BASH_SOURCE"` && pwd) # assumes this file is sourced
export PATH="$DOTFILES/bin":$PATH

if [[ -d $HOME/bin ]]; then
export PATH=$HOME/bin:$PATH
fi


# Given an array GO_SHORTCUTS defined elsewhere with pairs shorcut -> directory: # Given an array GO_SHORTCUTS defined elsewhere with pairs shorcut -> directory:
# #
Expand Down Expand Up @@ -105,25 +111,23 @@ function parse_git_branch {
} }
PS1="\u@\h:\w \$(parse_git_branch)\$ " PS1="\u@\h:\w \$(parse_git_branch)\$ "


# Add this project's bin directory to the PATH. Assumes this bashrc is sourced.
dotfiles=$(cd `dirname "$BASH_SOURCE"` && pwd)
export PATH="$dotfiles/bin":$PATH

if [[ -d $HOME/bin ]]; then
export PATH=$HOME/bin:$PATH
fi

# #
# --- Cheat Sheets ------------------------------------------------------------ # --- Cheat Sheets ------------------------------------------------------------
# #

export CHEAT_SHEETS=($DOTFILES/cheat-sheets)
function cs { function cs {
pushd $dotfiles/cheat-sheets > /dev/null local len=${#CHEAT_SHEETS[@]}
if [ -z "$1" ]; then
ls -1 # lists available cheat sheets for (( i=0; i<$len; i+=1 ));
elif [ -f $1* ]; then do
${EDITOR-subl} $1* # read/edit existing cheat sheet by prefix pushd "${CHEAT_SHEETS[$i]}" > /dev/null
else echo -- $(pwd)
${EDITOR-subl} $1 # cheat sheet creation if [ -z "$1" ]; then
fi ls -1 # lists available cheat sheets
popd > /dev/null elif [ -f $1* ]; then
${EDITOR-subl} $1* # read/edit existing cheat sheet by prefix
fi
popd > /dev/null
done
} }

0 comments on commit 49901ba

Please sign in to comment.