Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Fish 鱼壳中带空格的别名_Fish - Fatal编程技术网

Fish 鱼壳中带空格的别名

Fish 鱼壳中带空格的别名,fish,Fish,我想在fish中添加一个带空格的别名,如下所示: alias hello there 'print hello there' 这有可能吗?(我知道这个例子是无效的,我只是举个例子) 提前感谢。这在fish的别名中是不可能的 然而,最终要做的是定义一个函数,所以您可以这样做 function "hello there" echo hello there end 执行时使用“hello there”或hello\there@faho解释了如何执行此操作,但我很好奇您为什么要执行此操作?使

我想在fish中添加一个带空格的别名,如下所示:

alias hello there 'print hello there'
这有可能吗?(我知道这个例子是无效的,我只是举个例子)


提前感谢。

这在fish的
别名中是不可能的

然而,最终要做的是定义一个函数,所以您可以这样做

function "hello there"
    echo hello there
end

执行时使用
“hello there”
hello\there

@faho解释了如何执行此操作,但我很好奇您为什么要执行此操作?使用它的唯一方法是引用命令名,使用连字符或下划线而不是空格似乎更简单。如果不需要引用就支持这一点,则它对于子命令很有用,例如展开
git diff
->
git diff--word diff
。键入
git diff
后,我不想回溯添加连字符。不清楚“展开”是什么意思。在fish中,只有使用
abbr
命令创建的缩写在命令行上展开。由
alias
命令创建的函数不会展开。它们实际上是命令。正如@faho在他们的回答中指出的那样,与任何其他包含空格的命令一样,您必须引用该命令才能使用它。通常的解决方法是创建一个扩展为更长形式的缩写;e、 例如,
缩写为“你好”
。现在,您只需键入
ht
,后跟一个空格,它将被扩展为“hello there”。