mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
docs/commandline: Add more on the -oc/-ct thing
This was the remaining immediately actionable part of #7375. It's not definitely the last word, but a change here would require a bigger plan. Fixes #7375
This commit is contained in:
parent
180692fb29
commit
0e81d25b36
@ -74,6 +74,10 @@ The following options change the way ``commandline`` prints the current commandl
|
||||
|
||||
**-c** or **--cut-at-cursor**
|
||||
Only print selection up until the current cursor position.
|
||||
If combined with ``--tokenize``, this will print up until the last completed token - excluding the token the cursor is in.
|
||||
This is typically what you would want for instance in completions.
|
||||
To get both, use both ``commandline --cut-at-cursor --tokenize; commandline --cut-at-cursor --current-token``,
|
||||
or ``commandline -co; commandline -ct`` for short.
|
||||
|
||||
**-o** or **--tokenize**
|
||||
Tokenize the selection and print one string-type token per line.
|
||||
@ -120,8 +124,22 @@ The ``echo $flounder >&`` is the first process, ``less`` the second and ``and ec
|
||||
|
||||
**$flounder** is the current token.
|
||||
|
||||
More examples:
|
||||
The most common use for something like completions is
|
||||
|
||||
::
|
||||
|
||||
set -l tokens (commandline -opc)
|
||||
|
||||
which gives the current *process* (what is being completed), tokenized into separate entries, up to but excluding the currently being completed token
|
||||
|
||||
If you are then also interested in the in-progress token, add
|
||||
|
||||
::
|
||||
set -l current (commandline -ct)
|
||||
|
||||
Note that this makes it easy to render fish's infix matching moot - if possible it's best if the completions just print all possibilities and leave the matching to the current token up to fish's logic.
|
||||
|
||||
More examples:
|
||||
|
||||
::
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user