Skip to content

Instantly share code, notes, and snippets.

@dhilst
Created November 8, 2019 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhilst/308b4b26599b13c20a8ff46603b0fc27 to your computer and use it in GitHub Desktop.
Save dhilst/308b4b26599b13c20a8ff46603b0fc27 to your computer and use it in GitHub Desktop.
xCAT completions
_xcat_complete() {
COMPREPLY=()
if [[ "${COMP_LINE}" =~ ^(ls|rm|ch|mk)def ]] || [[ "$COMP_LINE" =~ ^nodeset ]]; then
if [[ "${COMP_LINE}" =~ "-t network" ]]; then
local networks=$(lsdef -t network | cut -f1 -d' ' | paste -sd ' ')
COMPREPLY=( $(compgen -W "$networks" -- ${COMP_WORDS[-1]}) )
return 0
elif [[ "${COMP_LINE}" =~ "-t osimage" ]] || [[ "$COMP_LINE" =~ "osimage=" ]]; then
COMPREPLY=( $(compgen -W "$(lsdef -t osimage | cut -f1 -d' ' | paste -sd ' ')" -- ${COMP_WORDS[-1]#*=}) )
return 0
fi
fi
}
complete -F _xcat_complete {ls,mk,ch,rm}def nodeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment