M contrib/completions/bash/wk => contrib/completions/bash/wk +6 -2
@@ 29,8 29,12 @@ _wk () {
done < <(printf '%s\n' "$pages" | grep -iF "$cur")
;;
t|tag|tags)
- local tags
- tags=$(awk '/^tags:/ {$1="";print}' "$WIKI_DIR"/* | tr ',' '\n' | awk '{$1=$1}1' | sort -u)
+ local tags files
+ files=()
+ while IFS='' read -r line; do
+ files+=("$line")
+ done < <(compgen -f "$WIKI_DIR/" | sed -E '/\/[0-9]{14}/!d')
+ tags=$(awk '/^tags:/ {$1="";print}' "${files[@]}" | tr ',' '\n' | awk '{$1=$1}1' | sort -u)
# Prioritize prefix matches but if none exist, fallback to matching
# any substring
M contrib/completions/fish/wk.fish => contrib/completions/fish/wk.fish +7 -4
@@ 6,14 6,17 @@ function __wiki_dir
end
end
-function __fish_complete_wiki_pages
+function __wiki_list_pages
set -q WIKI_DIR; or set -l WIKI_DIR (__wiki_dir)
- printf '%s\n' (command ls $WIKI_DIR | sed -E -e '/[0-9]{14}/!d' -e 's/\.[^.]*$//')
+ command ls -d $WIKI_DIR/* | sed -E '/[0-9]{14}/!d'
+end
+
+function __fish_complete_wiki_pages
+ printf '%s\n' (__wiki_list_pages | sed -E 's/\.[^.]*$//')
end
function __fish_complete_wiki_tags
- set -q WIKI_DIR; or set -l WIKI_DIR (__wiki_dir)
- awk -- '/^tags:/ {$1=""; print}' $WIKI_DIR/* | tr ',' '\n' | awk '{$1=$1}1' | sort -u
+ awk -- '/^tags:/ {$1=""; print}' (__wiki_list_pages) | tr ',' '\n' | awk '{$1=$1}1' | sort -u
end
complete -k -x -c wk -n '__fish_seen_subcommand_from bl backlinks' -a '(__fish_complete_wiki_pages)'