From 52f72086c93d4b5faec06665bc352246d3f4ec3f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 28 Feb 2014 18:44:49 +0000 Subject: users 18531 plus doc etc.: new expand-absolute-path widget --- Functions/Zle/.distfiles | 1 + Functions/Zle/expand-absolute-path | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Functions/Zle/expand-absolute-path (limited to 'Functions') diff --git a/Functions/Zle/.distfiles b/Functions/Zle/.distfiles index 256044fa5..5b301b62b 100644 --- a/Functions/Zle/.distfiles +++ b/Functions/Zle/.distfiles @@ -10,6 +10,7 @@ delete-whole-word-match down-case-word-match down-line-or-beginning-search edit-command-line +expand-absolute-path forward-word-match history-beginning-search-menu history-pattern-search diff --git a/Functions/Zle/expand-absolute-path b/Functions/Zle/expand-absolute-path new file mode 100644 index 000000000..b85757600 --- /dev/null +++ b/Functions/Zle/expand-absolute-path @@ -0,0 +1,19 @@ +# expand-absolute-path +# This is a ZLE widget to expand the absolute path to a file, +# using directory naming to shorten the path where possible. + +emulate -L zsh +setopt extendedglob cbases + +autoload -Uz modify-current-argument + +if (( ! ${+functions[glob-expand-absolute-path]} )); then + glob-expand-absolute-path() { + local -a files + files=(${~1}(N:A)) + (( ${#files} )) || return + REPLY=${(D)files[1]} + } +fi + +modify-current-argument glob-expand-absolute-path -- cgit 1.4.1