fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
d7d5d2a9b
master
1# Completions for make 2function __fish_print_make_targets --argument-names directory file 3# Since we filter based on localized text, we need to ensure the 4# text will be using the correct locale. 5set -lx LC_ALL C 6 7set -l makeflags -C$directory 8if test -n " $file " 9set -a makeflags -f$file 10end 11 12if make --version2> /dev/null| string match -q'GNU*' 13# https://stackoverflow.com/a/26339924 14make $makeflags -pRrq :2> /dev/null| 15awk -F: -v'bs_regex=\\\\\\\\' '/^# Files/,/^# Finished Make data base/ { 16if ($1 == "# Not a target") skip = 1; 17if ($1 !~ "^[#.\t]" && !is_continuation ) { 18if (!skip) print $1; 19skip = 0 20} 21is_continuation = $0 ~ "^([^#]*[^#" bs_regex "])?(" bs_regex bs_regex ")*" bs_regex "$"; 22}' 2> /dev/null 23else 24# FreeBSD/NetBSD 25make $makeflags -V .ALLTARGETS2> /dev/null| string split' ' 26# OpenBSD 27or make $makeflags -d g1 -rn2> /dev/null| awk '/^[^#. \t].+:/ { gsub(/:.*/, "", $1); print $1 }' 28end 29end 30 31function __fish_complete_make_targets 32set -l directory( string replace -rf'^make .*(-C ?|--directory(=| +))([^ ]*) .*$' '$3' --$argv ) 33or set directory . 34set -l file( string replace -rf'^make .*(-f ?|--file(=| +))([^ ]*) .*$' '$3' --$argv ) 35__fish_print_make_targets $directory $file 36end 37 38# This completion reenables file completion on 39# assignments, so e.g. 'make foo FILES=<tab>' will receive standard 40# filename completion. 41complete -c make -n'commandline -ct | string match -q "*=*"' -a"(__fish_complete_make_targets (commandline -p))" -d Target 42complete -f -c make -n'commandline -ct | not string match -q "*=*"' -a"(__fish_complete_make_targets (commandline -p))" -d Target 43complete -c make -s f -d"Use file as makefile" -r 44complete -x -c make -s C -l directory -x -a"(__fish_complete_directories (commandline -ct))" -d"Change directory" 45complete -c make -s d -d"Debug mode" 46complete -c make -s e -d"Environment before makefile" 47complete -c make -s i -d"Ignore errors" 48complete -x -c make -s I -d"Search directory for makefile" -a"(__fish_complete_directories (commandline -ct))" 49complete -f -c make -s j -d"Number of concurrent jobs (no argument means no limit)" 50complete -c make -s k -d"Continue after an error" 51complete -c make -s l -d"Start when load drops" 52complete -c make -s n -d"Do not execute commands" 53complete -c make -s o -r -d"Ignore specified file" 54complete -c make -s p -d"Print database" 55complete -c make -s q -d"Question mode" 56complete -c make -s r -d"Eliminate implicit rules" 57complete -c make -s s -d"Quiet mode" 58complete -c make -s S -d"Don't continue after an error" 59complete -c make -s t -d"Touch files, don't run commands" 60complete -c make -s v -d"Display version and exit" 61complete -c make -s w -d"Print working directory" 62complete -c make -s W -r -d"Pretend file is modified"