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
|
||||
wpa_supplicant_gui
|
||||
pcmanfm
|
||||
xdg-utils
|
||||
|
||||
# graphics
|
||||
evince
|
||||
gimp
|
||||
mpv
|
||||
ffmpeg
|
||||
|
||||
# sound
|
||||
pavucontrol
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
{ 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/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 :
|
||||
|
||||
|
||||
" 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=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
|
||||
|
||||
" Trash Directory
|
||||
set trash
|
||||
|
||||
" This is how many directories to store in the directory history.
|
||||
set history=100
|
||||
|
||||
" 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
|
||||
" unambiguous beginning using :! (e.g. :!Te instead of :!Terminal or :!Te<tab>).
|
||||
" set fastrun
|
||||
set fastrun
|
||||
|
||||
" Natural sort of (version) numbers within text.
|
||||
set sortnumbers
|
||||
|
@ -41,27 +29,14 @@ set vimhelp
|
|||
" press return on the file name set this.
|
||||
set norunexec
|
||||
|
||||
" Selected color scheme
|
||||
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
|
||||
|
||||
" 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
|
||||
|
||||
" Ignore case in search patterns unless it contains at least one uppercase
|
||||
" letter
|
||||
set ignorecase
|
||||
set smartcase
|
||||
|
||||
|
@ -112,63 +87,10 @@ command! mkcd :mkdir %a | cd %a
|
|||
command! vgrep vim "+grep %a"
|
||||
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
|
||||
filetype *.[1-8] man ./%c
|
||||
fileviewer *.[1-8] man ./%c | col -b
|
||||
|
||||
" Images
|
||||
filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
|
||||
\ {View in okular}
|
||||
\ okular,
|
||||
|
||||
" MD5
|
||||
filetype *.md5
|
||||
\ {Check MD5 hash sum}
|
||||
|
@ -195,7 +117,7 @@ filetype *.asc
|
|||
\ !!gpg --verify %c,
|
||||
|
||||
" Torrent
|
||||
filetype *.torrent ktorrent %f &
|
||||
filetype *.torrent transmission-gtk %f &
|
||||
fileviewer *.torrent dumptorrent -v %c
|
||||
|
||||
" FuseZipMount
|
||||
|
@ -249,57 +171,37 @@ filextype *.odt,*.doc,*.docx,*.xls,*.xlsx,*.odp,*.pptx libreoffice %f &
|
|||
fileviewer *.doc catdoc %c
|
||||
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
|
||||
"
|
||||
" fileviewer *.jpg,*.png shellpic %c
|
||||
fileviewer *.pdf
|
||||
\ vifm-sixel pdf %pw %ph %c %pd
|
||||
\ %pc
|
||||
\ vifm-sixel clear
|
||||
|
||||
" Open all other files with default system programs (you can also remove all
|
||||
" :file[x]type commands above to ensure they don't interfere with system-wide
|
||||
" settings). By default all unknown files are opened with 'vi[x]cmd'
|
||||
" uncommenting one of lines below will result in ignoring 'vi[x]cmd' option
|
||||
" for unknown file types.
|
||||
" For *nix:
|
||||
" filetype * xdg-open
|
||||
" For OS X:
|
||||
" filetype * open
|
||||
" For Windows:
|
||||
" filetype * start, explorer
|
||||
fileviewer *.epub
|
||||
\ vifm-sixel epub %pw %ph %c %pd
|
||||
\ %pc
|
||||
\ vifm-sixel clear
|
||||
|
||||
" ------------------------------------------------------------------------------
|
||||
fileviewer <video/*>
|
||||
\ vifm-sixel video %pw %ph %c %pd
|
||||
\ %pc
|
||||
\ vifm-sixel clear
|
||||
|
||||
" What should be saved automatically between vifm sessions. Drop "savedirs"
|
||||
" value if you don't want vifm to remember last visited directories for you.
|
||||
set vifminfo=dhistory,savedirs,chistory,state,tui,shistory,
|
||||
\phistory,fhistory,dirstack,registers,bookmarks,bmarks
|
||||
fileviewer <image/*>
|
||||
\ vifm-sixel draw %pw %ph %c %pd
|
||||
\ %pc
|
||||
\ 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
|
||||
"
|
||||
" filter! /^.*\.(lo|o|d|class|py[co])$|.*~$/
|
||||
|
||||
" ------------------------------------------------------------------------------
|
||||
filetype * xdg-open
|
||||
|
||||
" Better quit command"
|
||||
command Q :q
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
enable = true;
|
||||
shellAliases = {
|
||||
rm = "trash";
|
||||
vifm = "vifm .";
|
||||
};
|
||||
history = {
|
||||
size = 10000;
|
||||
|
|
Loading…
Reference in a new issue