From 121072c540f9a74b1f29ec751b283f09448552b6 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Thu, 14 Jan 2021 12:56:57 +0800 Subject: [PATCH] [feature] add fzf --- win/oh-my-posh.ps1 | 10 +++++++--- win/profile.ps1 | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/win/oh-my-posh.ps1 b/win/oh-my-posh.ps1 index dc07f3f..dc22204 100644 --- a/win/oh-my-posh.ps1 +++ b/win/oh-my-posh.ps1 @@ -1,6 +1,10 @@ -# Install-Module -Name PowerShellGet -Force -AllowPrerelease -# Install-Module -Name posh-git -# Install-Module -Name oh-my-posh +# curl: https://curl.se/windows/ +# ag: https://github.com/k-takata/the_silver_searcher-win32/releases +# fzf: https://github.com/junegunn/fzf/releases/latest +Install-Module -Name PowerShellGet -Force -AllowPrerelease +Install-Module -Name posh-git +Install-Module -Name oh-my-posh +Install-Module -Name psfzf $dotfiles=(Get-Item $PSScriptRoot).Parent.FullName New-Item -ItemType SymbolicLink -Target $dotfiles\win\profile.ps1 -Path $profile -Force diff --git a/win/profile.ps1 b/win/profile.ps1 index 2711eb0..86726f6 100644 --- a/win/profile.ps1 +++ b/win/profile.ps1 @@ -5,6 +5,8 @@ Set-PSReadLineOption -EditMode Emacs Set-PSReadLineOption -PredictionSource History +Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r' + $Env:Path += ";$PSScriptRoot\bin" $Env:KUBE_EDITOR = 'nvim' @@ -80,3 +82,21 @@ function ssh-copy-id { Get-Content $IdentityFile | ssh $UserHost "umask 077; mkdir -p .ssh ; cat >> .ssh/authorized_keys" } + +function pass-edit { + param ( + [Parameter()] + [String] + $Path + ) + + $tmpfile = New-TemporaryFile + gpg --decrypt $Path > $tmpfile.FullName + nvim $tmpfile.FullName + if ($? && ((gpg --list-secret-keys | findstr uid) -match '<(.*?)>')) { + $uid=$matches[1] + gpg -r $uid -o "${tmpfile.FullName}.gpg" --encrypt $tmpfile.FullName + Move-Item -Path "${tmpfile.FullName}.gpg" -Destination "$Path" -Force + Remove-Item $tmpfile.FullName -Force + } +} \ No newline at end of file