Shell Auto Completion ===================== tests/test.py ------------- ### Bash Short version: copy this into your .profile file: _cfa_test() ( (case $3 in (--continue|--debug|--install|--timout-with-gdb) echo yes no;; (--arch) echo x86 x64;; (-I|--include|-E|--exclude) $1 --list-comp | tr ' ' '\n' | sed -e 's@/[^/]\+$@/@;t;d';; (*) $1 --list-comp;; esac) | grep -Ewoe "$2[^[:space:]]*" ) complete -C _cfa_test tests/test.py The long version includes reading the bash manual, check for the complete built-in and readline programmable completion for details on how these commands are used. You can copy-paste the results directily into your terminal to test them or put them in one of the initalization files so they are loaded at start-up. This particular script does not handle the comma seperated options. ### Zsh 1 - Add the following somewhere: #compdef test.py _test_py() { local -a options options=$($words[1] --list-comp) _alternative "files:filenames:($options)" } _test_py "$@" 2 - Add the path to that file to the "fpath" environment variable. 3 - In ~/.zshrc add autoload -U compinit compinit *How it works:* I don't know ;P