"`n" #Skip line
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward #Work history as in bash
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
if ($host.Name -eq 'ConsoleHost') {
$host.UI.RawUI.WindowTitle = $(whoami) # Write curent user name in Powershell window tilte
function prompt {
$MyESC = "$([char]27)"
$MyColorRed = $MyESC + "[91m"
$MyColorWhite = $MyESC + "[97m"
$MyColorMagenta = $MyESC + "[95m"
$MyColorGreen = $MyESC + "[92m"
$MyRightArrow = [char]0x2192
$MyColorArrow = $MyESC + "[38;5;214m" #ORANGE
#$MyColorArrow = $MyESC + "[38;5;214m" #BLUE
$MyLocation = (Get-Location).Path
if ($MyLocation.length -gt 30) {
$MyLocation = $MyLocation.Substring(0,9)+"..."+$MyLocation.Substring(($MyLocation.length-20),20)
}
[Security.Principal.WindowsPrincipal]$user = [Security.Principal.WindowsIdentity]::GetCurrent();
if($user.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)){
"$($MyColorRed)PS$MyColorMagenta[$MyColorGreen" + $MyLocation+"$MyColorMagenta]$MyColorArrow$MyRightArrow" +
$(if ($NestedPromptLevel -ge 1) { $MyRightArrow+'>' }) + "$MyColorWhite"
}
else{
"$($MyColorWhite)PS$MyColorMagenta[$MyColorGreen" + $MyLocation+"$MyColorMagenta]$MyColorArrow$MyRightArrow" +
$(if ($NestedPromptLevel -ge 1) { $MyRightArrow+'>' }) + "$MyColorWhite"
}
}
}
# Aliases
function n { notepad $args } #
set-alias -name c -value clear
function pf { notepad $PROFILE.CurrentUserAllHosts } #Edit current profile
## Network
function p { ping -t $args }
function ptr { nslookup -q=ptr $args }
function mx { nslookup -q=mx $args }
function txt { nslookup -q =txt $args }
function ip { ipconfig /all $args }