Skip to content

Commit

Permalink
add YankHistoryYank
Browse files Browse the repository at this point in the history
  • Loading branch information
yazgoo committed Aug 28, 2021
1 parent 8dffc92 commit 0c14a11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/yank-history.txt
Expand Up @@ -28,6 +28,9 @@ COMMANDS *yank-history-commands*
:YankHistoryPaste[!] *:YankHistoryPaste*
opens FZF to select yank history file to be pasted

:YankHistoryYank[!] *:YankHistoryYank*
opens FZF to select yank history file to be added to the yank register

:YankHistoryRg[!] *:YankHistoryRg*
grep within yank history via FZF and opens the file matching the search
pattern
Expand Down
15 changes: 14 additions & 1 deletion plugin/yank-history.vim
Expand Up @@ -34,7 +34,7 @@ function! YankHistoryYank()
call mkdir(g:yank_history_tmp_dir, "p", 0700)
let tmp = g:yank_history_tmp_dir . '/' . strftime("%d-%m-%y-%H-%M-%S.").&filetype
call writefile(split(@0, "\n", 1), tmp, 'b')
let md5=trim(system('md5sum ' . tmp . ' | cut "-d " -f1'))
let md5=trim(system('md5sum ' . tmp . ' | cut "-d " -f1'))
let out = g:yank_history_dir.'/'.md5.'.'.&filetype
if filereadable(out)
silent execute "!rm " . tmp
Expand Down Expand Up @@ -77,6 +77,19 @@ command! -bang -nargs=0 YankHistoryPaste
\ <bang>0
\ )

""
" opens FZF to select yank history file to be
" added to the yank register
command! -bang -nargs=0 YankHistoryYank
\ call fzf#vim#grep(
\ 'ls -t ' . g:yank_history_dir . '/*', 0,
\ {
\ 'options': ["--prompt", "> ", "--preview", s:yank_history_script_dir .'/../../fzf.vim/bin/preview.sh {}'],
\ 'sink': function('s:yank_history_yank')
\ },
\ <bang>0
\ )

""
" grep within yank history via FZF and opens the file matching the search
" pattern
Expand Down

0 comments on commit 0c14a11

Please sign in to comment.