bundler and go suport for bash too

This commit is contained in:
Loic Nageleisen 2013-12-19 10:24:26 +01:00
parent 85d27c709e
commit 6f4df09b76
4 changed files with 25 additions and 15 deletions

View file

@ -8,6 +8,8 @@ source $DOTFILES_BASH_DIR/prompt
source $DOTFILES_BASH_DIR/history source $DOTFILES_BASH_DIR/history
source $DOTFILES_BASH_DIR/term_title source $DOTFILES_BASH_DIR/term_title
source $DOTFILES_BASH_DIR/completion source $DOTFILES_BASH_DIR/completion
source $DOTFILES_SHELL_DIR/bundler
source $DOTFILES_SHELL_DIR/go
precmd() { precmd() {
set_prompt set_prompt

View file

@ -7,9 +7,11 @@ _bundler-installed() {
_within-bundled-project() { _within-bundled-project() {
local check_dir=$PWD local check_dir=$PWD
while [ "$(dirname $check_dir)" != "/" ]; do local next_check_dir=${check_dir%/*}
[ -f "$check_dir/Gemfile" ] && return while [ "$next_check_dir" != "" ]; do
check_dir="$(dirname $check_dir)" [[ -f "$check_dir/Gemfile" ]] && return
check_dir="$next_check_dir"
next_check_dir=${check_dir%/*}
done done
false false
} }
@ -22,13 +24,15 @@ _run-with-bundler() {
fi fi
} }
for cmd in $bundled_commands; do for cmd in ${bundled_commands[@]}; do
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}" eval "function bundled_$cmd () { _run-with-bundler $cmd \$@; }"
alias $cmd=bundled_$cmd alias $cmd=bundled_$cmd
if which _$cmd > /dev/null 2>&1; then if [[ -n $ZSH_VERSION ]]; then
if declare -f _$cmd > /dev/null 2>&1; then
compdef _$cmd bundled_$cmd=$cmd compdef _$cmd bundled_$cmd=$cmd
fi fi
fi
done done
# vim: ft=zsh # vim: ft=zsh

View file

@ -6,12 +6,14 @@ _go-installed() {
_within-go-project() { _within-go-project() {
local check_dir=$PWD local check_dir=$PWD
while [ "$(dirname $check_dir)" != "/" ]; do local next_check_dir=${check_dir%/*}
while [ "$next_check_dir" != "" ]; do
if [ -f "$check_dir/.gopath" ]; then if [ -f "$check_dir/.gopath" ]; then
echo "$check_dir" echo "$check_dir"
return return
fi fi
check_dir="$(dirname $check_dir)" check_dir="$next_check_dir"
next_check_dir=${check_dir%/*}
done done
false false
} }
@ -25,11 +27,13 @@ _run-with-gopath() {
fi fi
} }
for cmd in $go_commands; do for cmd in ${go_commands[@]}; do
eval "function gopath_$cmd () { _run-with-gopath $cmd \$@}" eval "function gopath_$cmd () { _run-with-gopath $cmd \$@; }"
alias $cmd=gopath_$cmd alias $cmd=gopath_$cmd
if [[ -n $ZSH_VERSION ]]; then
if which _$cmd > /dev/null 2>&1; then if which _$cmd > /dev/null 2>&1; then
compdef _$cmd gopath_$cmd=$cmd compdef _$cmd gopath_$cmd=$cmd
fi fi
fi
done done

4
zsh/rc
View file

@ -11,8 +11,8 @@ source $DOTFILES_ZSH_DIR/keybindings
source $DOTFILES_ZSH_DIR/vi source $DOTFILES_ZSH_DIR/vi
source $DOTFILES_ZSH_DIR/completion source $DOTFILES_ZSH_DIR/completion
source $DOTFILES_ZSH_DIR/prompt source $DOTFILES_ZSH_DIR/prompt
source $DOTFILES_ZSH_DIR/bundler source $DOTFILES_SHELL_DIR/bundler
source $DOTFILES_ZSH_DIR/go source $DOTFILES_SHELL_DIR/go
source $DOTFILES_SHELL_DIR/git_prompt_info source $DOTFILES_SHELL_DIR/git_prompt_info
GIT_PS1_SHOWDIRTYSTATE=1 GIT_PS1_SHOWDIRTYSTATE=1