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/term_title
source $DOTFILES_BASH_DIR/completion
source $DOTFILES_SHELL_DIR/bundler
source $DOTFILES_SHELL_DIR/go
precmd() {
set_prompt

View file

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

View file

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

4
zsh/rc
View file

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