Created
July 24, 2014 12:39
-
-
Save Darkside73/046c3b69a726678d07eb to your computer and use it in GitHub Desktop.
Oh-my-zsh: alias rails, rake commands to generated spring binstubs on entering project's directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this file to $HOME/.oh-my-zsh/custom/plugins/chpwd_profiles | |
# and add plugin name to .zshrc: plugins=(... chpwd_profiles) | |
function chpwd_profiles() { | |
local -x profile | |
zstyle -s ":chpwd:profiles:${PWD}" profile profile || profile='default' | |
if (( ${+functions[chpwd_profile_$profile]} )) ; then | |
chpwd_profile_${profile} | |
fi | |
CHPWD_PROFILE="${profile}" | |
return 0 | |
} | |
chpwd_functions=( ${chpwd_functions} chpwd_profiles ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this file to $HOME/.oh-my-zsh/custom | |
# projects profile for projects directory and subdirectories where can be located rails projects | |
zstyle ":chpwd:profiles:$HOME/projects(|/|/*)" profile projects | |
# actually call the function | |
chpwd_profiles | |
# Executed when entering the profile | |
chpwd_profile_projects() | |
{ | |
alias_rails_binstub rails | |
alias_rails_binstub rake | |
} | |
# Execute when leaving the profile | |
chpwd_leave_profile_projects() | |
{ | |
alias rails="rails" | |
alias rake="rake" | |
} | |
function alias_rails_binstub () | |
{ | |
if [ -f $PWD/bin/$1 ]; then | |
alias $1="$PWD/bin/$1" | |
else | |
alias $1="$1" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment