diff options
| author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2025-05-18 03:06:16 +0000 |
|---|---|---|
| committer | Daniel Shahaf <d.s@daniel.shahaf.name> | 2025-05-18 03:06:16 +0000 |
| commit | 2ccf41e5772cbfb22802365a26872b796833a7c6 (patch) | |
| tree | 255d536b7420a945a84de679bcc3ae8793447972 /Completion | |
| parent | unposted: Fix a ChangeLog typo reported offlist. (diff) | |
| download | zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.gz zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.bz2 zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.lz zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.xz zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.zst zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.zip | |
github #134 (+ implement commit review suggestion): __git_worktrees: Use a library function
Using _describe makes the completions and descriptions line up in
columns, and makes the function honour the list-separator style.
Diffstat (limited to 'Completion')
| -rw-r--r-- | Completion/Unix/Command/_git | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 702360ef3..95bd3096d 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -8514,6 +8514,7 @@ __git_worktrees () { local -a records=( ${(ps.\n\n.)"$(_call_program directories git worktree list --porcelain)"} ) local -a directories descriptions local i hash branch + local match mbegin mend for i in $records; do directories+=( ${${i%%$'\n'*}#worktree } ) hash=${${${"${(f)i}"[2]}#HEAD }[1,9]} @@ -8527,9 +8528,10 @@ __git_worktrees () { branch="[$branch]" fi - descriptions+=( "${directories[-1]}"$'\t'"$hash $branch" ) + descriptions+=( "${directories[-1]//(#b)([\\:])/\\${match[1]}}":"$hash $branch" ) done - _wanted directories expl 'working tree' compadd -ld descriptions -S ' ' -f -M 'r:|/=* r:|=*' -a directories + + _describe -t directories 'working tree' descriptions -S ' ' -f -M 'r:|/=* r:|=*' } (( $+functions[__git_difftools] )) || |
