]> git.mdlowis.com Git - projs/tide.git/commitdiff
tweaked fcomplete script to add / for dirs
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 2 Dec 2019 03:30:31 +0000 (22:30 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 2 Dec 2019 03:30:31 +0000 (22:30 -0500)
bin/fcomplete

index bb002cba94d179efe8d0cb51dbe18e73a53b36ef..2eb94e24a46c33356a931f9f1391b37e32fa7e67 100755 (executable)
@@ -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