Skip to content

Instantly share code, notes, and snippets.

@kid1412621
Last active June 13, 2023 08:21
Show Gist options
  • Save kid1412621/e9bafc5362acbded0f6b726402c40d62 to your computer and use it in GitHub Desktop.
Save kid1412621/e9bafc5362acbded0f6b726402c40d62 to your computer and use it in GitHub Desktop.
Windows Setup
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
# Oh-My-Posh (`winget install oh-my-posh`)
$env:POSH_GIT_ENABLED = $true
oh-my-posh init pwsh --config $env:POSH_THEMES_PATH/star.omp.json | Invoke-Expression
Enable-PoshTooltips
# Alias
Set-Alias -N l -V Get-ChildItem
Set-Alias -N ll -V Get-ChildItemWithHidden
Set-Alias -N v -V vim
Set-Alias -N g -V git
Set-Alias -N tig -V "$env:ProgramFiles\Git\usr\bin\tig.exe"
Set-Alias -N d -V docker
Set-Alias -N nsv -V New-Service
Set-Alias -N rssv -V Restart-Service
Set-Alias -N fmo -V Find-Module
Set-Alias -N rdns -V Resolve-DnsName
Set-Alias -N gnc -V Get-NetTCPConnection
Set-Alias -N gvm -V Get-VM
Set-Alias -N cnvm -V Connnect-VM
Set-Alias -N open -V Invoke-Item
Set-Alias -N idea -V idea64
function Get-ChildItemWithHidden { Get-ChildItem -Hidden }
function Connect-VM { vmconnect localhost $args }
# Autocompletion
Set-PSReadLineOption -EditMode Emacs -HistorySearchCursorMovesToEnd -PredictionViewStyle ListView
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
# posh-git (`Install-Module Posh-Git -Scope CurrentUser`)
Import-Module Posh-Git
Import-Module DockerCompletion
Import-Module MavenAutoCompletion
Import-Module npm-completion
# K8S
kubectl completion powershell | Out-String | Invoke-Expression
# Github CLI
Invoke-Expression -Command $(gh completion -s powershell | Out-String)
# Winget
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
$Local:word = $wordToComplete.Replace('"', '""')
$Local:ast = $commandAst.ToString().Replace('"', '""')
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
# 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', $_)
}
}
# Azure CLI
Register-ArgumentCompleter -Native -CommandName az -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$completion_file = New-TemporaryFile
$env:ARGCOMPLETE_USE_TEMPFILES = 1
$env:_ARGCOMPLETE_STDOUT_FILENAME = $completion_file
$env:COMP_LINE = $wordToComplete
$env:COMP_POINT = $cursorPosition
$env:_ARGCOMPLETE = 1
$env:_ARGCOMPLETE_SUPPRESS_SPACE = 0
$env:_ARGCOMPLETE_IFS = "`n"
az 2>&1 | Out-Null
Get-Content $completion_file | Sort-Object | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_)
}
Remove-Item $completion_file, Env:\_ARGCOMPLETE_STDOUT_FILENAME, Env:\ARGCOMPLETE_USE_TEMPFILES, Env:\COMP_LINE, Env:\COMP_POINT, Env:\_ARGCOMPLETE, Env:\_ARGCOMPLETE_SUPPRESS_SPACE, Env:\_ARGCOMPLETE_IFS
}
# Chocolatey
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
# AWS
Register-ArgumentCompleter -Native -CommandName aws -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$env:COMP_LINE=$wordToComplete
$env:COMP_POINT=$cursorPosition
aws_completer.exe | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
Remove-Item Env:\COMP_LINE
Remove-Item Env:\COMP_POINT
}
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "#E06C75",
"style": "plain",
"template": "root <#ffffff>in</> ",
"type": "root"
},
{
"foreground": "#55B9C4",
"properties": {
"style": "folder"
},
"style": "plain",
"template": "{{ .Path }} ",
"type": "path"
},
{
"foreground": "#C678DD",
"properties": {
"fetch_status": true
},
"style": "plain",
"template": "<#ffffff>on</> {{ .HEAD }}{{ .BranchStatus }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }} ",
"type": "git"
},
{
"foreground": "#98C379",
"properties": {
"fetch_version": true
},
"style": "plain",
"template": " \ue781 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} ",
"type": "node"
},
{
"type": "java",
"style": "plain",
"foreground": "#de0a17",
"template": " \uE738 {{ .Full }}"
},
{
"type": "kotlin",
"style": "plain",
"foreground": "#906cff",
"template": " \ufa05 {{ .Full }} "
},
{
"type": "go",
"style": "plain",
"foreground": "#7FD5EA",
"template": " \uFCD1 {{ .Full }} "
},
{
"type": "dotnet",
"style": "plain",
"foreground": "#00ffff",
"template": " \uE77F {{ .Full }} "
},
{
"type": "python",
"style": "plain",
"foreground": "#906cff",
"template": " \uE235 {{ .Full }} "
},
{
"foreground": "#C94A16",
"style": "plain",
"template": " x ",
"type": "exit"
}
],
"type": "prompt"
},
{
"alignment": "right",
"segments": [
{
"type": "kubectl",
"style": "plain",
"foreground": "#000000",
"background": "#ebcc34",
"template": " \uFD31 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}} "
},
{
"type": "aws",
"style": "plain",
"foreground": "#ffffff",
"background": "#FFA400",
"template": " \uE7AD {{.Profile}}{{if .Region}}@{{.Region}}{{end}}"
}
],
"type": "prompt"
},
{
"alignment": "left",
"newline": true,
"segments": [
{
"foreground": "#63F08C",
"style": "plain",
"template": "\u279c ",
"type": "text"
}
],
"type": "prompt"
}
],
"tooltips": [
{
"type": "git",
"tips": [
"git",
"g"
],
"style": "diamond",
"foreground": "#193549",
"background": "#fffb38",
"leading_diamond": "",
"trailing_diamond": "î‚´",
"template": "{{ .HEAD }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}",
"properties": {
"fetch_status": true,
"fetch_upstream_icon": true
}
}
],
"version": 2
}
scoop alias add ls 'scoop list'
scoop alias add cc 'scoop cache rm *'
scoop alias add rm 'scoop uninstall $args[0]'
scoop alias add c 'scoop cleanup $args[0]'
scoop alias add i 'scoop install $args[0]'
scoop alias add ri 'scoop rm $args[0] && scoop cache rm $args[0] && scoop install $args[0]'
scoop alias add u 'scoop update $args[0]'
scoop alias add ru 'scoop cache rm $args[0] && scoop update $args[0]'
scoop alias add up 'scoop update * && scoop cleanup *'
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command": "unbound",
"keys": "ctrl+v"
},
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "paste"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
],
"copyFormatting": "none",
"copyOnSelect": true,
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"experimental.rendering.forceFullRepaint": true,
"firstWindowPreference": "persistedWindowLayout",
"profiles":
{
"defaults":
{
"antialiasingMode": "grayscale",
"bellStyle":
[
"audible",
"window",
"taskbar"
],
"cursorShape": "emptyBox",
"font":
{
"face": "JetBrainsMono Nerd Font Mono"
},
"opacity": 60,
"useAcrylic": true
},
"list":
[
{
"colorScheme": "Campbell Powershell",
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"source": "Windows.Terminal.PowershellCore",
"useAcrylic": true
},
{
"colorScheme": "Raspberry",
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"padding": "8",
"source": "Windows.Terminal.Wsl",
"useAcrylic": true
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "Command Prompt",
"opacity": 89,
"useAcrylic": true
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": true,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
]
},
"schemes":
[
{
"background": "#0C0C0C",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#012456",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell Powershell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#282C34",
"black": "#282C34",
"blue": "#61AFEF",
"brightBlack": "#5A6374",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#98C379",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#98C379",
"name": "One Half Dark",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
},
{
"background": "#FAFAFA",
"black": "#383A42",
"blue": "#0184BC",
"brightBlack": "#4F525D",
"brightBlue": "#61AFEF",
"brightCyan": "#56B5C1",
"brightGreen": "#98C379",
"brightPurple": "#C577DD",
"brightRed": "#DF6C75",
"brightWhite": "#FFFFFF",
"brightYellow": "#E4C07A",
"cursorColor": "#4F525D",
"cyan": "#0997B3",
"foreground": "#383A42",
"green": "#50A14F",
"name": "One Half Light",
"purple": "#A626A4",
"red": "#E45649",
"selectionBackground": "#FFFFFF",
"white": "#FAFAFA",
"yellow": "#C18301"
},
{
"background": "#3C0315",
"black": "#282A2E",
"blue": "#0170C5",
"brightBlack": "#676E7A",
"brightBlue": "#80C8FF",
"brightCyan": "#8ABEB7",
"brightGreen": "#B5D680",
"brightPurple": "#AC79BB",
"brightRed": "#BD6D85",
"brightWhite": "#FFFFFD",
"brightYellow": "#FFFD76",
"cursorColor": "#FFFFFF",
"cyan": "#3F8D83",
"foreground": "#FFFFFD",
"green": "#76AB23",
"name": "Raspberry",
"purple": "#7D498F",
"red": "#BD0940",
"selectionBackground": "#FFFFFF",
"white": "#FFFFFD",
"yellow": "#E0DE48"
},
{
"background": "#002B36",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#FFFFFF",
"cyan": "#2AA198",
"foreground": "#839496",
"green": "#859900",
"name": "Solarized Dark",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#FDF6E3",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#002B36",
"cyan": "#2AA198",
"foreground": "#657B83",
"green": "#859900",
"name": "Solarized Light",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#FFFFFF",
"cyan": "#06989A",
"foreground": "#D3D7CF",
"green": "#4E9A06",
"name": "Tango Dark",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#FFFFFF",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#000000",
"cyan": "#06989A",
"foreground": "#555753",
"green": "#4E9A06",
"name": "Tango Light",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#000080",
"brightBlack": "#808080",
"brightBlue": "#0000FF",
"brightCyan": "#00FFFF",
"brightGreen": "#00FF00",
"brightPurple": "#FF00FF",
"brightRed": "#FF0000",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFFF00",
"cursorColor": "#FFFFFF",
"cyan": "#008080",
"foreground": "#C0C0C0",
"green": "#008000",
"name": "Vintage",
"purple": "#800080",
"red": "#800000",
"selectionBackground": "#FFFFFF",
"white": "#C0C0C0",
"yellow": "#808000"
}
],
"startOnUserLogin": false,
"useAcrylicInTabRow": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment