Skip to content

Bash Shell Completion

Stephen Illingworth edited this page Feb 21, 2026 · 1 revision

Calling gopher2600 from the command line can be aided with this bash completion script. It is not a comprehensive completion script but it's good enough for me during development. It currently focuses on modes rather than options.

_gopher2600() {
	local cur prev opts

	cur="${comp_words[comp_cword]}"

	compreply=()

	for i in "${comp_words[@]}"
	do
		case "${i}" in
			${comp_words[comp_cword]})
				opts="run play debug headless disasm performance regress version"
				;;

			regress)
				opts="-help run list delete add redux cleanup"
				;;

			play)
				opts="-help"
				;;

			run)
				opts="-help"
				;;

			debug)
				opts="-help"
				;;

			performance)
				opts="-help"
				;;
		esac
	done

	compreply=( $(compgen -w "${opts}" -- "${cur}") )
	return
}

if [[ $(type -t compopt) = "builtin" ]]; then
	complete -o default -f _gopher2600 gopher2600
	complete -o default -f _gopher2600 go run gopher2600
	complete -o default -f _gopher2600 gotip run gopher2600
else
	complete -o default -o nospace -f _gopher2600 gopher2600
	complete -o default -o nospace -f _gopher2600 go run gopher2600
	complete -o default -o nospace -f _gopher2600 gotip run gopher2600
fi

Clone this wiki locally