Created
January 9, 2023 08:17
-
-
Save Gee19/15d8965b5d108817ab25b2ffcc9f5da8 to your computer and use it in GitHub Desktop.
fzf session picker
This file contains 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
" FZF Session Picker {{{ | |
let s:session_dir = '$HOME/.vim/session/' | |
function! s:list_sessions() abort | |
return systemlist('ls ' . s:session_dir) | |
endfunction | |
function! s:source_session(line) abort | |
exec 'source ' . s:session_dir . substitute(a:line[0], '%', '\\%', 'g') | |
endfunction | |
" TODO: Add ctrl-x to delete, ctrl-e to edit | |
command! SessionPicker call fzf#run(fzf#wrap({ | |
\ 'source': s:list_sessions(), | |
\ 'sink*': { line -> s:source_session(line) }, | |
\ 'options': '--prompt="Source Session:" --reverse' | |
\ })) | |
" }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment