0x01 环境变量
# list
PS> ls env:
# set
PS> $env:_JAVA_LAUNCHER_DEBUG=1
# unset
PS> del env:_JAVA_LAUNCHER_DEBUG
0x02 Profile
~ $ $profile
C:\Users\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
~ $ type $profile
# Truncate homedir to ~
function limit-HomeDirectory($Path) {
$Path.Replace("$home", "~")
}
# Must be called 'prompt' to be used by pwsh
function prompt {
$realLASTEXITCODE = $LASTEXITCODE
Write-Host $(limit-HomeDirectory("$pwd")) -ForegroundColor Yellow -NoNewline
Write-Host " $" -NoNewline
$global:LASTEXITCODE = $realLASTEXITCODE
Return " "
}
0x04 Parsing^
续行符 Line continuation,`
关于参数^,有个要点,-
之后为参数名,参数名不能有 .
,会被断开传递,需要包引号。
command-parameter: dash first-parameter-char parameter-chars colon~opt~ parameter-chars: parameter-char parameter-chars parameter-char parameter-char: Any Unicode character except { } ( ) ; , | & . [ colon whitespace new-line-character
例:
$ .\TestExe.exe -echoargs -DA.D
Arg 0 is <-DA>
Arg 1 is <.D>
更多
参考
- microsoft.powershell.core > about_profiles
- microsoft.powershell.core > about_environment_variables
- microsoft.powershell.core > about_prompts
- lang-spec > chapter-15 Grammar