.bash_completion.d/figlet
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 29 Mar 2023 23:42:06 +0300
changeset 1018 831e2c1bf980
parent 825 b1536ac2ff88
permissions -rw-r--r--
Completed migration from ~/devel to ~/work.

# -*- mode: sh; sh-shell-file: bash -*-

_figlet() {
  local cur=${COMP_WORDS[COMP_CWORD]}
  case "$cur" in
    -*)
      COMPREPLY=( $(compgen -W '-f -d -c -l -r -x -t -w -p -n -D -E -C -N -s -S -k -W -o -m -v -I -L -R -X' -- "$cur") )
      return 0
      ;;
  esac
  if [[ $COMP_CWORD -le 1 ]]; then
      return 0
  fi
  local prev=${COMP_WORDS[COMP_CWORD-1]}
  case "$prev" in
    -f)
      local fonts=( $(cd /usr/share/figlet/; echo *.flf) )
      fonts=( ${fonts[@]%.flf} )
      COMPREPLY=( $(compgen -W '${fonts[@]}' -- "$cur") )
      return 0 ;;
    -d)
      COMPREPLY=( $(compgen -d -- "$cur") )
      return 0 ;;
  esac
} && complete -F _figlet figlet