我使用的是 Windows PowerShell,它是使用 doskey 宏进行配置的。
我有一个名为Macros.doskey
.
105=code E:\static5\105
135=code E:\static5\135
static5=code E:\static5
如何获取别名对应的命令?
例如,当我输入105
在 PowerShell 中它将执行命令code E:\static5\105
现在我想知道如何从别名中获取命令。
总结一下不使用的原因doskey
在 PowerShell 中:
因此,我建议你abandon doskey
支持 PowerShell功能,并将它们添加到您的$PROFILE
file以便它们在每个会话中都可用:
function c { pushd E:/static5; code $(if ($Args) { $Args } else { '.' }); popd }
你原来的doskey
然后宏映射到该函数,如下所示:
-
105
-> c 105
-
135
-> c 135
-
static5
-> c
请注意,这不仅允许您传递任意文件名(位于E:/static5/
) 发挥作用c
,但即使multiple那些;例如。,c 105 135
会打开both供编辑的文件。
检查函数的定义c
稍后,您只需调用$function:c
或者,更详细地说,(Get-Command c).Definition
.
[1] As PetSerAl notes: "doskey
performs translations on the console input buffer. [...]. It does not work if the console is not in line input mode, thus it is not compatible with PSReadline
, although Read-Host
will be affected.
https://i.stack.imgur.com/HpYzq.png"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)