Last active
August 17, 2020 07:40
-
-
Save vchirikov/b9b2502850304c66ff8afe0af3f5eca5 to your computer and use it in GitHub Desktop.
Powershell profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module PSReadLine | |
# zsh-like menu complete, for bash-like use `Complete` | |
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete | |
Set-PSReadlineOption -ShowToolTips | |
Set-PSReadlineOption -BellStyle None | |
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward | |
Import-Module posh-git | |
# FZF bindings for powershell, should be imported after PSReadLine - https://github.com/kelleyma49/PSFzf | |
# Install-Module -Name PSFzf | |
Remove-PSReadlineKeyHandler 'Ctrl+r' | |
Remove-PSReadlineKeyHandler 'Ctrl+t' | |
Import-Module PSFzf | |
# dotnet tool install --global dotnet-suggest --version 1.1.116801 | |
# dotnet suggest shell start | |
$availableToComplete = (dotnet-suggest list) | Out-String | |
$availableToCompleteArray = $availableToComplete.Split([Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries) | |
Register-ArgumentCompleter -Native -CommandName $availableToCompleteArray -ScriptBlock { | |
param($commandName, $wordToComplete, $cursorPosition) | |
$fullpath = (Get-Command $wordToComplete.CommandElements[0]).Source | |
$arguments = $wordToComplete.Extent.ToString().Replace('"', '\"') | |
dotnet-suggest get -e $fullpath --position $cursorPosition -- "$arguments" | ForEach-Object { | |
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | |
} | |
} | |
$env:DOTNET_SUGGEST_SCRIPT_VERSION = "1.0.0" | |
# dotnet suggest script end | |
# PowerShell parameter completion shim for the dotnet CLI | |
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock { | |
param($commandName, $wordToComplete, $cursorPosition) | |
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object { | |
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | |
} | |
} | |
function killall { | |
param( | |
[ArgumentCompleter( | |
{ | |
param($cmd, $param, $values) | |
get-process | | |
Where-Object { $_.Name.StartsWith($values, [StringComparison]::OrdinalIgnoreCase) } | | |
Select-Object name -Unique | | |
ForEach-Object { $_.Name } | | |
Sort-Object | |
} | |
)] | |
$ProcessName) | |
stop-process -Name $ProcessName | |
} | |
# run visual studio | |
function vs([string] $path) { | |
[string] $vsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Preview\Common7\IDE\devenv.exe" | |
if ([string]::IsNullOrWhiteSpace($path)) { | |
$path = Get-ChildItem -Path $([System.IO.Path]::GetFullPath($PWD)) -Filter "*.sln" | Select-Object -First 1; | |
} | |
else { | |
if (!$path.Contains(':')) { | |
$path = $([System.IO.Path]::Combine($PWD, $path)) | |
} | |
} | |
Start-Process -FilePath $vsPath -ArgumentList $([System.IO.Path]::GetFullPath($path)) | |
} | |
# diff catalog | |
function diff_dir([string] $path1, [string] $path2) { | |
$files1 = Get-ChildItem -Recurse -File -path $path1 ; | |
$files2 = Get-ChildItem -Recurse -File -path $path2 ; | |
Compare-Object -ReferenceObject $files1 -DifferenceObject $files2 ; | |
} | |
# run build system command | |
function bs ([string] $buildArgs) { | |
[string] $path = "build"; | |
if ([System.IO.Directory]::Exists($([System.IO.Path]::Combine($PWD, "_build")))) { | |
$path = "_build"; | |
} | |
dotnet run --project $path -- $buildArgs | |
} | |
Import-Module DockerCompletion | |
Set-PsFzfOption -TabExpansion -GitKeyBindings -EnableAliasFuzzyEdit -EnableAliasFuzzyHistory -EnableAliasFuzzyKillProcess -EnableAliasFuzzySetLocation -EnableAliasFuzzySetEverything | |
Set-Alias fzf Invoke-Fzf | |
Set-Alias time Measure-Command | |
# Colorize directory listing https://github.com/joonro/Get-ChildItemColor | |
# but this approach is too slow, additional 9ms-90ms with simple ls | |
#Clear-Host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"alwaysShowTabs": true, | |
"confirmCloseAllTabs": true, | |
"showTabsInTitlebar": true, | |
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", | |
"initialCols": 170, | |
"initialRows": 60, | |
"requestedTheme": "dark", | |
"theme": "dark", | |
"showTerminalTitleInTitlebar": false, | |
"copyFormatting": false, | |
"wordDelimiters": " ./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}~?\u2502", | |
"profiles": { | |
"defaults": { | |
// Put settings here that you want to apply to all profiles | |
"acrylicOpacity": 0.80, | |
"useAcrylic": true, | |
"colorScheme": "Dracula", | |
"cursorColor": "#ffc600", | |
"cursorShape": "bar", | |
//"fontFace": "Consolas", | |
//"fontFace": "MesloLGS NF", | |
"fontFace": "Consolas NF", | |
"fontSize": 9, | |
"startingDirectory": ".", | |
"backgroundImage": "C:\\Tools\\colortool\\wallpaper_wt.jpeg", | |
"backgroundImageOpacity": 0.45 | |
}, | |
"list": [ | |
{ | |
"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}", | |
"hidden": false, | |
"name": "wsl", | |
"source": "Windows.Terminal.Wsl" | |
}, | |
{ | |
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", | |
"hidden": false, | |
"name": "pwsh", | |
"source": "Windows.Terminal.PowershellCore", | |
"commandline": "pwsh -NoLogo" | |
}, | |
{ | |
// Make changes here to the powershell.exe profile | |
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", | |
"name": "Windows PowerShell", | |
"commandline": "powershell.exe", | |
"hidden": true | |
}, | |
{ | |
// Make changes here to the cmd.exe profile | |
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", | |
"name": "cmd", | |
"commandline": "cmd.exe", | |
"hidden": false, | |
"fontFace": "Consolas", | |
"fontSize": 10 | |
}, | |
{ | |
"commandline": "C:/msys64/msys2_shell.cmd -defterm -no-start -mingw64", | |
"guid": "{1597a4d0-b666-4b1f-a8d3-79af62638679}", | |
"icon": "C:\\msys64\\msys2.ico", | |
"name": "msys2" | |
}, | |
{ | |
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", | |
"hidden": true, | |
"name": "Azure Cloud Shell", | |
"source": "Windows.Terminal.Azure" | |
} | |
] | |
}, | |
// Add custom color schemes to this array | |
"schemes": [ | |
// ubuntu dark | |
{ | |
"name": "Ubuntu_Dark", | |
"background": "#2E3436", | |
"foreground": "#B5BBAE", | |
"black": "#2E3436", | |
"blue": "#3465A4", | |
"cyan": "#06989A", | |
"green": "#4E9A06", | |
"purple": "#75507B", | |
"red": "#AE5E5E", | |
"white": "#B5BBAE", | |
"yellow": "#C4A000", | |
"brightBlack": "#696B67", | |
"brightBlue": "#729FCF", | |
"brightCyan": "#2EC3C3", | |
"brightGreen": "#79C32E", | |
"brightPurple": "#AD7FA8", | |
"brightRed": "#F49797", | |
"brightWhite": "#FBFBFB", | |
"brightYellow": "#FCE94F" | |
}, | |
// One Half Dark modified | |
{ | |
"background": "#0C0C0C", | |
"black": "#0C0C0C", | |
"blue": "#1170b5", | |
"brightBlack": "#5A6374", | |
"brightBlue": "#61AFEF", | |
"brightCyan": "#56B6C2", | |
"brightGreen": "#98C379", | |
"brightPurple": "#C678DD", | |
"brightRed": "#E06C75", | |
"brightWhite": "#DCDFE4", | |
"brightYellow": "#E5C07B", | |
"cyan": "#56B6C2", | |
"foreground": "#DCDFE4", | |
"green": "#98C379", | |
"name": "OneHalfDark", | |
"purple": "#C678DD", | |
"red": "#E06C75", | |
"white": "#DCDFE4", | |
"yellow": "#E5C07B" | |
}, | |
// Dracula | |
{ | |
"background": "#282A36", | |
"black": "#21222C", | |
"blue": "#1170b5", | |
"brightBlack": "#6272A4", | |
"brightBlue": "#61AFEF", | |
"brightCyan": "#A4FFFF", | |
"brightGreen": "#69FF94", | |
"brightPurple": "#FF92DF", | |
"brightRed": "#FF6E6E", | |
"brightWhite": "#FFFFFF", | |
"brightYellow": "#FFFFA5", | |
"cyan": "#8BE9FD", | |
"foreground": "#F8F8F2", | |
"green": "#50FA7B", | |
"name": "Dracula", | |
"purple": "#FF79C6", | |
"red": "#FF5555", | |
"white": "#F8F8F2", | |
"yellow": "#F1FA8C" | |
} | |
], | |
// Add any keybinding overrides to this array. | |
// To unbind a default keybinding, set the command to "unbound" | |
"keybindings": [ | |
{ | |
"command": { | |
"action": "splitPane", | |
"split": "horizontal", | |
"splitMode": "duplicate" | |
}, | |
"keys": [ | |
"ctrl+shift+-" | |
] | |
}, | |
{ | |
"command": { | |
"action": "splitPane", | |
"split": "vertical", | |
"splitMode": "duplicate" | |
}, | |
"keys": [ | |
"ctrl+shift+|" | |
] | |
}, | |
{ | |
"command": { | |
"action": "splitPane", | |
"split": "auto", | |
"splitMode": "duplicate" | |
}, | |
"keys": [ | |
"ctrl+shift+d" | |
] | |
}, | |
{ | |
"command": { | |
"action": "moveFocus", | |
"direction": "up" | |
}, | |
"keys": [ | |
"ctrl+alt+up" | |
] | |
}, | |
{ | |
"command": { | |
"action": "moveFocus", | |
"direction": "down" | |
}, | |
"keys": [ | |
"ctrl+alt+down" | |
] | |
}, | |
{ | |
"command": { | |
"action": "moveFocus", | |
"direction": "left" | |
}, | |
"keys": [ | |
"ctrl+alt+left" | |
] | |
}, | |
{ | |
"command": { | |
"action": "moveFocus", | |
"direction": "right" | |
}, | |
"keys": [ | |
"ctrl+alt+right" | |
] | |
}, | |
{ | |
"command": { | |
"action": "resizePane", | |
"direction": "up" | |
}, | |
"keys": [ | |
"shift+alt+up" | |
] | |
}, | |
{ | |
"command": { | |
"action": "resizePane", | |
"direction": "down" | |
}, | |
"keys": [ | |
"shift+alt+down" | |
] | |
}, | |
{ | |
"command": { | |
"action": "resizePane", | |
"direction": "left" | |
}, | |
"keys": [ | |
"shift+alt+left" | |
] | |
}, | |
{ | |
"command": { | |
"action": "resizePane", | |
"direction": "right" | |
}, | |
"keys": [ | |
"shift+alt+right" | |
] | |
}, | |
{ | |
"command": "closePane", | |
"keys": [ | |
"ctrl+shift+w" | |
] | |
}, | |
{ | |
"command": "find", | |
"keys": [ | |
"ctrl+f" | |
] | |
}, | |
{ | |
"command": "duplicateTab", | |
"keys": [ | |
"alt+shift+d" | |
] | |
}, | |
{ | |
"command": { | |
"action": "copy", | |
"singleLine": true | |
}, | |
"keys": [ | |
"ctrl+c" | |
] | |
}, | |
{ | |
"command": "paste", | |
"keys": [ | |
"ctrl+v" | |
] | |
}, | |
{ | |
"command": "closeTab", | |
"keys": [ | |
"ctrl+w" | |
] | |
}, | |
{ | |
"command": "newTab", | |
"keys": [ | |
"ctrl+t" | |
] | |
}, | |
{ | |
"command": "prevTab", | |
"keys": [ | |
"ctrl+shift+tab" | |
] | |
}, | |
{ | |
"command": "scrollDown", | |
"keys": [ | |
"ctrl+shift+down" | |
] | |
}, | |
{ | |
"command": "scrollDownPage", | |
"keys": [ | |
"ctrl+shift+pgdn" | |
] | |
}, | |
{ | |
"command": "scrollUp", | |
"keys": [ | |
"ctrl+shift+up" | |
] | |
}, | |
{ | |
"command": "scrollUpPage", | |
"keys": [ | |
"ctrl+shift+pgup" | |
] | |
}, | |
{ | |
"command": { | |
"action": "switchToTab", | |
"index": 0 | |
}, | |
"keys": [ | |
"alt+1" | |
] | |
}, | |
{ | |
"command": { | |
"action": "switchToTab", | |
"index": 1 | |
}, | |
"keys": [ | |
"alt+2" | |
] | |
}, | |
{ | |
"command": { | |
"action": "switchToTab", | |
"index": 2 | |
}, | |
"keys": [ | |
"alt+3" | |
] | |
}, | |
{ | |
"command": { | |
"action": "switchToTab", | |
"index": 3 | |
}, | |
"keys": [ | |
"alt+4" | |
] | |
}, | |
{ | |
"command": { | |
"action": "switchToTab", | |
"index": 4 | |
}, | |
"keys": [ | |
"alt+5" | |
] | |
}, | |
{ | |
"command": { | |
"action": "switchToTab", | |
"index": 5 | |
}, | |
"keys": [ | |
"alt+6" | |
] | |
}, | |
{ | |
"command": { | |
"action": "switchToTab", | |
"index": 6 | |
}, | |
"keys": [ | |
"alt+7" | |
] | |
}, | |
{ | |
"command": { | |
"action": "switchToTab", | |
"index": 7 | |
}, | |
"keys": [ | |
"alt+8" | |
] | |
}, | |
{ | |
"command": { | |
"action": "switchToTab", | |
"index": 8 | |
}, | |
"keys": [ | |
"alt+9" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment