Skip to content

Instantly share code, notes, and snippets.

@aperezm-vlex
Created February 16, 2017 15:23
Show Gist options
  • Save aperezm-vlex/8693476b7cc4b3586d3a3e01a391c4f8 to your computer and use it in GitHub Desktop.
Save aperezm-vlex/8693476b7cc4b3586d3a3e01a391c4f8 to your computer and use it in GitHub Desktop.
rvm, z and nave automated
rename_function() {
declare -F $1 > /dev/null || return 1
eval "$(echo "${2}()"; declare -f ${1} | tail -n +2)"
}
if [[ $(type -t old_cd) == "function" ]]; then
echo "old_cd already exists" > /dev/null
elif [[ $(type -t cd) == "function" ]]; then
rename_function cd old_cd
cd() {
old_cd "$*"
exec nave auto
}
if [[ $(type -t z) == "alias" && $(type -t old_z) != "alias" ]]; then
unalias z
function z {
_z 2>& "$*"
exec nave auto
}
fi
else
alias cd='exec nave auto'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment