Created
October 16, 2022 12:27
-
-
Save maguroguma/5a3a960800351804b6685358e9bf25e0 to your computer and use it in GitHub Desktop.
filter command history from `.zhistory` to a buffer
This file contains hidden or 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
" show zsh command history | |
if getftype(expand('$HOME') . '/.zhistory') != "" | |
function! s:showShellHistory(...) | |
execute 'botright' 10 'new' | |
setlocal nobuflisted bufhidden=unload buftype=nofile | |
silent read !cat $HOME/.zhistory | cut -b 16- | head -n 5000 | |
if a:0 == 1 | |
let l:exe_com = 'v/' . a:1 . '/d' | |
execute l:exe_com | |
endif | |
norm G | |
setlocal nomodified | |
endfunction | |
" filter by strings given by the argument | |
command! -nargs=? ShellHistory :call s:showShellHistory(<f-args>) | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment