summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-07-05 20:53:14 +0200
committerFlorian Pritz <bluewind@xinu.at>2018-07-05 20:53:14 +0200
commit6c7769112eaa213c09d412a8dba51e59f2240bea (patch)
tree7bf2f7955568622b71bc7ef3b1e7de23d2e82b40
parent5aeb17165ffce38c2956f255b792d54fb534e7dc (diff)
downloaddotfiles-6c7769112eaa213c09d412a8dba51e59f2240bea.tar.gz
dotfiles-6c7769112eaa213c09d412a8dba51e59f2240bea.tar.xz
zshrc: Add cd $file correction
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--.zshrc10
1 files changed, 10 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
index 2706434..2ae57bb 100644
--- a/.zshrc
+++ b/.zshrc
@@ -297,6 +297,16 @@ SPROMPT='zsh: correct '%R' to '%r' ? ([Y]es/[N]o/[E]dit/[A]bort) '
# }}}
# Functions {{{
+function cd () {
+ if (( ${#argv} == 1 )) && [[ -f ${1} ]]; then
+ [[ ! -e ${1:h} ]] && return 1
+ print "Correcting ${1} to ${1:h}"
+ builtin cd ${1:h}
+ else
+ builtin cd "$@"
+ fi
+}
+
sv() {
vim "sudo:$1"
}