mirror of
https://github.com/lloeki/dotfiles.git
synced 2025-12-06 07:24:39 +01:00
bundler and go suport for bash too
This commit is contained in:
parent
85d27c709e
commit
6f4df09b76
4 changed files with 25 additions and 15 deletions
34
zsh/bundler
34
zsh/bundler
|
|
@ -1,34 +0,0 @@
|
|||
# bundler
|
||||
bundled_commands=(annotate cap capify cucumber foreman guard heroku nanoc rackup rainbows rake rspec ruby shotgun spec spork thin unicorn unicorn_rails irb rails pry)
|
||||
|
||||
_bundler-installed() {
|
||||
which bundle > /dev/null 2>&1
|
||||
}
|
||||
|
||||
_within-bundled-project() {
|
||||
local check_dir=$PWD
|
||||
while [ "$(dirname $check_dir)" != "/" ]; do
|
||||
[ -f "$check_dir/Gemfile" ] && return
|
||||
check_dir="$(dirname $check_dir)"
|
||||
done
|
||||
false
|
||||
}
|
||||
|
||||
_run-with-bundler() {
|
||||
if _bundler-installed && _within-bundled-project; then
|
||||
bundle exec $@
|
||||
else
|
||||
$@
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
fi
|
||||
done
|
||||
|
||||
# vim: ft=zsh
|
||||
35
zsh/go
35
zsh/go
|
|
@ -1,35 +0,0 @@
|
|||
go_commands=(go)
|
||||
|
||||
_go-installed() {
|
||||
which go > /dev/null 2>&1
|
||||
}
|
||||
|
||||
_within-go-project() {
|
||||
local check_dir=$PWD
|
||||
while [ "$(dirname $check_dir)" != "/" ]; do
|
||||
if [ -f "$check_dir/.gopath" ]; then
|
||||
echo "$check_dir"
|
||||
return
|
||||
fi
|
||||
check_dir="$(dirname $check_dir)"
|
||||
done
|
||||
false
|
||||
}
|
||||
|
||||
_run-with-gopath() {
|
||||
local go_path
|
||||
if _go-installed && go_path=$(_within-go-project); then
|
||||
GOPATH="$go_path" $@
|
||||
else
|
||||
$@
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
fi
|
||||
done
|
||||
4
zsh/rc
4
zsh/rc
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue