Skip to content

Instantly share code, notes, and snippets.

@maguroguma
Created October 16, 2022 12:27
Show Gist options
  • Save maguroguma/5a3a960800351804b6685358e9bf25e0 to your computer and use it in GitHub Desktop.
Save maguroguma/5a3a960800351804b6685358e9bf25e0 to your computer and use it in GitHub Desktop.
filter command history from `.zhistory` to a buffer
" 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