mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-20 03:02:29 +01:00
Prepend "rails", "rake" and "rspec" commands with "spring" when possible
This commit is contained in:
parent
4131a59d1a
commit
8817266698
1 changed files with 31 additions and 0 deletions
31
plugins/spring/spring.plugin.zsh
Normal file
31
plugins/spring/spring.plugin.zsh
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
spring_commands=(rails rake rspec)
|
||||
|
||||
_spring_installed() {
|
||||
which spring > /dev/null 2>&1
|
||||
}
|
||||
|
||||
_within_springified_rails_project() {
|
||||
local check_dir=$PWD
|
||||
while [ $check_dir != "/" ]; do
|
||||
[ -f "$check_dir/bin/spring" ] && return
|
||||
check_dir="$(dirname $check_dir)"
|
||||
done
|
||||
false
|
||||
}
|
||||
|
||||
_run_with_spring() {
|
||||
if _spring_installed && _within_springified_rails_project; then
|
||||
spring $@
|
||||
else
|
||||
$@
|
||||
fi
|
||||
}
|
||||
|
||||
for cmd in $spring_commands; do
|
||||
eval "function springified_$cmd () { _run_with_spring $cmd \$@}"
|
||||
alias $cmd=springified_$cmd
|
||||
|
||||
if which _$cmd > /dev/null 2>&1; then
|
||||
compdef _$cmd springified_$cmd=$cmd
|
||||
fi
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue