Skip to content

Instantly share code, notes, and snippets.

@enriched
Created May 2, 2016 19:21
Show Gist options
  • Save enriched/e926659520514ffd06b3c61613980905 to your computer and use it in GitHub Desktop.
Save enriched/e926659520514ffd06b3c61613980905 to your computer and use it in GitHub Desktop.
bash command completion based on lines in a file
_list_from_file()
{
local curr_arg;
curr_arg=${COMP_WORDS[COMP_CWORD]}
filelines=$(cat /some/file)
COMPREPLY=( $(compgen -W "$filelines" -- $curr_arg) );
}
complete -F _list_from_file somecommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment