Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

jellystack-autocomplete.bash (Source)

#!/bin/bash
# trimmed for blog
_show_manager_confs() {
   # reference: vm4:/etc/bash_completion.d/docker-nfs-check
   local cur prev words cword;
   _init_completion || return
   _tmpfile1="$( mktemp )"
   # populate list
   find /mnt/public/Support/Programs/jellyfin/scripts/input -mindepth 1 -maxdepth 1 ! -type d -name '*.conf' -printf '%P\n' | sed -r -e 's/\.conf$//;' > "${_tmpfile1}"
   COMPREPLY=($( compgen -W "$( cat ${_tmpfile1} )" -- "$cur" | sed -r -e "/^${prev}/d;" ))
   command rm -rf "${_tmpfile1:-NOTHINGTODEL}" 1>/dev/null 2>&1
   return 0
} &&
complete -F _show_manager_confs manage-show
. /mnt/public/Support/Programs/jellyfin/scripts/show-manager.sh
alias manage-show="manage_show"