Skip to content

Instantly share code, notes, and snippets.

@cmccandless
Created April 24, 2018 18:02
Show Gist options
  • Save cmccandless/1cd6257e1c0433ce01cebd71611811b2 to your computer and use it in GitHub Desktop.
Save cmccandless/1cd6257e1c0433ce01cebd71611811b2 to your computer and use it in GitHub Desktop.
ifconfig bash completion
_ifconfig()
{
local cur prev interfaces
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case "${COMP_CWORD}" in
1) interfaces=$(ifconfig | grep -oP "^\w+") ;;
esac
COMPREPLY=( $(compgen -W "${interfaces}" -- ${cur}) )
}
complete -F _ifconfig ifconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment