From da40d8af8d71a66f34aa5fd619fbff6dcf585e58 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sun, 1 Dec 2019 22:30:31 -0500 Subject: [PATCH] tweaked fcomplete script to add / for dirs --- bin/fcomplete | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/fcomplete b/bin/fcomplete index bb002cb..2eb94e2 100755 --- a/bin/fcomplete +++ b/bin/fcomplete @@ -3,4 +3,15 @@ orig="$1" path="${orig%/*}" file="${orig##*/}" [ "$path" = "$file" ] && path="." -printf "%s" "$(find "$path" -maxdepth 1 -path "$path/*$file*" | pick "$path/$file")" + +# pick the path +pickpath="$(find "$path" -maxdepth 1 -path "$path/*$file*" | pick "$path/$file")" + +# Print the result +if [ -z "$pickpath" ]; then + printf "%s" "$orig" +elif [ -d "$pickpath" ]; then + printf "%s" "$pickpath/" +else + printf "%s" "$pickpath" +fi -- 2.51.0