mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 04:13:08 +00:00
Add alias -s/--save
, which saves the alias.
Also updates the `alias` documentation to mention the `-h`/`--help` option, which was previously undocumented.
This commit is contained in:
parent
6c0f31d622
commit
25169a44ed
3 changed files with 13 additions and 3 deletions
|
@ -54,6 +54,7 @@ This section is for changes merged to the `major` branch that are not also merge
|
|||
- `functions --handlers` can be used to show event handlers (#4694).
|
||||
- Variables set in `if` and `while` conditions are available outside the block (#4820).
|
||||
- The universal variables file no longer contains the MAC address. It is now at the fixed location `.config/fish/fish_universal_variables` (#1912).
|
||||
- `alias` now has a `-s` and `--save` option to save the function generated by the alias using `funcsave` (#4878).
|
||||
|
||||
## Other significant changes
|
||||
- Command substitution output is now limited to 10 MB by default (#3822).
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
\subsection alias-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
alias
|
||||
alias NAME DEFINITION
|
||||
alias NAME=DEFINITION
|
||||
alias [OPTIONS] NAME DEFINITION
|
||||
alias [OPTIONS] NAME=DEFINITION
|
||||
\endfish
|
||||
|
||||
\subsection alias-description Description
|
||||
|
@ -18,6 +18,12 @@ alias NAME=DEFINITION
|
|||
|
||||
You cannot create an alias to a function with the same name. Note that spaces need to be escaped in the call to `alias` just like at the command line, _even inside quoted parts_.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-h` or `--help` displays help about using this command.
|
||||
|
||||
- `-s` or `--save` Automatically save the function created by the alias into your fish configuration directory using <a href='#funcsave'>funcsave</a>.
|
||||
|
||||
\subsection alias-example Example
|
||||
|
||||
The following code will create `rmi`, which runs `rm` with additional arguments on every invocation.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function alias --description 'Creates a function wrapping a command'
|
||||
set -l options 'h/help'
|
||||
set -l options 'h/help' 's/save'
|
||||
argparse -n alias --max-args=2 $options -- $argv
|
||||
or return
|
||||
|
||||
|
@ -69,5 +69,8 @@ function alias --description 'Creates a function wrapping a command'
|
|||
set -l cmd_string (string escape -- "alias $argv")
|
||||
set wrapped_cmd (string join ' ' -- $first_word $body | string escape)
|
||||
echo "function $name --wraps $wrapped_cmd --description $cmd_string; $prefix $first_word $body \$argv; end" | source
|
||||
if set -q _flag_save
|
||||
funcsave $name
|
||||
end
|
||||
#echo "function $name --wraps $wrapped_cmd --description $cmd_string; $prefix $first_word $body \$argv; end"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue