如何在鱼中显示功能的内容?

Fre*_*ind 18 fish

fishshell中,我可以非常轻松地创建和保存函数,例如:

function aaa
   echo hello
end

funcsave aaa
Run Code Online (Sandbox Code Playgroud)

但是如何aaa从命令行轻松查看函数体?有什么办法除了:

echo ~/.config/fish/functions/aaa.fish
Run Code Online (Sandbox Code Playgroud)

sda*_*yal 24

functions aaa在命令行上调用

username@MacBook-Pro ~> functions aaa
function aaa
    echo hello
end
username@MacBook-Pro ~>
Run Code Online (Sandbox Code Playgroud)

函数命令的更多用法

functions -n
# Displays a list of currently-defined functions

functions -c foo bar
# Copies the 'foo' function to a new function called 'bar'

functions -e bar
# Erases the function `bar`
Run Code Online (Sandbox Code Playgroud)


gle*_*man 16

此外,type aaa将向您展示函数定义,并带有一些前言:

$ type aaa
aaa is a function with definition
function aaa
    echo hello
end
Run Code Online (Sandbox Code Playgroud)

  • 这甚至比`function aaa`更好,因为输出是语法突出显示的! (4认同)