Improve PowerShell on Linux
This commit is contained in:
parent
2597888258
commit
9d11d4a876
1 changed files with 34 additions and 9 deletions
|
@ -4,6 +4,7 @@
|
||||||
# C:\Users\USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
|
# C:\Users\USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
|
||||||
|
|
||||||
function Prompt {
|
function Prompt {
|
||||||
|
if ($IsWindows) {
|
||||||
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
||||||
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||||
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "# "
|
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "# "
|
||||||
|
@ -11,6 +12,10 @@ function Prompt {
|
||||||
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "> "
|
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "> "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elseif ($IsLinux) {
|
||||||
|
"`e[1m" + $(id -un) + "@" + $(hostname -s) + "> `e[0m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set-Alias -Name json -Value ConvertTo-Json
|
Set-Alias -Name json -Value ConvertTo-Json
|
||||||
Set-PSReadlineOption -BellStyle None
|
Set-PSReadlineOption -BellStyle None
|
||||||
|
@ -29,3 +34,23 @@ Set-PSReadLineKeyHandler -Chord Ctrl+LeftArrow -Function BackwardWord
|
||||||
Set-PSReadLineKeyHandler -Chord Ctrl+RightArrow -Function ForwardWord
|
Set-PSReadLineKeyHandler -Chord Ctrl+RightArrow -Function ForwardWord
|
||||||
Set-PSReadLineKeyHandler -Chord Ctrl+Backspace -Function BackwardKillWord
|
Set-PSReadLineKeyHandler -Chord Ctrl+Backspace -Function BackwardKillWord
|
||||||
Set-PSReadLineKeyHandler -Chord Ctrl+Delete -Function KillWord
|
Set-PSReadLineKeyHandler -Chord Ctrl+Delete -Function KillWord
|
||||||
|
|
||||||
|
$AnsiReset = "`e[0m"
|
||||||
|
Set-PSReadLineOption -Colors @{
|
||||||
|
Default = $AnsiReset;
|
||||||
|
Command = $AnsiReset;
|
||||||
|
Comment = $AnsiReset;
|
||||||
|
ContinuationPrompt = $AnsiReset;
|
||||||
|
Emphasis = $AnsiReset;
|
||||||
|
Error = $AnsiReset;
|
||||||
|
InlinePrediction = $AnsiReset;
|
||||||
|
Keyword = $AnsiReset;
|
||||||
|
Member = $AnsiReset;
|
||||||
|
Number = $AnsiReset;
|
||||||
|
Operator = $AnsiReset;
|
||||||
|
Parameter = $AnsiReset;
|
||||||
|
Selection = $AnsiReset;
|
||||||
|
String = $AnsiReset;
|
||||||
|
Type = $AnsiReset;
|
||||||
|
Variable = $AnsiReset;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue