fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
c5e4fed02
master
1# Completion for builtin string 2# This follows a strict command-then-options approach, so we can just test the number of tokens 3complete -f -c string 4complete -f -c string -n"test (count (commandline -xpc)) -le 2" -s h -l help -d"Display help and exit" 5complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"not contains -- (commandline -xpc)[2] escape collect pad" -s q -l quiet -d"Do not print output" 6complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a lower 7complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a upper 8complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a length 9complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] length" -s V -l visible -d"Use the visible width, excluding escape sequences" 10complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a sub 11complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] sub" -s s -l start -xa"(seq 1 10)" -d"Specify start index" 12complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] sub" -s e -l end -xa"(seq 1 10)" -d"Specify end index" 13complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] sub" -s l -l length -xa"(seq 1 10)" -d"Specify substring length" 14complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a split 15complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a split0 16complete -x -c string -n'test (count (commandline -xpc)) -ge 2' -n'string match -qr split0\?\$ -- (commandline -xpc)[2]' -s m -l max -a"(seq 1 10)" -d"Specify maximum number of splits" 17complete -x -c string -n'test (count (commandline -xpc)) -ge 2' -n'string match -qr split0\?\$ -- (commandline -xpc)[2]' -s f -l fields -a"(seq 1 10)" -d"Specify fields" 18complete -f -c string -n'test (count (commandline -xpc)) -ge 2' -n'string match -qr split0\?\$ -- (commandline -xpc)[2]' -s r -l right -d"Split right-to-left" 19complete -f -c string -n'test (count (commandline -xpc)) -ge 2' -n'string match -qr split0\?\$ -- (commandline -xpc)[2]' -s n -l no-empty -d"Empty results excluded" 20complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a collect 21complete -f -c string -n'test (count (commandline -xpc)) -ge 2' -n'string match -qr collect\$ -- (commandline -xpc)[2]' -s N -l no-trim-newlines -d"Don't trim trailing newlines" 22complete -f -c string -n'test (count (commandline -xpc)) -ge 2' -n'string match -qr collect\$ -- (commandline -xpc)[2]' -s a -l allow-empty -d"Always print empty argument" 23 24complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a join 25complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a join0 26complete -f -c string -n'test (count (commandline -xpc)) -ge 2' -n'contains -- (commandline -xpc)[2] join' -s n -l no-empty -d"Empty strings excluded" 27complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a trim 28complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] trim" -s l -l left -d"Trim only leading chars" 29complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] trim" -s r -l right -d"Trim only trailing chars" 30complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] trim" -s c -l chars -d"Specify the chars to trim (default: whitespace)" -x 31complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a escape 32complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a unescape 33complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] escape; or contains -- (commandline -xpc)[2] unescape" -s n -l no-quoted -d"Escape with \\ instead of quotes" 34complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] escape; or contains -- (commandline -xpc)[2] unescape" -l style -d"Specify escaping style" -xa" 35(printf '%s\t%s\n' script 'For use in scripts' \ 36var 'For use as a variable name' \ 37regex 'For string match -r, string replace -r' \ 38url 'For use as a URL') 39" 40complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a match 41complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] match" -s n -l index -d"Report index, length of match" 42complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] match" -s v -l invert -d"Report only non-matches" 43complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] match" -s e -l entire -d"Show entire matching lines" 44complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] match" -s g -l groups-only -d"Only report capturing groups" 45complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a replace 46complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] replace" -s f -l filter -d"Report only actual replacements" 47# All replace options are also valid for match 48complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] match replace" -s a -l all -d"Report every match" 49complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] match replace" -s i -l ignore-case -d"Case insensitive" 50complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] match replace" -s r -l regex -d"Use regex instead of globs" 51 52complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a repeat 53complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] repeat" -s n -l count -xa"(seq 1 10)" -d"Repetition count" 54complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] repeat" -s m -l max -xa"(seq 1 10)" -d"Maximum number of printed chars" 55complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] repeat" -s N -l no-newline -d"Remove newline" 56complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a pad 57complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] pad" -s r -l right -d"Pad right instead of left" 58complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] pad" -s r -l center -d"Pad both left and right" 59complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] pad" -s c -l char -x -d"Character to use for padding" 60complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] pad" -s w -l width -x -d"Integer width of the result, default is maximum width of inputs" 61complete -f -c string -n"test (count (commandline -xpc)) -lt 2" -a shorten 62complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] shorten" -s l -l left -d"Remove from the left on" 63complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] shorten" -s c -l char -x -d"Characters to use as ellipsis" 64complete -x -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] shorten" -s m -l max -x -d"Integer width of the result, default is minimum non-zero width of inputs" 65complete -f -c string -n"test (count (commandline -xpc)) -ge 2" -n"contains -- (commandline -xpc)[2] shorten" -s N -l no-newline -d"Only keep one line of each input"