From: Michael D. Lowis Date: Mon, 2 Dec 2019 03:30:31 +0000 (-0500) Subject: tweaked fcomplete script to add / for dirs X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=da40d8af8d71a66f34aa5fd619fbff6dcf585e58;p=projs%2Ftide.git tweaked fcomplete script to add / for dirs --- 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