From 26792463b3e1281cb3b58c8bfcb7d712d576f0e1 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Mon, 6 Jul 2015 17:36:52 -0400 Subject: ZSH get-parent-dir. Supports this: $ cp M-u M-u M-u foo ./ As a substitute for: $ cp ../../../foo ./ --- zshrc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'zshrc') 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 -- cgit v1.2.3