aboutsummaryrefslogtreecommitdiffhomepage
path: root/share
diff options
context:
space:
mode:
authorGravatar Fabian Homborg <FHomborg@gmail.com>2015-11-12 15:08:47 +0100
committerGravatar Fabian Homborg <FHomborg@gmail.com>2015-11-12 15:08:47 +0100
commite31a93040e46f32267ec3a72eca71a008e5c9e3a (patch)
tree93b4ef4635339357015627324009c0c7b5e67400 /share
parent8e55f7154bb72a544e185b19acaeaade8b3425ed (diff)
Add completion for string
A bit simplistic since we can't complete e.g. regexes properly, but it does the job. Fixes #2543
Diffstat (limited to 'share')
-rw-r--r--share/completions/string.fish25
1 files changed, 25 insertions, 0 deletions
diff --git a/share/completions/string.fish b/share/completions/string.fish
new file mode 100644
index 00000000..2966cac9
--- /dev/null
+++ b/share/completions/string.fish
@@ -0,0 +1,25 @@
+# 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
+complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "length"
+complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "sub"
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] sub" -s s -l start -a "(seq 1 10)"
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] sub" -s l -l length -a "(seq 1 10)"
+complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "split"
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] split" -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 contains -- (commandline -opc)[2] split" -s r -l right -d "Split right-to-left"
+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 "trim"
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] trim" -s l -l left -d "Trim only leading characters"
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] trim" -s r -l right -d "Trim only trailing characters"
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] trim" -s c -l chars -d "Specify the chars to trim (default: whitespace)"
+complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "escape"
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] escape" -s n -l no-quoted -d "Escape with \\ instead of quoting"
+complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "match"
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match" -s n -l index -d "Report index and length of the matches"
+complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "replace"
+# All replace options are also valid for match
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match replace" -s a -l all -d "Report all matches per line/string"
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match replace" -s i -l ignore-case
+complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match replace" -s r -l regex -d "Use regex instead of globs"