我想将 --group-directories-first
添加到 ls
命令。如果在 ~/.config/fish/config.fish
中,我可以定义一个像这样的别名:
alias ls "ls --group-directories-first"
但它覆盖了 Fish shell 的 ls
函数定义:
function ls --description 'List contents of directory'
set -l param --color=auto
if isatty 1
set param $param --indicator-style=classify
end
command ls $param $argv
end
我可以重新定义 ls
函数以添加所需的参数:
function ls --description 'List contents of directory'
set -l param --color=auto --group-directories-first
if isatty 1
set param $param --indicator-style=classify
end
command ls $param $argv
end
但我不喜欢这个解决方案:我想要的是重新定义 ls
以便使用参数调用之前的 ls
函数。有办法实现吗?
最佳答案
您可以重命名复制fish的ls函数:
functions --copy ls __fish_ls
然后在您的函数中使用它:
alias ls '__fish_ls --group-directories-first'
关于shell - fish shell : append argument to an existing function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48251960/