summaryrefslogtreecommitdiff
path: root/zshrc
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2015-07-06 17:36:52 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2015-07-06 17:36:52 -0400
commit26792463b3e1281cb3b58c8bfcb7d712d576f0e1 (patch)
tree942f31f0e4c66c8220b75bf2b3cc7e966a93bafb /zshrc
parent94f70c4c2ed3d65c9f07c4976fa7123a773b98f7 (diff)
ZSH get-parent-dir.
Supports this: $ cp M-u M-u M-u foo ./ As a substitute for: $ cp ../../../foo ./
Diffstat (limited to 'zshrc')
-rwxr-xr-xzshrc13
1 files changed, 13 insertions, 0 deletions
diff --git a/zshrc b/zshrc
index a5570a2..8db2a50 100755
--- a/zshrc
+++ b/zshrc
@@ -59,3 +59,16 @@ export TZ='America/New_York'
autoload -U edit-command-line
zle -N edit-command-line
bindkey "^V" edit-command-line
+
+function get-parent-dir() {
+ words=(${(z)LBUFFER})
+ if [[ "${words[${#words}]}" = /* ]]; then
+ # There is already a path thing here.
+ words[${#words}]="${words[${#words}]:h}/" # Parent directory.
+ else
+ words=($words $PWD)
+ fi
+ LBUFFER="${words[@]}"
+}
+zle -N get-parent-dir
+bindkey "^[u" get-parent-dir