diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2015-07-06 17:36:52 -0400 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2015-07-06 17:36:52 -0400 |
commit | 26792463b3e1281cb3b58c8bfcb7d712d576f0e1 (patch) | |
tree | 942f31f0e4c66c8220b75bf2b3cc7e966a93bafb /zshrc | |
parent | 94f70c4c2ed3d65c9f07c4976fa7123a773b98f7 (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-x | zshrc | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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 |