From 2d3f134c870f8a1a279f2ade4dfbef57b75f6ad9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 17:58:13 +1300 Subject: Reduce ud() completion to just dirnames This was really overdoing it. --- bash/bash_completion.d/ud.bash | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) (limited to 'bash') diff --git a/bash/bash_completion.d/ud.bash b/bash/bash_completion.d/ud.bash index a9912f5a..e6c79716 100644 --- a/bash/bash_completion.d/ud.bash +++ b/bash/bash_completion.d/ud.bash @@ -1,35 +1,2 @@ -# Completion setup for ud -_ud() { - - # Only makes sense for the second argument - ((COMP_CWORD == 2)) || return - - # Iterate through directories, null-separated, add them to completions - local dirname - while IFS= read -rd '' dirname ; do - [[ -n "$dirname" ]] || continue - COMPREPLY[${#COMPREPLY[@]}]=$dirname - done < <( - - # Set options to glob correctly - shopt -s dotglob nullglob - - # Make globbing case-insensitive if appropriate - while read -r _ setting ; do - case $setting in - ('completion-ignore-case on') - shopt -s nocaseglob - break - ;; - esac - done < <(bind -v) - - # Collect directory names, strip trailing slashes - dirnames=("$2"*/) - dirnames=("${dirnames[@]%/}") - - # Print results null-delimited - printf '%s\0' "${dirnames[@]}" - ) -} -complete -F _ud -o filenames ud +# Completie ud() with directory names +complete -A directory ud -- cgit v1.2.3