mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 17:31:14 -03:00
@@ -10,7 +10,6 @@ function alias --description 'Creates a function wrapping a command'
|
||||
|
||||
set -l name
|
||||
set -l body
|
||||
set -l prefix
|
||||
|
||||
if not set -q argv[1]
|
||||
# Print the known aliases.
|
||||
@@ -51,9 +50,9 @@ function alias --description 'Creates a function wrapping a command'
|
||||
# $body starts with the same command as $name.
|
||||
if test $first_word = $name
|
||||
if contains $name (builtin --names)
|
||||
set prefix builtin
|
||||
set body "builtin $body"
|
||||
else
|
||||
set prefix command
|
||||
set body "command $body"
|
||||
end
|
||||
end
|
||||
set -l cmd_string (string escape -- "alias $argv")
|
||||
@@ -67,8 +66,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 # The function definition in split in two lines to ensure that a '#' can be put in the body.
|
||||
# The function definition in split in two lines to ensure that a '#' can be put in the body.
|
||||
echo "function $name $wraps --description $cmd_string"\n"$body \$argv"\n"end" | source
|
||||
if set -q _flag_save
|
||||
funcsave $name
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user