def find -docstring "find files" -menu -params 1 \ %{ edit -existing %arg{1} } \ -shell-script-candidates %{ fd -t f --hidden --color=never -E .git } def file-manager -params .. %{ terminal-singleton files env "DAFFM_PATH_RELATIVE_TO=%val{client_env_PWD}" daffm -c @kak %arg{@} } def findfzf %{ terminal-singleton fzf sh -c 'kcr edit $(fd -t f --hidden --color=never -E .git | fzf --multi --min-height=100 --preview=''bat --color=always {}'')' } declare-user-mode file map global user f ': enter-user-mode file' -docstring 'File mode' map global file f ': find ' -docstring 'Find files' map global file n ': file-manager %val{buffile}' -docstring 'File manager' map global file F ': findfzf' -docstring 'Fzf' declare-user-mode buffer map global user b ': enter-user-mode-with-count buffer' -docstring 'Buffer mode' map global buffer b ': buffer ' -docstring 'Switch buffer' map global buffer ': buffer-jump %opt{user_mode_count}; buffers-show' -docstring 'Jump to buffer' map global buffer n ': buffer-next; buffers-show' -docstring 'Next buffer' map global buffer p ': buffer-previous; buffers-show' -docstring 'Previous buffer' map global buffer d ': delete-buffer; buffers-show' -docstring 'Delete buffer' map global buffer s ': write' -docstring 'Save' def buffers-show %{ info -title 'buffers' -markup %sh{ echo "$kak_quoted_buflist" | xargs -n1 | while IFS= read buf; do if [ -z "$buf" ]; then echo "{comment}{Normal}" elif [ "$buf" == "$kak_bufname" ]; then echo "{keyword}$buf{Normal}" else echo "{Default}$buf{Normal}" fi done | nl -w 2 } } def buffer-jump -params 1 %{ evaluate-commands %sh{ if ! [ "$1" == "0" ]; then buf=$(echo "$kak_quoted_buflist" | xargs -n1 | head -n "$1" | tail -n1) [ -z "$buf" ] || printf "buffer '%s'" $(echo "$buf" | sed "s/'/''/g") fi } }