mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 04:41: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
|
||||
|
||||
@@ -26,11 +26,11 @@ alias l. "ls -d .*"
|
||||
# No output
|
||||
|
||||
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: end
|
||||
functions d | sed s,^,^,
|
||||
# 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: ^end
|
||||
|
||||
# Use "command" to prevent recursion, and don't add --wraps to avoid accidental recursion in completion.
|
||||
alias e 'e --option=value'
|
||||
|
||||
Reference in New Issue
Block a user