Skip to content

Instantly share code, notes, and snippets.

Last active December 21, 2022 06:28
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
PowerShell Profile
# 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