Add completion for figlet.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 12 Feb 2017 14:21:32 +0200
changeset 825 b1536ac2ff88
parent 824 b8ac1e0a719a
child 826 54d42c57cc4d
Add completion for figlet.
.bash_completion.d/figlet
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.bash_completion.d/figlet	Sun Feb 12 14:21:32 2017 +0200
@@ -0,0 +1,25 @@
+# -*- 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