Skip to content

Instantly share code, notes, and snippets.

@thomd
Last active March 29, 2025 16:08
Show Gist options
  • Save thomd/e875f3289b72d4c142ab6b1d3e777f91 to your computer and use it in GitHub Desktop.
Save thomd/e875f3289b72d4c142ab6b1d3e777f91 to your computer and use it in GitHub Desktop.
Graph::Easy bash completion
#!/usr/bin/env bash
_graph_easy_completions() {
local cur prev opts filenames
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--help --input --output --as --from --renderer --parse --stats --timeout --verbose --boxart --html --svg --graphviz --dot --txt --vcg --gdl --graphml"
if [[ ${cur} == -* ]]; then
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
return 0
fi
filenames=$(compgen -f "$cur")
COMPREPLY=( $(compgen -W "${filenames}" -- "${cur}") )
case "${prev}" in
--input|--output)
COMPREPLY=($(compgen -f -- "${cur}"))
return 0
;;
--as)
COMPREPLY=($(compgen -W "ascii boxart html svg graphviz dot txt vcg gdl graphml" -- "${cur}"))
return 0
;;
--from)
COMPREPLY=($(compgen -W "graphviz txt vcg gdl" -- "${cur}"))
return 0
;;
--renderer)
COMPREPLY=($(compgen -W "dot neato twopi fdp circo" -- "${cur}"))
return 0
;;
esac
return 0
}
complete -F _graph_easy_completions graph-easy
@thomd
Copy link
Author

thomd commented Mar 29, 2025

This file was created using the llm CLI tool from Simon Willison.

graph-easy -h |& llm -s "act as a unix bash developer for bash on OSX" "create a bash completion file for this help text of a CLI command. Only print the bash code."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment