Do not auto-complete directories in shell completions (only entries)

This commit is contained in:
2024-03-18 14:39:55 -04:00
parent 26a5898e15
commit e4de8f930b
3 changed files with 21 additions and 19 deletions
+8 -7
View File
@@ -1,16 +1,17 @@
#compdef mutn
mutn_path="$HOME/.local/share/libmutton"
full_paths=("$mutn_path"/**/*)
trimmed_paths=()
for scan_path in "${full_paths[@]}"; do
trimmed_paths+=("${scan_path#$mutn_path}")
mutnPath="$HOME/.local/share/libmutton"
fullPaths=("$mutnPath"/**/*)
trimmedPaths=()
for scanPath in "${fullPaths[@]}"; do
# exclude directories
[ -f "$scanPath" ] && trimmedPaths+=("${scanPath#$mutnPath}")
done
[[ -z $trimmed_paths ]] && trimmed_paths=(help)
[[ -z $trimmedPaths ]] && trimmedPaths=(help)
case ${words[-2]} in
mutn )
compadd $trimmed_paths
compadd $trimmedPaths
;;
/* )
compadd {copy,edit,gen,add,shear}