Improve PowerShell on Linux

This commit is contained in:
Anthony Rose 2022-03-02 11:56:41 +00:00
parent 2597888258
commit 9d11d4a876

View file

@ -4,12 +4,17 @@
# C:\Users\USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
function Prompt {
if ($IsWindows) {
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "# "
} else {
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "> "
}
}
elseif ($IsLinux) {
"`e[1m" + $(id -un) + "@" + $(hostname -s) + "> `e[0m"
}
}
Set-Alias -Name json -Value ConvertTo-Json
@ -29,3 +34,23 @@ Set-PSReadLineKeyHandler -Chord Ctrl+LeftArrow -Function BackwardWord
Set-PSReadLineKeyHandler -Chord Ctrl+RightArrow -Function ForwardWord
Set-PSReadLineKeyHandler -Chord Ctrl+Backspace -Function BackwardKillWord
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;
}