mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 10:06:49 +08:00
Add the possibility to ignore arguments in alliases (#9199)
* Replace ";" with "\n" in alias-generated functions This can let us add a "#" in our aliases to make them ignore additional arguments. * Update changelog about aliases that ignore arguments * Update test for alias.fish This is now compliant with the aliases that can ignore arguments.
This commit is contained in:
parent
ee6270301b
commit
d50e9ffff3
|
@ -97,6 +97,7 @@ Other improvements
|
|||
------------------
|
||||
- The css for fish's documentation no longer depends on sphinx' stock "classic" theme. This should improve compatibility with sphinx versions and ease upgrading (:issue:`9003`).
|
||||
- The web-based configuration tool now works on systems that have ipv6 disabled (:issue:`3857`).
|
||||
- Aliases can ignore arguments by ending them with ``#``.
|
||||
|
||||
|
||||
For distributors
|
||||
|
|
|
@ -67,7 +67,8 @@ function alias --description 'Creates a function wrapping a command'
|
|||
set wraps --wraps (string escape -- $body)
|
||||
end
|
||||
|
||||
echo "function $name $wraps --description $cmd_string; $prefix $body \$argv; end" | source
|
||||
echo "function $name $wraps --description $cmd_string; $prefix $body \$argv
|
||||
end" | source # The function definition in split in two lines to ensure that a '#' can be put in the body.
|
||||
if set -q _flag_save
|
||||
funcsave $name
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ alias d "'/mnt/c/Program Files (x86)/devenv.exe' /Edit"
|
|||
functions d
|
||||
# CHECK: # Defined via `source`
|
||||
# CHECK: function d --wraps=\'/mnt/c/Program\ Files\ \(x86\)/devenv.exe\'\ /Edit --description alias\ d\ \'/mnt/c/Program\ Files\ \(x86\)/devenv.exe\'\ /Edit
|
||||
# CHECK: '/mnt/c/Program Files (x86)/devenv.exe' /Edit $argv;
|
||||
# CHECK: '/mnt/c/Program Files (x86)/devenv.exe' /Edit $argv
|
||||
# CHECK: end
|
||||
|
||||
# Use "command" to prevent recusion, and don't add --wraps to avoid accidental recursion in completion.
|
||||
|
@ -37,7 +37,7 @@ alias e 'e --option=value'
|
|||
functions e
|
||||
# CHECK: # Defined via `source`
|
||||
# CHECK: function e --description 'alias e e --option=value'
|
||||
# CHECK: command e --option=value $argv;
|
||||
# CHECK: command e --option=value $argv
|
||||
# CHECK: end
|
||||
|
||||
# Don't add --wraps if it looks like a wrapper command to avoid accidental recursion in completion.
|
||||
|
@ -45,5 +45,5 @@ alias f 'wrapper around f'
|
|||
functions f
|
||||
# CHECK: # Defined via `source`
|
||||
# CHECK: function f --description 'alias f wrapper around f'
|
||||
# CHECK: wrapper around f $argv;
|
||||
# CHECK: wrapper around f $argv
|
||||
# CHECK: end
|
||||
|
|
Loading…
Reference in New Issue
Block a user