From 08c6aee17e2e83b8cffea503bb65431e4c07acc0 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 14 Mar 2021 17:31:05 +0100 Subject: [PATCH] vifm: Set statusline, ruler, fzf, and PDF combine Set statusline to show more relevant information, and removed 'tip of the day' functionality since I've never been looking at it. Set ruler to show me how many files are hidden in a directory. Added shortcut to quickly combine a bunch of PDFs (`gc`) that are selected. Added shortcut (`f`) to invoke fzf on current directory and navigate to the result. This mirrors my vim use and mapping. Additionally, added commands to invoke the fzf functionality (`:FZFfind` and `FZFlocate`) by hand. Lastly, moved the file classification and opening functionality a bit out of the way. Should still think about handing off opening files to xdg-open since that's what it's there for, and only make vifm handle the file preview stuff (i.e. the opposite window buffer preview). --- vifm/.config/vifm/vifmrc | 293 +++++++++++++++++++++------------------ 1 file changed, 158 insertions(+), 135 deletions(-) diff --git a/vifm/.config/vifm/vifmrc b/vifm/.config/vifm/vifmrc index 1eaa437..0f6aca9 100644 --- a/vifm/.config/vifm/vifmrc +++ b/vifm/.config/vifm/vifmrc @@ -39,7 +39,6 @@ set nofollowlinks " With this option turned on you can run partially entered commands with " unambiguous beginning using :! (e.g. :!Te instead of :!Terminal or :!Te). - " set fastrun " Natural sort of (version) numbers within text. @@ -62,7 +61,7 @@ colorscheme cfillion.vifm " Format for displaying time in file list. For example: " TIME_STAMP_FORMAT=%m/%d-%H:%M " See man date or man strftime for details. -set timefmt=%d-%m\ %H:%M +set timefmt=%Y-%m-%d\ %H:%M " Show list of matches on tab completion in command-line mode set wildmenu @@ -94,7 +93,12 @@ if !has('win') endif " Set custom status line look -set statusline=" Hint: %z%= %A %10u:%-7g %15s %20d " +set statusline="%A %10u:%-7g %10E / %-a %20d" + +" Set ruler look (below statusline, showing directory info) +" set to show current file number, and overall number of files in dir +" with optional display of not-shown files if any are filtered out. +set rulerformat="%2l/%S %[[+%x]%]" " decrease waiting time between input polling set mintimeoutlen=50 @@ -102,6 +106,9 @@ set mintimeoutlen=50 " set the pre-key timeout really high, see https://git.io/fNm1d set timeoutlen=5000 +" use fd instead of default find to make searching faster and more flexible +set findprg='fd %A --hidden --exclude .git --exclude node_modules' + " }}} " Marks {{{ " ------------------------------------------------------------------------------ @@ -143,7 +150,155 @@ command! mkcd :mkdir %a | cd %a " command! vgrep nvim "+grep %a" command! reload :write | restart +command! FZFlocate : set noquickview + \| let $FZF_PICK = term('locate $HOME | fzf 2>/dev/tty') + \| if $FZF_PICK != '' + \| execute 'goto' fnameescape($FZF_PICK) + \| endif +command! FZFfind : set noquickview + \| let $FZF_PICK = term('find | fzf 2>/dev/tty') + \| if $FZF_PICK != '' + \| execute 'goto' fnameescape($FZF_PICK) + \| endif " }}} +" vifminfo {{{ +" ------------------------------------------------------------------------------ + +" What should be saved automatically between vifm runs +" Like in previous versions of vifm +" set vifminfo=options,filetypes,commands,bookmarks,dhistory,state,cs +" Like in vi +set vifminfo=dhistory,savedirs,chistory,state,tui,shistory, + \phistory,fhistory,dirstack,registers,bookmarks,bmarks + +" ------------------------------------------------------------------------------ + +" Examples of configuring both panels + +" Customize view columns a bit (enable ellipsis for truncated file names) +" +" set viewcolumns=-{name}..,6{}. + +" Filter-out build and temporary files +" +" filter! /^.*\.(lo|o|d|class|py[co])$|.*~$/ + +" }}} +" Mappings {{{ +" ------------------------------------------------------------------------------ + +" make quitting simpler +nmap Q :q + +" Sample mappings +" for now they use space for my leader key - so we can't switch panels with +" space, use tab for that +nnoremap +nnoremap t + +" quick find mirroring my vim filefinder +nnoremap f :FZFfind + +" Start shell in current directory +nnoremap s :shell + +" Display sorting dialog +nnoremap S :sort + +" Toggle visibility of preview window +nnoremap w :view +vnoremap w :viewgv + +" Open file in existing instance of nvim +nnoremap e :!nvim %f + +" Open file in the background using its default program +nnoremap gb :file &l + +" yank current directory path into the clipboard +nnoremap yd :!echo -n %d | xclip -selection "clipboard" %i + +" yank current file path into the clipboard +nnoremap yf :!echo -n %c:p | xclip -selection "clipboard" %i + +" yank current filename without path into the clipboard +nnoremap yn :!echo -n %c | xclip -selection "clipboard" %i + +" yank root of current file's name into the clipboard +nnoremap yr :!echo -n %c:r | xclip -selection "clipboard" %i + +" Mappings for faster renaming +nnoremap I cw +nnoremap cc cw +nnoremap A cw +" More logical renaming, cw renames just the name, cW with extension +nnoremap cw cW +nnoremap cW cw + +" Open editor to edit vifmrc and apply settings after returning to vifm +nnoremap V :write | edit $MYVIFMRC | restart + +" esc quits out of preview mode (it does in vim, why not here?) +qnoremap q + +" Select file and jump in the indicated direction +nnoremap J tj +nnoremap K tk + +" Example of standard two-panel file managers mappings +nnoremap :!less %f +nnoremap :edit +nnoremap :copy +nnoremap :move +nnoremap :mkdir +nnoremap :delete + +" toggle options +command! toggle :execute 'set %a! | echo "%a" &%a' +nnoremap tw :toggle wrap +nnoremap tm :toggle millerview +nnoremap tl :toggle lsview +nnoremap tn :toggle number +nnoremap tr :toggle relativenumber +nnoremap tN :windo toggle number +nnoremap tR :windo toggle relativenumber +nnoremap te :execute ':tree! | echo ":tree"' +nnoremap t +nnoremap tt t + +" Switch pane to same directory as opposite pane +nnoremap :cd %D + +" zo shows hidden files, mimicking fold open in vim -- why does zc not close +" again? +nnoremap zc zm + +" external commands +" extract currently selected file(s) +nnoremap gx :!atool -x %f +" combine selected PDFs into single one (named output.pdf) +noremap gc :!pdftk %f cat output output.pdf + +" }}} +" Classify (Icons) {{{ +" file types +set classify=' :dir:/, :exe:, :reg:, :link:' +" various file names +set classify+=' ::../::, ::*.sh::, ::*.[hc]pp::, ::*.[hc]::, ::/^copying|license$/::, ::.git/,,*.git/::, ::*.epub,,*.fb2,,*.djvu::, ::*.pdf::, ::*.htm,,*.html,,**.[sx]html,,*.xml::' +" archives +set classify+=' ::*.7z,,*.ace,,*.arj,,*.bz2,,*.cpio,,*.deb,,*.dz,,*.gz,,*.jar,,*.lzh,,*.lzma,,*.rar,,*.rpm,,*.rz,,*.tar,,*.taz,,*.tb2,,*.tbz,,*.tbz2,,*.tgz,,*.tlz,,*.trz,,*.txz,,*.tz,,*.tz2,,*.xz,,*.z,,*.zip,,*.zoo::' +" images +set classify+=' ::*.bmp,,*.gif,,*.jpeg,,*.jpg,,*.ico,,*.png,,*.ppm,,*.svg,,*.svgz,,*.tga,,*.tif,,*.tiff,,*.xbm,,*.xcf,,*.xpm,,*.xspf,,*.xwd::' +" audio +set classify+=' ::*.aac,,*.anx,,*.asf,,*.au,,*.axa,,*.flac,,*.m2a,,*.m4a,,*.mid,,*.midi,,*.mp3,,*.mpc,,*.oga,,*.ogg,,*.ogx,,*.ra,,*.ram,,*.rm,,*.spx,,*.wav,,*.wma,,*.ac3::' +" media +set classify+=' ::*.avi,,*.ts,,*.axv,,*.divx,,*.m2v,,*.m4p,,*.m4v,,.mka,,*.mkv,,*.mov,,*.mp4,,*.flv,,*.mp4v,,*.mpeg,,*.mpg,,*.nuv,,*.ogv,,*.pbm,,*.pgm,,*.qt,,*.vob,,*.wmv,,*.xvid::' +" office files +set classify+=' ::*.doc,,*.docx::, ::*.xls,,*.xls[mx]::, ::*.pptx,,*.ppt::' + +" }}} +" +" ------------------------------------------------------------------------------ " Filetypes {{{ " ------------------------------------------------------------------------------ @@ -395,138 +550,6 @@ fileviewer */ " filetype * start, explorer " }}} -" vifminfo {{{ -" ------------------------------------------------------------------------------ - -" What should be saved automatically between vifm runs -" Like in previous versions of vifm -" set vifminfo=options,filetypes,commands,bookmarks,dhistory,state,cs -" Like in vi -set vifminfo=dhistory,savedirs,chistory,state,tui,shistory, - \phistory,fhistory,dirstack,registers,bookmarks,bmarks - -" ------------------------------------------------------------------------------ - -" Examples of configuring both panels - -" Customize view columns a bit (enable ellipsis for truncated file names) -" -" set viewcolumns=-{name}..,6{}. - -" Filter-out build and temporary files -" -" filter! /^.*\.(lo|o|d|class|py[co])$|.*~$/ - -" }}} -" Mappings {{{ -" ------------------------------------------------------------------------------ - -" make quitting simpler -nmap Q :q - -" Sample mappings -" for now they use space for my leader key - so we can't switch panels with -" space, use tab for that -nnoremap -nnoremap t - -" Start shell in current directory -nnoremap s :shell - -" Display sorting dialog -nnoremap S :sort - -" Toggle visibility of preview window -nnoremap w :view -vnoremap w :viewgv - -" Open file in existing instance of nvim -nnoremap e :!nvim %f - -" Open file in the background using its default program -nnoremap gb :file &l - -" yank current directory path into the clipboard -nnoremap yd :!echo -n %d | xclip -selection "clipboard" %i - -" yank current file path into the clipboard -nnoremap yf :!echo -n %c:p | xclip -selection "clipboard" %i - -" yank current filename without path into the clipboard -nnoremap yn :!echo -n %c | xclip -selection "clipboard" %i - -" yank root of current file's name into the clipboard -nnoremap yr :!echo -n %c:r | xclip -selection "clipboard" %i - -" Mappings for faster renaming -nnoremap I cw -nnoremap cc cw -nnoremap A cw -" More logical renaming, cw renames just the name, cW with extension -nnoremap cw cW -nnoremap cW cw - -" Open editor to edit vifmrc and apply settings after returning to vifm -nnoremap V :write | edit $MYVIFMRC | restart - -" esc quits out of preview mode (it does in vim, why not here?) -qnoremap q - -" Select file and jump in the indicated direction -nnoremap J tj -nnoremap K tk - -" Example of standard two-panel file managers mappings -nnoremap :!less %f -nnoremap :edit -nnoremap :copy -nnoremap :move -nnoremap :mkdir -nnoremap :delete - -" toggle options -command! toggle :execute 'set %a! | echo "%a" &%a' -nnoremap tw :toggle wrap -nnoremap tm :toggle millerview -nnoremap tl :toggle lsview -nnoremap tn :toggle number -nnoremap tr :toggle relativenumber -nnoremap tN :windo toggle number -nnoremap tR :windo toggle relativenumber -nnoremap te :execute ':tree! | echo ":tree"' -nnoremap t -nnoremap tt t - -" Switch pane to same directory as opposite pane -nnoremap :cd %D - -" zo shows hidden files, mimicking fold open in vim -- why does zc not close -" again? -nnoremap zc zm - -" extract currently selected file(s) -nnoremap gx :!atool -x %f - -" }}} -" Classify (Icons) {{{ -" file types -set classify=' :dir:/, :exe:, :reg:, :link:' -" various file names -set classify+=' ::../::, ::*.sh::, ::*.[hc]pp::, ::*.[hc]::, ::/^copying|license$/::, ::.git/,,*.git/::, ::*.epub,,*.fb2,,*.djvu::, ::*.pdf::, ::*.htm,,*.html,,**.[sx]html,,*.xml::' -" archives -set classify+=' ::*.7z,,*.ace,,*.arj,,*.bz2,,*.cpio,,*.deb,,*.dz,,*.gz,,*.jar,,*.lzh,,*.lzma,,*.rar,,*.rpm,,*.rz,,*.tar,,*.taz,,*.tb2,,*.tbz,,*.tbz2,,*.tgz,,*.tlz,,*.trz,,*.txz,,*.tz,,*.tz2,,*.xz,,*.z,,*.zip,,*.zoo::' -" images -set classify+=' ::*.bmp,,*.gif,,*.jpeg,,*.jpg,,*.ico,,*.png,,*.ppm,,*.svg,,*.svgz,,*.tga,,*.tif,,*.tiff,,*.xbm,,*.xcf,,*.xpm,,*.xspf,,*.xwd::' -" audio -set classify+=' ::*.aac,,*.anx,,*.asf,,*.au,,*.axa,,*.flac,,*.m2a,,*.m4a,,*.mid,,*.midi,,*.mp3,,*.mpc,,*.oga,,*.ogg,,*.ogx,,*.ra,,*.ram,,*.rm,,*.spx,,*.wav,,*.wma,,*.ac3::' -" media -set classify+=' ::*.avi,,*.ts,,*.axv,,*.divx,,*.m2v,,*.m4p,,*.m4v,,.mka,,*.mkv,,*.mov,,*.mp4,,*.flv,,*.mp4v,,*.mpeg,,*.mpg,,*.nuv,,*.ogv,,*.pbm,,*.pgm,,*.qt,,*.vob,,*.wmv,,*.xvid::' -" office files -set classify+=' ::*.doc,,*.docx::, ::*.xls,,*.xls[mx]::, ::*.pptx,,*.ppt::' - -" }}} -" -" ------------------------------------------------------------------------------ " Various customization examples