Improve PowerShell on Linux
This commit is contained in:
parent
2597888258
commit
9d11d4a876
1 changed files with 34 additions and 9 deletions
|
@ -4,11 +4,16 @@
|
||||||
# C:\Users\USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
|
# C:\Users\USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
|
||||||
|
|
||||||
function Prompt {
|
function Prompt {
|
||||||
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
if ($IsWindows) {
|
||||||
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
||||||
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "# "
|
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||||
} else {
|
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "# "
|
||||||
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "> "
|
} else {
|
||||||
|
$env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "> "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($IsLinux) {
|
||||||
|
"`e[1m" + $(id -un) + "@" + $(hostname -s) + "> `e[0m"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,15 +22,35 @@ Set-PSReadlineOption -BellStyle None
|
||||||
Set-PSReadlineOption -EditMode Emacs
|
Set-PSReadlineOption -EditMode Emacs
|
||||||
Set-PSReadlineKeyHandler -Key Tab -Function Complete
|
Set-PSReadlineKeyHandler -Key Tab -Function Complete
|
||||||
Set-PSReadLineKeyHandler -Key UpArrow -ScriptBlock {
|
Set-PSReadLineKeyHandler -Key UpArrow -ScriptBlock {
|
||||||
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchBackward()
|
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchBackward()
|
||||||
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
|
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
|
||||||
}
|
}
|
||||||
Set-PSReadLineKeyHandler -Key DownArrow -ScriptBlock {
|
Set-PSReadLineKeyHandler -Key DownArrow -ScriptBlock {
|
||||||
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchForward()
|
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchForward()
|
||||||
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
|
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
|
||||||
}
|
}
|
||||||
Set-PSReadLineKeyHandler -Chord Shift+Spacebar -Function SelfInsert
|
Set-PSReadLineKeyHandler -Chord Shift+Spacebar -Function SelfInsert
|
||||||
Set-PSReadLineKeyHandler -Chord Ctrl+LeftArrow -Function BackwardWord
|
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