mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
Add string collect
The `string collect` subcommand behaves quite similarly in practice to `string split0 -m 0` in that it doesn't split its output, but it also takes an optional `--trim-newline` flag to trim a single trailing newline off of the output. See issue #159.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Completion for builtin string
|
||||
# This follows a strict command-then-options approach, so we can just test the number of tokens
|
||||
complete -f -c string
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and not contains -- (commandline -opc)[2] escape" -s q -l quiet -d "Do not print output"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and not contains -- (commandline -opc)[2] escape collect" -s q -l quiet -d "Do not print output"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "lower"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "upper"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "length"
|
||||
@@ -13,6 +13,8 @@ complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "split0"
|
||||
complete -x -c string -n 'test (count (commandline -opc)) -ge 2; and string match -qr split0\?\$ -- (commandline -opc)[2]' -s m -l max -a "(seq 1 10)" -d "Specify maximum number of splits"
|
||||
complete -f -c string -n 'test (count (commandline -opc)) -ge 2; and string match -qr split0\?\$ -- (commandline -opc)[2]' -s r -l right -d "Split right-to-left"
|
||||
complete -f -c string -n 'test (count (commandline -opc)) -ge 2; and string match -qr split0\?\$ -- (commandline -opc)[2]' -s n -l no-empty -d "Empty results excluded"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "collect"
|
||||
complete -f -c string -n 'test (count (commandline -opc)) -ge 2; and string match -qr collect\$ -- (commandline -opc)[2]' -s n -l trim-newline -d "Remove trailing newline"
|
||||
|
||||
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "join"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "join0"
|
||||
|
||||
Reference in New Issue
Block a user