Created
June 24, 2017 13:32
-
-
Save yamaguchi1024/0f798bf4aba8ab10fec65082b5715f03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please add "source /path/to/bash-autocomplete.sh" to your .bashrc to use this. | |
_clang() | |
{ | |
local cur prev words cword arg | |
_init_completion -n : || return | |
local w1="${COMP_WORDS[$cword - 1]}" | |
local w2="${COMP_WORDS[$cword - 2]}" | |
if [[ "$cur" == -* ]]; then | |
# -foo<tab> | |
arg="$cur" | |
elif [[ "$w1" == -* && "$cur" == '=' ]]; then | |
# -foo=<tab> | |
arg="$w1=," | |
elif [[ "$w1" == -* ]]; then | |
# -foo <tab> or -foo bar<tab> | |
arg="$w1,$cur" | |
elif [[ "$w2" == -* && "$w1" == '=' ]]; then | |
# -foo=bar<tab> | |
arg="$w2=,$cur" | |
else | |
_filedir | |
fi | |
flags=$( /home/yamaguchi/test-build/bin/clang-5.0 --autocomplete="$arg" ) | |
if [[ "$cur" == "=" ]]; then | |
COMPREPLY=( $( compgen -W "$flags" -- "") ) | |
elif [[ "$flags" == "" ]]; then | |
_filedir | |
else | |
if [[ ${flags: -1} == "=" ]]; then | |
compopt -o nospace | |
fi | |
COMPREPLY=( $( compgen -W "$flags" -- "$cur" ) ) | |
fi | |
} | |
complete -F _clang clang |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment