Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Commit

Permalink
Initial tab autocomplete (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored and Landrash committed Oct 29, 2017
1 parent 3d63ce2 commit 41f763d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions package/etc/bash_completion.d/hassbian-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
_hassbian-config()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="install upgrade show"

case "${prev}" in
install)
local inst=$(find /opt/hassbian/suites/ -maxdepth 1 -type f -name 'install_*' | grep -v 'install_homeassistant.sh' | awk -F'/|_' ' {print $NF}' | awk -F. '{print $1}')
COMPREPLY=( $(compgen -W "${inst}" -- ${cur}) )
return 0
;;
upgrade)
local upd=$(find /opt/hassbian/suites/ -maxdepth 1 -type f -name 'upgrade*' | awk -F'/|_' ' {print $NF}' | awk -F. '{print $1}')
COMPREPLY=( $(compgen -W "${upd}" -- ${cur}) )
return 0
;;
*)
;;
esac

COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
}
complete -F _hassbian-config hassbian-config

0 comments on commit 41f763d

Please sign in to comment.