Add PowerShell profile
This commit is contained in:
parent
8e5a371fee
commit
a4cfd46422
3 changed files with 39 additions and 0 deletions
31
roles/home-cli/files/Microsoft.PowerShell_profile.ps1
Normal file
31
roles/home-cli/files/Microsoft.PowerShell_profile.ps1
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Put this in the location of $PROFILE. For PowerShell 5+ this is either
|
||||
# C:\Users\USERNAME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
|
||||
# or
|
||||
# C:\Users\USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
|
||||
|
||||
function Prompt {
|
||||
$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() + "> "
|
||||
}
|
||||
}
|
||||
|
||||
Set-Alias -Name json -Value ConvertTo-Json
|
||||
Set-PSReadlineOption -BellStyle None
|
||||
Set-PSReadlineOption -EditMode Emacs
|
||||
Set-PSReadlineKeyHandler -Key Tab -Function Complete
|
||||
Set-PSReadLineKeyHandler -Key UpArrow -ScriptBlock {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchBackward()
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
|
||||
}
|
||||
Set-PSReadLineKeyHandler -Key DownArrow -ScriptBlock {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchForward()
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
|
||||
}
|
||||
Set-PSReadLineKeyHandler -Chord Shift+Spacebar -Function SelfInsert
|
||||
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
|
|
@ -47,3 +47,7 @@
|
|||
ansible.builtin.file:
|
||||
path: "{{ ansible_env.HOME }}/.config/mc"
|
||||
state: directory
|
||||
- name: Create ~/.config/powershell directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_env.HOME }}/.config/powershell"
|
||||
state: directory
|
||||
|
|
|
@ -66,3 +66,7 @@
|
|||
ansible.builtin.copy:
|
||||
src: mc.panels.ini
|
||||
dest: "{{ ansible_env.HOME }}/.config/mc/panels.ini"
|
||||
- name: Copy Microsoft.PowerShell_profile.ps1
|
||||
ansible.builtin.copy:
|
||||
src: Microsoft.PowerShell_profile.ps1
|
||||
dest: "{{ ansible_env.HOME }}/.config/powershell/Microsoft.PowerShell_profile.ps1"
|
||||
|
|
Loading…
Reference in a new issue