X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=cf20ca75e9a202a0bc5b68aea4e119c29ec4019b;hb=aad6e4ee9274c7d0ed98d50ced3c9795cd48fb9c;hp=d5bbfa0bae3c1623c460a42da9fb278eff7e995f;hpb=5f0f906bd2a6d5d0f14094368089a69dfc6927ad;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index d5bbfa0..cf20ca7 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -2655,6 +2655,17 @@ fir() { firefox -a firefox -remote "openURL($1)" || firefox ${1}& fi } +# smart cd function, allows switching to /etc when running 'cd /etc/fstab' +cd() { + if [[ -f ${1} ]]; then + [[ ! -e ${1:h} ]] && return 1 + print "Correcting ${1} to ${1:h}" + builtin cd ${1:h} + else + builtin cd ${1} + fi +} + #f5# Create Directoy and \kbd{cd} to it mcd() { mkdir -p "$@" && cd "$@"