Firefox 的别名语法 'cfx run -profile <dir>'
Alias syntax for Firefox 'cfx run -profile <dir>'
我想知道如何在 PowerShell 中为开发 Firefox 扩展时使用的 cmd 设置别名:
cfx run -p C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ripltbxm.cfxp
我已将以下内容添加到 Microsoft.PowerShell_profile。ps1:
Set-Alias cfxp cfx run -p "C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ripltbxm.cfxp"
但是启动PowerShell时,显示错误:
Set-Alias : A positional parameter cannot be found that accepts argument 'run'.
At D:\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:2 char:1
+ Set-Alias cfxp cfx run -p "C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profil ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Alias], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetAliasCommand
也尝试过:
Set-Alias cfxp "cfx run -p C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ripltbxm.cfxp"
另一个错误:
cfxp : The term 'cfx run -p C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ripltbxm.cfxp' is not recognized
as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ cfxp
+ ~~~~
+ CategoryInfo : ObjectNotFound: (cfx run -p C:\U...s\ripltbxm.cfxp:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
在 PowerShell 中,只能为命令或 cmdlet 定义别名,而不能为带有参数的整个命令行定义:
NAME
New-Alias
SYNOPSIS
Creates a new alias.
[...]
DESCRIPTION
The New-Alias cmdlet creates a new alias in the current Windows
PowerShell session. Aliases created by using New-Alias are not
saved after you exit the session or close Windows PowerShell. You
can use the Export-Alias cmdlet to save your alias information to
a file. You can later use Import-Alias to retrieve that saved
alias information.
PARAMETERS
[...]
-Value <String>
Specifies the name of the cmdlet or command element that is
being aliased.
如果您想要 shorthand 用于 运行 带有参数的特定命令,您将需要一个自定义函数。
function cfxp {
& cfx run -p "$env:APPDATA\Mozilla\Firefox\Profiles\ripltbxm.cfxp"
}
我想知道如何在 PowerShell 中为开发 Firefox 扩展时使用的 cmd 设置别名:
cfx run -p C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ripltbxm.cfxp
我已将以下内容添加到 Microsoft.PowerShell_profile。ps1:
Set-Alias cfxp cfx run -p "C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ripltbxm.cfxp"
但是启动PowerShell时,显示错误:
Set-Alias : A positional parameter cannot be found that accepts argument 'run'.
At D:\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:2 char:1
+ Set-Alias cfxp cfx run -p "C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profil ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Alias], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetAliasCommand
也尝试过:
Set-Alias cfxp "cfx run -p C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ripltbxm.cfxp"
另一个错误:
cfxp : The term 'cfx run -p C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ripltbxm.cfxp' is not recognized
as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ cfxp
+ ~~~~
+ CategoryInfo : ObjectNotFound: (cfx run -p C:\U...s\ripltbxm.cfxp:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
在 PowerShell 中,只能为命令或 cmdlet 定义别名,而不能为带有参数的整个命令行定义:
NAME
New-Alias
SYNOPSIS
Creates a new alias.
[...]
DESCRIPTION
The New-Alias cmdlet creates a new alias in the current Windows
PowerShell session. Aliases created by using New-Alias are not
saved after you exit the session or close Windows PowerShell. You
can use the Export-Alias cmdlet to save your alias information to
a file. You can later use Import-Alias to retrieve that saved
alias information.
PARAMETERS
[...]
-Value <String>
Specifies the name of the cmdlet or command element that is
being aliased.
如果您想要 shorthand 用于 运行 带有参数的特定命令,您将需要一个自定义函数。
function cfxp {
& cfx run -p "$env:APPDATA\Mozilla\Firefox\Profiles\ripltbxm.cfxp"
}