From c5296ed6f840adf1073032ceb7b129d91c44b772 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 5 Apr 2024 01:25:59 +0200 Subject: [PATCH] Add vifm (terminal filemgr) --- .../terminal/file-managers/default.nix | 5 + .../file-managers/vifm/config/colors/.gitkeep | 1 + .../vifm/config/settings/abbr.vifm | 4 + .../vifm/config/settings/commands.vifm | 26 ++++ .../vifm/config/settings/favicons.vifm | 70 +++++++++ .../vifm/config/settings/ft.vifm | 136 ++++++++++++++++++ .../vifm/config/settings/fv.vifm | 3 + .../vifm/config/settings/mappings.vifm | 38 +++++ .../terminal/file-managers/vifm/config/vifmrc | 114 +++++++++++++++ .../terminal/file-managers/vifm/default.nix | 23 +++ 10 files changed, 420 insertions(+) create mode 100644 home/programs/terminal/file-managers/vifm/config/colors/.gitkeep create mode 100644 home/programs/terminal/file-managers/vifm/config/settings/abbr.vifm create mode 100644 home/programs/terminal/file-managers/vifm/config/settings/commands.vifm create mode 100644 home/programs/terminal/file-managers/vifm/config/settings/favicons.vifm create mode 100644 home/programs/terminal/file-managers/vifm/config/settings/ft.vifm create mode 100644 home/programs/terminal/file-managers/vifm/config/settings/fv.vifm create mode 100644 home/programs/terminal/file-managers/vifm/config/settings/mappings.vifm create mode 100644 home/programs/terminal/file-managers/vifm/config/vifmrc create mode 100644 home/programs/terminal/file-managers/vifm/default.nix diff --git a/home/programs/terminal/file-managers/default.nix b/home/programs/terminal/file-managers/default.nix index 97fef1d..f6ad61e 100644 --- a/home/programs/terminal/file-managers/default.nix +++ b/home/programs/terminal/file-managers/default.nix @@ -1,7 +1,12 @@ +# Note: Pretty much all of these configurations were copied from +# https://git.notashelf.dev/NotAShelf/nyx, there may be some small +# adjustments made to them but the majority of the credit goes to +# notashelf. _: { imports = [ ./yazi ./xplr + ./vifm ]; } diff --git a/home/programs/terminal/file-managers/vifm/config/colors/.gitkeep b/home/programs/terminal/file-managers/vifm/config/colors/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/home/programs/terminal/file-managers/vifm/config/colors/.gitkeep @@ -0,0 +1 @@ + diff --git a/home/programs/terminal/file-managers/vifm/config/settings/abbr.vifm b/home/programs/terminal/file-managers/vifm/config/settings/abbr.vifm new file mode 100644 index 0000000..3949c55 --- /dev/null +++ b/home/programs/terminal/file-managers/vifm/config/settings/abbr.vifm @@ -0,0 +1,4 @@ +" vim:ft=vim +cabbrev t touch +cabbrev mk mkdir + diff --git a/home/programs/terminal/file-managers/vifm/config/settings/commands.vifm b/home/programs/terminal/file-managers/vifm/config/settings/commands.vifm new file mode 100644 index 0000000..1704428 --- /dev/null +++ b/home/programs/terminal/file-managers/vifm/config/settings/commands.vifm @@ -0,0 +1,26 @@ +" vim:ft=vim +" :com[mand][!] command_name action +" The following macros can be used in a command +" %a is replaced with the user arguments. +" %c the current file under the cursor. +" %C the current file under the cursor in the other directory. +" %f the current selected file, or files. +" %F the current selected file, or files in the other directory. +" %b same as %f %F. +" %d the current directory name. +" %D the other window directory name. +" %m run the command in a menu window +" more information: https://vifm.info/vimdoc.shtml#vifm-macros + +command! df df -h %m 2> /dev/null +command! diff nvim -d %f %F +command! run !! ./%f +command! make !!make %a +command! mkcd :mkdir %a | cd %a +command! vgrep vim "+grep %a" +command! reload :write | restart +command! dragon dragon-drop -a -x %f +command! clear vifmimg clear +command! print lp -n 1 -o sides=two-sided-long-edge %f +command! sudoedit sudoedit %c + diff --git a/home/programs/terminal/file-managers/vifm/config/settings/favicons.vifm b/home/programs/terminal/file-managers/vifm/config/settings/favicons.vifm new file mode 100644 index 0000000..76b4d3b --- /dev/null +++ b/home/programs/terminal/file-managers/vifm/config/settings/favicons.vifm @@ -0,0 +1,70 @@ +" vim:ft=vim + +" Filetypes/directories +set classify=' :dir:/, :exe:, :reg:, :link:,? :?:, ::../::' + +" Specific files +set classify+=' ::.Xdefaults,,.Xresources,,.bashprofile,,.bash_profile,,.bashrc,,.dmrc,,.d_store,,.fasd,,.gitconfig,,.gitignore,,.jack-settings,,.mime.types,,.nvidia-settings-rc,,.pam_environment,,.profile,,.recently-used,,.selected_editor,,.xinitpurc,,.zprofile,,.yarnc,,.snclirc,,.tmux.conf,,.urlview,,.config,,.ini,,.user-dirs.dirs,,.mimeapps.list,,.offlineimaprc,,.msmtprc,,.Xauthority,,config::' +set classify+=' ::dropbox::' +set classify+=' ::favicon.*,,README,,readme::' +set classify+=' ::.vim,,.vimrc,,.gvimrc,,.vifm::' +set classify+=' ::gruntfile.coffee,,gruntfile.js,,gruntfile.ls::' +set classify+=' ::gulpfile.coffee,,gulpfile.js,,gulpfile.ls::' +set classify+=' ::ledger::' +set classify+=' ::license,,copyright,,copying,,LICENSE,,COPYRIGHT,,COPYING::' +set classify+=' ::node_modules::' +set classify+=' ::react.jsx::' + +" File extensions +set classify+='λ ::*.ml,,*.mli::' +set classify+=' ::*.styl::' +set classify+=' ::*.scss::' +set classify+=' ::*.py,,*.pyc,,*.pyd,,*.pyo::' +set classify+=' ::*.php::' +set classify+=' ::*.markdown,,*.md::' +set classify+=' ::*.json::' +set classify+=' ::*.js::' +set classify+=' ::*.bmp,,*.gif,,*.ico,,*.jpeg,,*.jpg,,*.png,,*.svg,,*.svgz,,*.tga,,*.tiff,,*.xmb,,*.xcf,,*.xpm,,*.xspf,,*.xwd,,*.cr2,,*.dng,,*.3fr,,*.ari,,*.arw,,*.bay,,*.crw,,*.cr3,,*.cap,,*.data,,*.dcs,,*.dcr,,*drf,,*.eip,,*.erf,,*.fff,,*.gpr,,*.iiq,,*.k25,,*.kdc,,*.mdc,,.*mef,,*.mos,,.*.mrw,,.*.obm,,*.orf,,*.pef,,*.ptx,,*.pxn,,*.r3d,,*.raf,,*.raw,,*.rwl,,*.rw2,,*.rwz,,*.sr2,,*.srf,,*.srf,,*.srw,,*.tif,,*.x3f::' +set classify+=' ::*.ejs,,*.htm,,*.html,,*.slim,,*.xml::' +set classify+=' ::*.mustasche::' +set classify+=' ::*.css,,*.less,,*.bat,,*.conf,,*.ini,,*.rc,,*.yml,,*.cfg,,*.rc::' +set classify+=' ::*.rss::' +set classify+=' ::*.coffee::' +set classify+=' ::*.twig::' +set classify+=' ::*.c++,,*.cc,,*.cpp,,*.cxx,,*.h::' +set classify+=' ::*.c::' +set classify+=' ::*.hs,,*.lhs::' +set classify+=' ::*.lua::' +set classify+=' ::*.jl::' +set classify+=' ::*.go::' +set classify+=' ::*.ts::' +set classify+=' ::*.db,,*.dump,,*.sql::' +set classify+=' ::*.sln,,*.suo::' +set classify+=' ::*.exe::' +set classify+=' ::*.diff,,*.sum,,*.md5,,*.sha512::' +set classify+=' ::*.scala::' +set classify+=' ::*.java,,*.jar::' +set classify+=' ::*.xul::' +set classify+=' ::*.clj,,*.cljc::' +set classify+=' ::*.pl,,*.pm,,*.t::' +set classify+=' ::*.cljs,,*.edn::' +set classify+=' ::*.rb::' +set classify+=' ::*.fish,,*.sh,,*.bash::' +set classify+=' ::*.dart::' +set classify+=' ::*.f#,,*.fs,,*.fsi,,*.fsscript,,*.fsx::' +set classify+=' ::*.rlib,,*.rs::' +set classify+=' ::*.d::' +set classify+=' ::*.erl,,*.hrl::' +set classify+=' ::*.ai::' +set classify+=' ::*.psb,,*.psd::' +set classify+=' ::*.jsx::' +set classify+=' ::*.aac,,*.anx,,*.asf,,*.au,,*.axa,,*.flac,,*.m2a,,*.m4a,,*.mid,,*.midi,,*.mp3,,*.mpc,,*.oga,,*.ogg,,*.ogx,,*.ra,,*.ram,,*.rm,,*.spx,,*.wav,,*.wma,,*.ac3::' +set classify+=' ::*.avi,,*.flv,,*.mkv,,*.mov,,*.mov,,*.mp4,,*.mpeg,,*.mpg,,*.webm::' +set classify+=' ::*.epub,,*.pdf,,*.fb2,,*.djvu::' +set classify+=' ::*.7z,,*.apk,,*.bz2,,*.cab,,*.cpio,,*.deb,,*.gem,,*.gz,,*.gzip,,*.lh,,*.lzh,,*.lzma,,*.rar,,*.rpm,,*.tar,,*.tgz,,*.xz,,*.zip::' +set classify+=' ::*.cbr,,*.cbz::' +set classify+=' ::*.log::' +set classify+=' ::*.doc,,*.docx,,*.adoc::' +set classify+=' ::*.xls,,*.xls,,*.xlsmx::' +set classify+=' ::*.pptx,,*.ppt::' + diff --git a/home/programs/terminal/file-managers/vifm/config/settings/ft.vifm b/home/programs/terminal/file-managers/vifm/config/settings/ft.vifm new file mode 100644 index 0000000..3d2a2d1 --- /dev/null +++ b/home/programs/terminal/file-managers/vifm/config/settings/ft.vifm @@ -0,0 +1,136 @@ +" vim:ft=vim +" filextype: What should it do (which program should it use), when you want to open it +" fileviewer: What should it do for the prievew? + +filextype *.pdf zathura %c & + +filextype *.ps,*.eps,*.ps.gz + \ {View in sioyek} + \ sioyek %f & + +filextype *.xml,*.ipe ipe %c & + +filextype *.djvu + \ {View in sioyek} + \ sioyek %f & , + \ {View in apvlv} + \ apvlv %f, + +filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus,*.MOD + \ {Play using ffplay} + \ ffplay -nodisp -autoexit %c &, + \ {Play using MPlayer} + \ mplayer %f &, +fileviewer *.mp3 mp3info +fileviewer *.flac soxi + +filextype *.avi,*.mp4,*.wmv,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob, + \*.fl[icv],*.m2v,*.mov,*.webm,*.mts,*.m4v,*.r[am],*.qt,*.divx, + \*.as[fx] + \ {View using ffplay} + \ ffplay -fs -autoexit -volume 100 %f &, + +filextype *.html,*.htm + \ firefox %f &, +filetype *.html,*.htm links, lynx +fileviewer *.html + \ w3m %c + +filetype *.o,*.out objdump -d %f | less +fileviewer *.o,*.out objdump -d %f + +filetype *.[1-8] man ./%c +fileviewer *.[1-8] man ./%c | col -b + +filextype *.bmp,*.jpg,*.jpeg,*.png,*.xpm,*.svg,*.ico,*.gif + "\ viewnior %c & + " \ vimiv --log-level info --debug vimico %c & + \ vimiv %c & + +filextype *.ora + \ {Edit in MyPaint} + \ mypaint %f, + +filextype *.vym + \ {Open with VYM} + \ vym %f &, + +filetype *.md5 + \ {Check MD5 hash sum} + \ md5sum -c %f %S, + +filetype *.sha1 + \ {Check SHA1 hash sum} + \ sha1sum -c %f %S, + +filetype *.sha256 + \ {Check SHA256 hash sum} + \ sha256sum -c %f %S, + +filetype *.sha512 + \ {Check SHA512 hash sum} + \ sha512sum -c %f %S, + +filetype *.asc + \ {Check signature} + \ !!gpg --verify %c, + +filetype *.torrent ktorrent %f & +fileviewer *.torrent dumptorrent -v %c + +filetype *.zip,*.jar,*.war,*.ear,*.oxt,*.apkg + \ {Mount with fuse-zip} + \ FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR, + \ {View contents} + \ zip -sf %c | less, + \ {Extract here} + \ tar -xf %c +filetype *.zip unzip %f +filetype *.tar.gz tar -xvf %f +fileviewer *.zip,*.jar,*.war,*.ear,*.oxt zip -sf %c + +filetype *.tar,*.tar.bz2,*.tbz2,*.tgz,*.tar.gz,*.tar.xz,*.txz + \ {Mount with archivemount} + \ FUSE_MOUNT|archivemount %SOURCE_FILE %DESTINATION_DIR, +fileviewer *.tgz,*.tar.gz tar -tzf %c +fileviewer *.tar.bz2,*.tbz2 tar -tjf %c +fileviewer *.tar.txz,*.txz xz --list %c +fileviewer *.tar tar -tf %c + +filetype *.rar + \ {Mount with rar2fs} + \ FUSE_MOUNT|rar2fs %SOURCE_FILE %DESTINATION_DIR, +fileviewer *.rar unrar v %c + +filetype *.iso + \ {Mount with fuseiso} + \ FUSE_MOUNT|fuseiso %SOURCE_FILE %DESTINATION_DIR, + +filetype *.ssh + \ {Mount with sshfs} + \ FUSE_MOUNT2|sshfs %PARAM %DESTINATION_DIR %FOREGROUND, + +filetype *.ftp + \ {Mount with curlftpfs} + \ FUSE_MOUNT2|curlftpfs -o ftp_port=-,,disable_eprt %PARAM %DESTINATION_DIR %FOREGROUND, + +filetype *.7z + \ {Mount with fuse-7z} + \ FUSE_MOUNT|fuse-7z %SOURCE_FILE %DESTINATION_DIR, +fileviewer *.7z 7z l %c + +filextype *.odt,*.doc,*.docx,*.xls,*.xlsx,*.odp,*.pptx libreoffice %f & +fileviewer *.odt odt2txt %f +fileviewer *.docx docx2txt %f - + +filetype *.tudu tudu -f %c + +filextype *.pro qtcreator %f & + +filextype */ + \ pacmanfm %f &, + +fileviewer *.md glow %c + +filetype *.xopp xournalpp %f & + diff --git a/home/programs/terminal/file-managers/vifm/config/settings/fv.vifm b/home/programs/terminal/file-managers/vifm/config/settings/fv.vifm new file mode 100644 index 0000000..969a9ea --- /dev/null +++ b/home/programs/terminal/file-managers/vifm/config/settings/fv.vifm @@ -0,0 +1,3 @@ +" vim:ft=vim + +fileviewer *.* bat --color=always --decorations=never %c diff --git a/home/programs/terminal/file-managers/vifm/config/settings/mappings.vifm b/home/programs/terminal/file-managers/vifm/config/settings/mappings.vifm new file mode 100644 index 0000000..42c1ae9 --- /dev/null +++ b/home/programs/terminal/file-managers/vifm/config/settings/mappings.vifm @@ -0,0 +1,38 @@ +" vim:ft=vim + +" Editing / Do something with the files +nnoremap cd :cd +nnoremap cD :diff +vnoremap cD :diff + +" start shell +nmap S :shell + +" Display sorting dialog +nnoremap s :sort + +" preview window +" Toggle visibility of preview window +nnoremap w :view +vnoremap w :viewgv + +" panel resize +nnoremap < 5< +nnoremap > 5> + +" tabs +nnoremap :tabnew + +" drag and drop +nmap :dragon +vmap :dragon + +" Yank current directory path into the clipboard +nnoremap yd :!echo -n %d | wl-copy %i:echo expand('%"d') "is yanked to clipboard" +" Yank current file path into the clipboard +nnoremap yf :!echo -n %c:p | wl-copy %i:echo expand('%"c:p') "is yanked to clipboard" + +nnoremap q :q + +"nnoremap ö q + diff --git a/home/programs/terminal/file-managers/vifm/config/vifmrc b/home/programs/terminal/file-managers/vifm/config/vifmrc new file mode 100644 index 0000000..c190ae5 --- /dev/null +++ b/home/programs/terminal/file-managers/vifm/config/vifmrc @@ -0,0 +1,114 @@ +" vim:ft=vim + +" editor +set vicmd="nvim" + +" This makes vifm perform file operations on its own instead of relying on +" standard utilities like `cp`. While using `cp` and alike is a more universal +" solution, it's also much slower when processing large amounts of files and +" doesn't support progress measuring. +set syscalls + +" miller view +set millerview +set milleroptions="lsize:1,csize:2,rsize:0,rpreview:all" + +set sizefmt=units:si,precision:2,space + +" The display on the bottom left +set rulerformat="%2l/%2S %[MAX: %2L%]" + +set findprg="fd %A" +set grepprg="rg -n -H %i %a %s" + +" set fillchars=vborder:│ + +" execute files +set runexec + +set tuioptions="pu" + +" controls details of file operations +set iooptions=fastfilecloning + +" Trash Directory +" The default is to move files that are deleted with dd or :d to +" the trash directory. If you change this you will not be able to move +" files by deleting them and then using p to put the file in the new location. +" I recommend not changing this until you are familiar with vifm. +" This probably shouldn't be an option. +set trash +set trashdir="~/.local/share/Trash/files" + +" This is how many directories to store in the directory history. +set history=100 + +" number of spaces of a tab" +set tabstop=4 + +" 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. +set sortnumbers + +" Maximum number of changes that can be undone. +set undolevels=100 + +" If you installed the vim.txt help file set vimhelp. +" If would rather use a plain text help file set novimhelp. +set vimhelp + +" If you would like to run an executable file when you +" press return on the file name set this. +set norunexec + +set rnu +set dotdirs= + +" colorscheme custom + +" 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.%Y\ \ %H:%M + +" Show list of matches on tab completion in command-line mode +set wildmenu +" Display completions in a form of popup with descriptions of the matches +set wildstyle=popup + +" Display suggestions in normal, visual and view modes for keys, marks and +" registers (at most 5 files). In other view, when available. +set suggestoptions=normal,visual,view,otherpane,keys,marks,registers,delay:0 + +" Ignore case in search patterns unless it contains at least one uppercase +" letter +set ignorecase +set smartcase + +" Don't highlight search results automatically +set nohlsearch + +" Use increment searching (search while typing) +set incsearch + +" Try to leave some space from cursor to upper/lower border in lists +set scrolloff=4 + +" Don't do too many requests to slow file systems +if !has('win') + set slowfs=curlftpfs +endif + +set statusline=" %A %10u:%-7g %20d Free Space: %a" + +set vifminfo=dhistory,chistory,state,tui,shistory, + \phistory,fhistory,dirstack,registers,bookmarks,bmarks + +" ------------ +" panels +" ------------ +set viewcolumns=-{name},{size} + diff --git a/home/programs/terminal/file-managers/vifm/default.nix b/home/programs/terminal/file-managers/vifm/default.nix new file mode 100644 index 0000000..24e2468 --- /dev/null +++ b/home/programs/terminal/file-managers/vifm/default.nix @@ -0,0 +1,23 @@ +{ + self, + pkgs, + ... +}: { + imports = [self.homeManagerModules.vifm]; + config = { + programs.vifm = { + enable = true; + package = pkgs.vifm-full; + config = builtins.readFile "${./config/vifmrc}"; + extraConfigFiles = [ + "${./config/settings/abbr.vifm}" + "${./config/settings/commands.vifm}" + "${./config/settings/favicons.vifm}" + "${./config/settings/ft.vifm}" + "${./config/settings/fv.vifm}" + "${./config/settings/mappings.vifm}" + ]; + }; + }; +} +