mirror of
https://git.sr.ht/~rouven/nixos-config
synced 2024-11-15 05:13:10 +01:00
set up vifm image preview
This commit is contained in:
parent
0e77ba38e0
commit
4127926e06
|
@ -4,11 +4,13 @@
|
||||||
# essentials
|
# essentials
|
||||||
wpa_supplicant_gui
|
wpa_supplicant_gui
|
||||||
pcmanfm
|
pcmanfm
|
||||||
|
xdg-utils
|
||||||
|
|
||||||
# graphics
|
# graphics
|
||||||
evince
|
evince
|
||||||
gimp
|
gimp
|
||||||
mpv
|
mpv
|
||||||
|
ffmpeg
|
||||||
|
|
||||||
# sound
|
# sound
|
||||||
pavucontrol
|
pavucontrol
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{
|
{
|
||||||
home.packages = with pkgs; [ vifm ];
|
home.packages = with pkgs; [
|
||||||
|
vifm
|
||||||
|
ffmpegthumbnailer
|
||||||
|
dumptorrent
|
||||||
|
poppler_utils
|
||||||
|
fontpreview
|
||||||
|
];
|
||||||
xdg.configFile."vifm/vifmrc".source = ./vifmrc;
|
xdg.configFile."vifm/vifmrc".source = ./vifmrc;
|
||||||
xdg.configFile."vifm/colors/dracula.vifm".source = ./dracula.vifm;
|
xdg.configFile."vifm/colors/dracula.vifm".source = ./dracula.vifm;
|
||||||
|
xdg.configFile."vifm/scripts/vifm-sixel" = {
|
||||||
|
executable = true;
|
||||||
|
source = ./vifm-sixel;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
55
users/rouven/modules/vifm/vifm-sixel
Normal file
55
users/rouven/modules/vifm/vifm-sixel
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/run/current-system/sw/bin/bash
|
||||||
|
|
||||||
|
[ -d "$HOME/.cache/vifm" ] || mkdir -p "$HOME/.cache/vifm"
|
||||||
|
|
||||||
|
# $1 action
|
||||||
|
action="$1"
|
||||||
|
# $2 panel width
|
||||||
|
# $3 panel height
|
||||||
|
panel_width=$2
|
||||||
|
panel_height=$3
|
||||||
|
cell_width=10
|
||||||
|
cell_height=18
|
||||||
|
width=$((panel_width*cell_width))
|
||||||
|
height=$((panel_height*cell_height))
|
||||||
|
# $4 image path
|
||||||
|
image_file="$4"
|
||||||
|
background=black
|
||||||
|
|
||||||
|
PCACHE="$HOME/.cache/vifm/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$PWD/$image_file")" | sha256sum | awk '{print $1}')"
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
printf '\33[s\33[5A\33[2K\33[u'
|
||||||
|
clear
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$action" in
|
||||||
|
"clear")
|
||||||
|
cleanup
|
||||||
|
;;
|
||||||
|
"draw")
|
||||||
|
img2sixel -S --width=$width $image_file
|
||||||
|
;;
|
||||||
|
"video")
|
||||||
|
[ ! -f "${PCACHE}.jpg" ] && \
|
||||||
|
ffmpegthumbnailer -i "$4" -o "${PCACHE}.jpg" -s 0 -q 5
|
||||||
|
img2sixel --width=$width ${PCACHE}.jpg
|
||||||
|
;;
|
||||||
|
"epub")
|
||||||
|
[ ! -f "${PCACHE}.jpg" ] && \
|
||||||
|
epub-thumbnailer "$image_file" "$PCACHE" 1024
|
||||||
|
img2sixel --width=$width --height=$height ${PCACHE}.jpg
|
||||||
|
;;
|
||||||
|
"pdf")
|
||||||
|
[ ! -f "${PCACHE}.jpg" ] && \
|
||||||
|
pdftoppm -jpeg -f 1 -singlefile "$image_file" "$PCACHE"
|
||||||
|
img2sixel --height=$height ${PCACHE}.jpg
|
||||||
|
;;
|
||||||
|
"font")
|
||||||
|
[ ! -f "${PCACHE}.jpg" ] && \
|
||||||
|
fontpreview -i "$image_file" -o "${PCACHE}.jpg"
|
||||||
|
img2sixel --width=$width --height=$height ${PCACHE}.jpg
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
esac
|
|
@ -1,24 +1,12 @@
|
||||||
" vim: filetype=vifm :
|
" vim: filetype=vifm :
|
||||||
|
|
||||||
|
|
||||||
" Command used to edit files in various contexts. The default is vim.
|
|
||||||
" If you would like to use another vi clone such as Elvis or Vile
|
|
||||||
" you will need to change this setting.
|
|
||||||
|
|
||||||
set vicmd=nvim
|
set vicmd=nvim
|
||||||
" set vicmd=elvis\ -G\ termcap
|
|
||||||
" set vicmd=vile
|
|
||||||
|
|
||||||
" 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
|
set syscalls
|
||||||
|
|
||||||
" Trash Directory
|
" Trash Directory
|
||||||
set trash
|
set trash
|
||||||
|
|
||||||
" This is how many directories to store in the directory history.
|
|
||||||
set history=100
|
set history=100
|
||||||
|
|
||||||
" Automatically resolve symbolic links on l or Enter.
|
" Automatically resolve symbolic links on l or Enter.
|
||||||
|
@ -26,7 +14,7 @@ set nofollowlinks
|
||||||
|
|
||||||
" With this option turned on you can run partially entered commands with
|
" With this option turned on you can run partially entered commands with
|
||||||
" unambiguous beginning using :! (e.g. :!Te instead of :!Terminal or :!Te<tab>).
|
" unambiguous beginning using :! (e.g. :!Te instead of :!Terminal or :!Te<tab>).
|
||||||
" set fastrun
|
set fastrun
|
||||||
|
|
||||||
" Natural sort of (version) numbers within text.
|
" Natural sort of (version) numbers within text.
|
||||||
set sortnumbers
|
set sortnumbers
|
||||||
|
@ -41,27 +29,14 @@ set vimhelp
|
||||||
" press return on the file name set this.
|
" press return on the file name set this.
|
||||||
set norunexec
|
set norunexec
|
||||||
|
|
||||||
" Selected color scheme
|
|
||||||
colorscheme dracula
|
colorscheme dracula
|
||||||
|
|
||||||
" 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=%m/%d\ %H:%M
|
set timefmt=%m/%d\ %H:%M
|
||||||
|
|
||||||
" Show list of matches on tab completion in command-line mode
|
|
||||||
set wildmenu
|
set wildmenu
|
||||||
|
|
||||||
" Display completions in a form of popup with descriptions of the matches
|
|
||||||
set wildstyle=popup
|
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
|
set suggestoptions=normal,visual,view,otherpane,keys,marks,registers
|
||||||
|
|
||||||
" Ignore case in search patterns unless it contains at least one uppercase
|
|
||||||
" letter
|
|
||||||
set ignorecase
|
set ignorecase
|
||||||
set smartcase
|
set smartcase
|
||||||
|
|
||||||
|
@ -112,63 +87,10 @@ command! mkcd :mkdir %a | cd %a
|
||||||
command! vgrep vim "+grep %a"
|
command! vgrep vim "+grep %a"
|
||||||
command! reload :write | restart
|
command! reload :write | restart
|
||||||
|
|
||||||
" ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
" The file type is for the default programs to be used with
|
|
||||||
" a file extension.
|
|
||||||
" :filetype pattern1,pattern2 defaultprogram,program2
|
|
||||||
" :fileviewer pattern1,pattern2 consoleviewer
|
|
||||||
" The other programs for the file type can be accessed with the :file command
|
|
||||||
" The command macros %f, %F, %d, %F may be used in the commands.
|
|
||||||
" The %a macro is ignored. To use a % you must put %%.
|
|
||||||
|
|
||||||
" For automated FUSE mounts, you must register an extension with :file[x]type
|
|
||||||
" in one of following formats:
|
|
||||||
"
|
|
||||||
" :filetype extensions FUSE_MOUNT|some_mount_command using %SOURCE_FILE and %DESTINATION_DIR variables
|
|
||||||
" %SOURCE_FILE and %DESTINATION_DIR are filled in by vifm at runtime.
|
|
||||||
" A sample line might look like this:
|
|
||||||
" :filetype *.zip,*.jar,*.war,*.ear FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR
|
|
||||||
"
|
|
||||||
" :filetype extensions FUSE_MOUNT2|some_mount_command using %PARAM and %DESTINATION_DIR variables
|
|
||||||
" %PARAM and %DESTINATION_DIR are filled in by vifm at runtime.
|
|
||||||
" A sample line might look like this:
|
|
||||||
" :filetype *.ssh FUSE_MOUNT2|sshfs %PARAM %DESTINATION_DIR
|
|
||||||
" %PARAM value is filled from the first line of file (whole line).
|
|
||||||
" Example first line for SshMount filetype: root@127.0.0.1:/
|
|
||||||
"
|
|
||||||
" You can also add %CLEAR if you want to clear screen before running FUSE
|
|
||||||
" program.
|
|
||||||
|
|
||||||
" Pdf
|
|
||||||
filextype *.pdf evince
|
|
||||||
|
|
||||||
" Audio
|
|
||||||
filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus
|
|
||||||
\ {Play using VLC}
|
|
||||||
\ vlc,
|
|
||||||
|
|
||||||
" Video
|
|
||||||
filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
|
|
||||||
\*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,
|
|
||||||
\*.as[fx]
|
|
||||||
\ {Play using VLC}
|
|
||||||
\ vlc,
|
|
||||||
|
|
||||||
" Web
|
|
||||||
filextype *.html,*.htm
|
|
||||||
\ {Open with firefox}
|
|
||||||
\ firefox %f &,
|
|
||||||
|
|
||||||
" Man page
|
" Man page
|
||||||
filetype *.[1-8] man ./%c
|
filetype *.[1-8] man ./%c
|
||||||
fileviewer *.[1-8] man ./%c | col -b
|
fileviewer *.[1-8] man ./%c | col -b
|
||||||
|
|
||||||
" Images
|
|
||||||
filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
|
|
||||||
\ {View in okular}
|
|
||||||
\ okular,
|
|
||||||
|
|
||||||
" MD5
|
" MD5
|
||||||
filetype *.md5
|
filetype *.md5
|
||||||
\ {Check MD5 hash sum}
|
\ {Check MD5 hash sum}
|
||||||
|
@ -195,7 +117,7 @@ filetype *.asc
|
||||||
\ !!gpg --verify %c,
|
\ !!gpg --verify %c,
|
||||||
|
|
||||||
" Torrent
|
" Torrent
|
||||||
filetype *.torrent ktorrent %f &
|
filetype *.torrent transmission-gtk %f &
|
||||||
fileviewer *.torrent dumptorrent -v %c
|
fileviewer *.torrent dumptorrent -v %c
|
||||||
|
|
||||||
" FuseZipMount
|
" FuseZipMount
|
||||||
|
@ -249,57 +171,37 @@ filextype *.odt,*.doc,*.docx,*.xls,*.xlsx,*.odp,*.pptx libreoffice %f &
|
||||||
fileviewer *.doc catdoc %c
|
fileviewer *.doc catdoc %c
|
||||||
fileviewer *.docx docx2txt.pl %f -
|
fileviewer *.docx docx2txt.pl %f -
|
||||||
|
|
||||||
" Syntax highlighting in preview
|
|
||||||
"
|
|
||||||
" Explicitly set highlight type for some extensions
|
|
||||||
"
|
|
||||||
" 256-color terminal
|
|
||||||
" fileviewer *.[ch],*.[ch]pp highlight -O xterm256 -s dante --syntax c %c
|
|
||||||
" fileviewer Makefile,Makefile.* highlight -O xterm256 -s dante --syntax make %c
|
|
||||||
"
|
|
||||||
" 16-color terminal
|
|
||||||
" fileviewer *.c,*.h highlight -O ansi -s dante %c
|
|
||||||
"
|
|
||||||
" Or leave it for automatic detection
|
|
||||||
"
|
|
||||||
" fileviewer *[^/] pygmentize -O style=monokai -f console256 -g
|
|
||||||
|
|
||||||
" Displaying pictures in terminal
|
" Displaying pictures in terminal
|
||||||
"
|
fileviewer *.pdf
|
||||||
" fileviewer *.jpg,*.png shellpic %c
|
\ vifm-sixel pdf %pw %ph %c %pd
|
||||||
|
\ %pc
|
||||||
|
\ vifm-sixel clear
|
||||||
|
|
||||||
" Open all other files with default system programs (you can also remove all
|
fileviewer *.epub
|
||||||
" :file[x]type commands above to ensure they don't interfere with system-wide
|
\ vifm-sixel epub %pw %ph %c %pd
|
||||||
" settings). By default all unknown files are opened with 'vi[x]cmd'
|
\ %pc
|
||||||
" uncommenting one of lines below will result in ignoring 'vi[x]cmd' option
|
\ vifm-sixel clear
|
||||||
" for unknown file types.
|
|
||||||
" For *nix:
|
|
||||||
" filetype * xdg-open
|
|
||||||
" For OS X:
|
|
||||||
" filetype * open
|
|
||||||
" For Windows:
|
|
||||||
" filetype * start, explorer
|
|
||||||
|
|
||||||
" ------------------------------------------------------------------------------
|
fileviewer <video/*>
|
||||||
|
\ vifm-sixel video %pw %ph %c %pd
|
||||||
|
\ %pc
|
||||||
|
\ vifm-sixel clear
|
||||||
|
|
||||||
" What should be saved automatically between vifm sessions. Drop "savedirs"
|
fileviewer <image/*>
|
||||||
" value if you don't want vifm to remember last visited directories for you.
|
\ vifm-sixel draw %pw %ph %c %pd
|
||||||
set vifminfo=dhistory,savedirs,chistory,state,tui,shistory,
|
\ %pc
|
||||||
\phistory,fhistory,dirstack,registers,bookmarks,bmarks
|
\ vifm-sixel clear
|
||||||
|
|
||||||
" ------------------------------------------------------------------------------
|
fileviewer <audio/*>
|
||||||
|
\ ffmpeg -i %c -hide_banner -f null /dev/null
|
||||||
|
|
||||||
" Examples of configuring both panels
|
fileviewer <font/*>
|
||||||
|
\ vifm-sixel font %pw %ph %c %pd
|
||||||
|
\ %pc
|
||||||
|
\ vifm-sixel clear
|
||||||
|
|
||||||
" Customize view columns a bit (enable ellipsis for truncated file names)
|
|
||||||
"
|
|
||||||
" set viewcolumns=-{name}..,6{}.
|
|
||||||
|
|
||||||
" Filter-out build and temporary files
|
filetype * xdg-open
|
||||||
"
|
|
||||||
" filter! /^.*\.(lo|o|d|class|py[co])$|.*~$/
|
|
||||||
|
|
||||||
" ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
" Better quit command"
|
" Better quit command"
|
||||||
command Q :q
|
command Q :q
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
shellAliases = {
|
shellAliases = {
|
||||||
rm = "trash";
|
rm = "trash";
|
||||||
vifm = "vifm .";
|
|
||||||
};
|
};
|
||||||
history = {
|
history = {
|
||||||
size = 10000;
|
size = 10000;
|
||||||
|
|
Loading…
Reference in a new issue