Last active
December 21, 2022 06:28
-
-
Save hotchpotch/61582e7d390577dff76c88f5ddc88e20 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
# PS Modules | |
Import-Module posh-git | |
Import-Module oh-my-posh | |
Import-Module ZLocation | |
Set-Theme robbyrussell # お好きなテーマ | |
Set-PSReadLineOption -EditMode Emacs | |
Set-PSReadLineOption -BellStyle None | |
# 標準だと Ctrl+d は DeleteCharOrExit のため、うっかり端末が終了することを防ぐ | |
Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar | |
# env | |
$env:GIT_SSH = "C:\WINDOWS\System32\OpenSSH\ssh.exe" | |
# aliases | |
Set-Alias grep rg | |
# functions | |
function gf { | |
$path = ghq list | fzf | |
if ($LastExitCode -eq 0) { | |
cd "$(ghq root)\$path" | |
} | |
} | |
function ghg { | |
ghq get --shallow $args | |
} | |
# uutils | |
@" | |
arch, base32, base64, basename, cat, cksum, comm, cp, cut, date, df, dircolors, dirname, | |
echo, env, expand, expr, factor, false, fmt, fold, hashsum, head, hostname, join, link, ln, | |
ls, md5sum, mkdir, mktemp, more, mv, nl, nproc, od, paste, printenv, printf, ptx, pwd, | |
readlink, realpath, relpath, rm, rmdir, seq, sha1sum, sha224sum, sha256sum, sha3-224sum, | |
sha3-256sum, sha3-384sum, sha3-512sum, sha384sum, sha3sum, sha512sum, shake128sum, | |
shake256sum, shred, shuf, sleep, sort, split, sum, sync, tac, tail, tee, test, touch, tr, | |
true, truncate, tsort, unexpand, uniq, wc, whoami, yes | |
"@ -split ',' | | |
ForEach-Object { $_.trim() } | | |
Where-Object { ! @('tee', 'sort', 'sleep').Contains($_) } | | |
ForEach-Object { | |
$cmd = $_ | |
if (Test-Path Alias:$cmd) { Remove-Item -Path Alias:$cmd } | |
$fn = '$input | uutils ' + $cmd + ' $args' | |
Invoke-Expression "function global:$cmd { $fn }" | |
} | |
` | |
# keybinds | |
# 実行後入力待ちになるため、AcceptLine を実行する | |
Set-PSReadLineKeyHandler -Chord 'Ctrl+]' -ScriptBlock { gf; [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() } | |
Set-PSReadLineKeyHandler -Chord 'Ctrl+;' -ScriptBlock { Invoke-FuzzyZLocation; [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment