mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 20:25:12 +00:00
abbr/web_config: support space-delimited abbreviations
Support for space-delimited abbreviations was added to the expansion parser in fbade198; this commit extends that support to the user-facing tools, and documents the space-separated behaviour. Equals-delimited abbreviations are expected to be removed before the next release. Work on #731.
This commit is contained in:
parent
a6a41d159c
commit
a7bab7b18b
3 changed files with 4 additions and 4 deletions
|
@ -18,7 +18,7 @@ Abbreviations are stored, by default, in a universal variable.
|
||||||
|
|
||||||
The following parameters are available:
|
The following parameters are available:
|
||||||
|
|
||||||
- `-a 'WORD=PHRASE'` or `--add 'WORD=PHRASE'` Adds a new abbreviation, where WORD will be expanded to PHRASE. Only a single argument is supported - protect the contents with quotes or escapes.
|
- `-a WORD PHRASE` or `--add WORD PHRASE` Adds a new abbreviation, where WORD will be expanded to PHRASE.
|
||||||
|
|
||||||
- `-s` or `--show` Show all abbreviated words and their expanded phrases in a manner suitable for export and import.
|
- `-s` or `--show` Show all abbreviated words and their expanded phrases in a manner suitable for export and import.
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ The following parameters are available:
|
||||||
\subsection abbr-example Examples
|
\subsection abbr-example Examples
|
||||||
|
|
||||||
\fish
|
\fish
|
||||||
abbr -a 'gco=git checkout'
|
abbr -a gco git checkout
|
||||||
\endfish
|
\endfish
|
||||||
Add a new abbreviation where `gco` will be replaced with `git checkout`.
|
Add a new abbreviation where `gco` will be replaced with `git checkout`.
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ function __fish_abbr_parse_entry -S -a __input __key __value
|
||||||
end
|
end
|
||||||
# use read -z to avoid splitting on newlines
|
# use read -z to avoid splitting on newlines
|
||||||
# I think we can safely assume there will be no NULs in the input
|
# I think we can safely assume there will be no NULs in the input
|
||||||
set -l IFS =
|
set -l IFS '= '
|
||||||
printf "%s" $__input | read -z $__key $__value
|
printf "%s" $__input | read -z $__key $__value
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -691,7 +691,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
lines = (x for x in out.rstrip().split('\n'))
|
lines = (x for x in out.rstrip().split('\n'))
|
||||||
# Turn the output into something we can use
|
# Turn the output into something we can use
|
||||||
abbrout = (line[len('abbr -a '):].strip('\'') for line in lines)
|
abbrout = (line[len('abbr -a '):].strip('\'') for line in lines)
|
||||||
abbrs = [x.split('=') for x in abbrout]
|
abbrs = [re.split('[ =]', x, maxsplit=1) for x in abbrout]
|
||||||
|
|
||||||
if abbrs[0][0]:
|
if abbrs[0][0]:
|
||||||
result = [{'word': x, 'phrase': y} for x, y in abbrs]
|
result = [{'word': x, 'phrase': y} for x, y in abbrs]
|
||||||
|
|
Loading…
Reference in a new issue