mirror of
https://github.com/alrayyes/dotfiles/
synced 2023-11-14 15:56:30 +00:00
cleaned up vifm config
This commit is contained in:
parent
41168254ff
commit
2ebb412c5e
4
.gitignore
vendored
4
.gitignore
vendored
@ -11,3 +11,7 @@ mutt/.config/mutt/.mailsynclastrun
|
||||
gtk/.config/gtk-3.0/bookmarks
|
||||
|
||||
emacs/.config/doom/configuration.el
|
||||
|
||||
# vifm
|
||||
vifm/.config/vifm/vifmimgpdffile
|
||||
vifm/.config/vifm/vifmimgpdfpage
|
||||
|
7
install
7
install
@ -64,6 +64,13 @@ end
|
||||
# Install Neovim plugins
|
||||
nvim +PlugInstall +qall
|
||||
|
||||
# Install vifm dependencies
|
||||
curl https://raw.githubusercontent.com/cirala/vifmimg/master/vifmimg --output vifm/.local/bin/vifmimg
|
||||
chmod 700 vifm/.local/bin/vifmimg
|
||||
curl https://raw.githubusercontent.com/cirala/vifmimg/master/vifmrun --output vifm/.local/bin/vifmrun
|
||||
chmod 700 vifm/.local/bin/vifmrun
|
||||
curl https://raw.githubusercontent.com/cirala/vifm_devicons/master/SETUP --output vifm/.config/vifm/SETUP
|
||||
|
||||
# Setup broot if not done already
|
||||
if [ ! -d ~/.local/share/broot ]
|
||||
broot --install
|
||||
|
71
vifm/.config/vifm/SETUP
Normal file
71
vifm/.config/vifm/SETUP
Normal file
@ -0,0 +1,71 @@
|
||||
" Ranger devicons for ViFM
|
||||
" https://github.com/cirala/vifm_devicons
|
||||
"
|
||||
" 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,,*.c,,*.cpp,,*.cxx,,*.c,,*.h::'
|
||||
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+=' ::*.vim,,*.vimrc::'
|
||||
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::'
|
||||
|
@ -1,64 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
readonly ID_PREVIEW="preview"
|
||||
|
||||
#PLAY_GIF="yes"
|
||||
# By enabling this option the GIF will be animated, by leaving it commented like it
|
||||
# is now will make the gif preview behave the same was a video preview.
|
||||
|
||||
#AUTO_REMOVE="yes"
|
||||
# By enabling this option the script will remove the preview file after it is drawn
|
||||
# and by doing so the preview will always be up-to-date with the file.
|
||||
# This however, requires more CPU and therefore affects the overall performance.
|
||||
|
||||
if [ -e "$FIFO_UEBERZUG" ]; then
|
||||
if [[ "$1" == "draw" ]]; then
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5"
|
||||
[path]="$PWD/$6") \
|
||||
>"$FIFO_UEBERZUG"
|
||||
elif [[ "$1" == "videopreview" ]]; then
|
||||
[[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/"
|
||||
[[ ! -f "/tmp$PWD/$6.png" ]] && ffmpegthumbnailer -i "$PWD/$6" -o "/tmp$PWD/$6.png" -s 0 -q 10
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5"
|
||||
[path]="/tmp$PWD/$6.png") \
|
||||
>"$FIFO_UEBERZUG"
|
||||
elif [[ "$1" == "gifpreview" ]]; then
|
||||
[[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/" && convert -coalesce "$PWD/$6" "/tmp$PWD/$6/$6.png"
|
||||
if [[ ! -z "$PLAY_GIF" ]]; then
|
||||
for frame in $(ls -1 /tmp$PWD/$6/$6*.png | sort -V); do
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5"
|
||||
[path]="$frame") \
|
||||
>"$FIFO_UEBERZUG"
|
||||
# Sleep between frames to make the animation smooth.
|
||||
sleep .07
|
||||
done
|
||||
else
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5"
|
||||
[path]="/tmp$PWD/$6/$6-0.png") \
|
||||
>"$FIFO_UEBERZUG"
|
||||
fi
|
||||
elif [[ "$1" == "epubpreview" ]]; then
|
||||
[[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/"
|
||||
[[ ! -f "/tmp$PWD/$6.png" ]] && epub-thumbnailer "$6" "/tmp$PWD/$6.png" 512
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5"
|
||||
[path]="/tmp$PWD/$6.png") \
|
||||
>"$FIFO_UEBERZUG"
|
||||
elif [[ "$1" == "pdfpreview" ]]; then
|
||||
[[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/"
|
||||
[[ ! -f "/tmp$PWD/$6.png" ]] && pdftoppm -png -singlefile "$6" "/tmp$PWD/$6"
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5"
|
||||
[path]="/tmp$PWD/$6.png") \
|
||||
>"$FIFO_UEBERZUG"
|
||||
elif [[ "$1" == "clear" ]]; then
|
||||
declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") \
|
||||
>"$FIFO_UEBERZUG"
|
||||
[[ ! -z $AUTO_REMOVE ]] && [[ -f "/tmp$PWD/$6.png" ]] && rm -f "/tmp$PWD/$6.png"
|
||||
[[ ! -z $AUTO_REMOVE ]] && [[ -d "/tmp$PWD/$6/" ]] && rm -rf "/tmp$PWD/$6/"
|
||||
|
||||
fi
|
||||
fi
|
@ -1,16 +1,6 @@
|
||||
" vim: filetype=vifm :
|
||||
" Sample configuration file for vifm (last updated: 20 July, 2018)
|
||||
" You can edit this file by hand.
|
||||
" The " character at the beginning of a line comments out the line.
|
||||
" Blank lines are ignored.
|
||||
" The basic format for each item is shown with an example.
|
||||
|
||||
" ------------------------------------------------------------------------------
|
||||
|
||||
" This is the actual command used to start vi. 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.
|
||||
|
||||
" vim alias
|
||||
set vicmd=nvim
|
||||
" set vicmd=elvis\ -G\ termcap
|
||||
" set vicmd=vile
|
||||
@ -39,11 +29,6 @@ set history=100
|
||||
|
||||
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
|
||||
|
||||
" Natural sort of (version) numbers within text.
|
||||
|
||||
set sortnumbers
|
||||
@ -96,18 +81,13 @@ set smartcase
|
||||
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 custom status line look
|
||||
|
||||
set statusline=" Hint: %z%= %A %10u:%-7g %15s %20d "
|
||||
@ -116,9 +96,8 @@ set statusline=" Hint: %z%= %A %10u:%-7g %15s %20d "
|
||||
|
||||
" :mark mark /full/directory/path [filename]
|
||||
|
||||
mark b ~/bin/
|
||||
mark h ~/
|
||||
mark s ~/.local/bin
|
||||
mark b ~/.local/bin
|
||||
mark d ~/Documents
|
||||
mark w ~/Pictures/wallpaper
|
||||
|
||||
@ -180,98 +159,42 @@ command! FZFfind :set noquickview | :execute 'goto "'.system('find | fzf --heigh
|
||||
" You can also add %CLEAR if you want to clear screen before running FUSE
|
||||
" program.
|
||||
|
||||
" Pdf
|
||||
filextype *.pdf zathura %c %i &, apvlv %c, xpdf %c
|
||||
fileviewer *.pdf
|
||||
\ vifmimg pdfpreview %px %py %pw %ph %c
|
||||
\ %pc
|
||||
\ vifmimg clear
|
||||
"\ pdftotext -nopgbrk %c -
|
||||
" Ebpub
|
||||
|
||||
fileviewer *.epub
|
||||
\ vifmimg epubpreview %px %py %pw %ph %c
|
||||
\ %pc
|
||||
\ vifmimg clear
|
||||
|
||||
" PostScript
|
||||
filextype *.ps,*.eps,*.ps.gz
|
||||
\ {View in zathura}
|
||||
\ zathura %f,
|
||||
\ {View in gv}
|
||||
\ gv %c %i &,
|
||||
|
||||
" Djvu
|
||||
filextype *.djvu
|
||||
\ {View in zathura}
|
||||
\ zathura %f,
|
||||
\ {View in apvlv}
|
||||
\ apvlv %f,
|
||||
|
||||
" Audio
|
||||
filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus
|
||||
\ {Play using ffplay}
|
||||
\ ffplay -nodisp -autoexit %c,
|
||||
\ {Play using MPlayer}
|
||||
\ mplayer %f,
|
||||
fileviewer *.mp3 mp3info
|
||||
fileviewer *.flac soxi
|
||||
|
||||
" 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]
|
||||
\ {View using mpv}
|
||||
\ mpv %c %i &,
|
||||
fileviewer *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
|
||||
\*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,
|
||||
\*.as[fx]
|
||||
\ vifmimg videopreview %px %py %pw %ph %c
|
||||
\ %pc
|
||||
\ vifmimg clear
|
||||
" \ ffprobe -pretty %c 2>&1
|
||||
|
||||
" Web
|
||||
filextype *.html,*.htm
|
||||
\ {Open with surf}
|
||||
\ surf %f &,
|
||||
\ {Open with firefox}
|
||||
\ firefox %f &,
|
||||
filetype *.html,*.htm w3m
|
||||
|
||||
" Object
|
||||
filetype *.o nm %f | less
|
||||
|
||||
" Man page
|
||||
filetype *.[1-8] man ./%c
|
||||
fileviewer *.[1-8] man ./%c | col -b
|
||||
|
||||
" Images
|
||||
filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
|
||||
\ {View in sxiv}
|
||||
\ sxiv -a %f,
|
||||
\ {View in gpicview}
|
||||
\ gpicview %c,
|
||||
\ {View in shotwell}
|
||||
\ shotwell,
|
||||
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.xpm,*.webp
|
||||
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.xpm
|
||||
\ vifmimg draw %px %py %pw %ph %c
|
||||
\ %pc
|
||||
\ vifmimg clear
|
||||
" \ convert -identify %f -verbose /dev/null
|
||||
|
||||
fileviewer *.gif
|
||||
\ vifmimg gifpreview %px %py %pw %ph %c
|
||||
\ %pc
|
||||
\ vifmimg clear
|
||||
|
||||
" OpenRaster
|
||||
filextype *.ora
|
||||
\ {Edit in MyPaint}
|
||||
\ mypaint %f,
|
||||
fileviewer *.ico
|
||||
\ vifmimg magickpreview %px %py %pw %ph %c
|
||||
\ %pc
|
||||
\ vifmimg clear
|
||||
fileviewer *.mp3 mp3info
|
||||
fileviewer *.flac soxi
|
||||
|
||||
" Mindmap
|
||||
filextype *.vym
|
||||
\ {Open with VYM}
|
||||
\ vym %f &,
|
||||
" Man page
|
||||
filetype *.[1-8] man ./%c
|
||||
fileviewer *.[1-8] man ./%c | col -b
|
||||
|
||||
" MD5
|
||||
filetype *.md5
|
||||
@ -298,10 +221,6 @@ filetype *.asc
|
||||
\ {Check signature}
|
||||
\ !!gpg --verify %c,
|
||||
|
||||
" Torrent
|
||||
filetype *.torrent ktorrent %f &
|
||||
fileviewer *.torrent dumptorrent -v %c
|
||||
|
||||
" FuseZipMount
|
||||
filetype *.zip,*.jar,*.war,*.ear,*.oxt,*.apkg
|
||||
\ {Mount with fuse-zip}
|
||||
@ -354,17 +273,6 @@ fileviewer *.doc catdoc %c
|
||||
fileviewer *.docx docx2txt.pl %f -
|
||||
fileviewer *.odt,*.ods,*.odp,*.sxw odt2txt %c
|
||||
|
||||
" TuDu files
|
||||
filetype *.tudu tudu -f %c
|
||||
|
||||
" Qt projects
|
||||
filextype *.pro qtcreator %f &
|
||||
|
||||
" Directories
|
||||
filextype */
|
||||
\ {View in thunar}
|
||||
\ Thunar %f &,
|
||||
|
||||
" Syntax highlighting in preview
|
||||
"
|
||||
" Explicitly set highlight type for some extensions
|
||||
@ -390,26 +298,7 @@ filextype */
|
||||
" 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
|
||||
|
||||
" 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::'
|
||||
filetype * gio open
|
||||
|
||||
" ------------------------------------------------------------------------------
|
||||
|
||||
@ -526,3 +415,10 @@ nnoremap <c-f> :FZFfind<cr>
|
||||
" vifm --server-name "$VIFM_SERVER_NAME" --remote +"cd '$PWD'"
|
||||
"
|
||||
" let $VIFM_SERVER_NAME = v:servername
|
||||
|
||||
" pdf review keybindings
|
||||
map > :!vifmimg inc<CR>
|
||||
map < :!vifmimg dec<CR>
|
||||
|
||||
" load devicons
|
||||
source ~/.config/vifm//SETUP
|
||||
|
154
vifm/.local/bin/vifmimg
Executable file
154
vifm/.local/bin/vifmimg
Executable file
@ -0,0 +1,154 @@
|
||||
#!/usr/bin/env bash
|
||||
readonly ID_PREVIEW="preview"
|
||||
|
||||
#PLAY_GIF="yes"
|
||||
# By enabling this option the GIF will be animated, by leaving it commented like it
|
||||
# is now will make the gif previews behave the same way as video previews.
|
||||
|
||||
#AUTO_REMOVE="yes"
|
||||
# By enabling this option the script will remove the preview file after it is drawn
|
||||
# and by doing so the preview will always be up-to-date with the file.
|
||||
# This however, requires more CPU and therefore affects the overall performance.
|
||||
|
||||
# The messy code below is for moving pages in pdf files in the vifm file preview by
|
||||
# utilizing the < and > keys which will be bound to `vifmimg inc` or `vifmimg dec`.
|
||||
PDF_PAGE_CONFIG="$HOME/.config/vifm/vifmimgpdfpage"
|
||||
PDF_FILE_CONFIG="$HOME/.config/vifm/vifmimgpdffile"
|
||||
PDF_PAGE=1
|
||||
PDF_FILE=""
|
||||
# Initialize the variables and required files
|
||||
[[ -f "$PDF_PAGE_CONFIG" ]] && PDF_PAGE=$(cat $PDF_PAGE_CONFIG) || touch $PDF_PAGE_CONFIG
|
||||
[[ -f "$PDF_FILE_CONFIG" ]] && PDF_FILE=$(cat $PDF_FILE_CONFIG) || touch $PDF_FILE_CONFIG
|
||||
|
||||
|
||||
# Create temporary working directory if the directory structure doesn't exist
|
||||
if [[ ! -d "/tmp$PWD/" ]]; then
|
||||
mkdir -p "/tmp$PWD/"
|
||||
fi
|
||||
|
||||
function inc() {
|
||||
VAL="$(cat $PDF_PAGE_CONFIG)"
|
||||
echo "$(expr $VAL + 1)" > $PDF_PAGE_CONFIG
|
||||
}
|
||||
|
||||
function dec() {
|
||||
VAL="$(cat $PDF_PAGE_CONFIG)"
|
||||
echo "$(expr $VAL - 1)" > $PDF_PAGE_CONFIG
|
||||
if [[ $VAL -le 0 ]]; then
|
||||
echo 0 > $PDF_PAGE_CONFIG
|
||||
fi
|
||||
}
|
||||
|
||||
function previewclear() {
|
||||
declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") \
|
||||
> "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
function fileclean() {
|
||||
if [[ -f "/tmp$PWD/$6.png" ]]; then
|
||||
rm -f "/tmp$PWD/$6.png"
|
||||
elif [[ -d "/tmp$PWD/$6/" ]]; then
|
||||
rm -rf "/tmp$PWD/$6/"
|
||||
fi
|
||||
}
|
||||
|
||||
function preview() {
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||
[path]="$PWD/$6") \
|
||||
> "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
function previewvideo() {
|
||||
if [[ ! -f "/tmp$PWD/$6.png" ]]; then
|
||||
ffmpegthumbnailer -i "$PWD/$6" -o "/tmp$PWD/$6.png" -s 0 -q 10
|
||||
fi
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||
[path]="/tmp$PWD/$6.png") \
|
||||
> "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
function previewepub() {
|
||||
if [[ ! -f "/tmp$PWD/$6.png" ]]; then
|
||||
epub-thumbnailer "$6" "/tmp$PWD/$6.png" 1024
|
||||
fi
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||
[path]="/tmp$PWD/$6.png") \
|
||||
> "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
function previewgif() {
|
||||
if [[ ! -d "/tmp$PWD/$6/" ]]; then
|
||||
mkdir -p "/tmp$PWD/$6/"
|
||||
convert -coalesce "$PWD/$6" "/tmp$PWD/$6/$6.png"
|
||||
fi
|
||||
if [[ ! -z "$PLAY_GIF" ]]; then
|
||||
for frame in $(ls -1 /tmp$PWD/$6/$6*.png | sort -V); do
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||
[path]="$frame") \
|
||||
> "$FIFO_UEBERZUG"
|
||||
# Sleep between frames to make the animation smooth.
|
||||
sleep .07
|
||||
done
|
||||
else
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||
[path]="/tmp$PWD/$6/$6-0.png") \
|
||||
> "$FIFO_UEBERZUG"
|
||||
fi
|
||||
}
|
||||
|
||||
function previewpdf() {
|
||||
if [[ ! "$6" == "$PDF_FILE" ]]; then
|
||||
PDF_PAGE=1
|
||||
echo 1 > $PDF_PAGE_CONFIG
|
||||
rm -f "/tmp$PWD/$6.png"
|
||||
fi
|
||||
|
||||
if [[ ! "$PDF_PAGE" == "1" ]] && [[ -f "/tmp$PWD/$6.png" ]]; then
|
||||
rm -f "/tmp$PWD/$6.png"
|
||||
fi
|
||||
|
||||
if [[ ! -f "/tmp$PWD/$6.png" ]]; then
|
||||
pdftoppm -png -f $PDF_PAGE -singlefile "$6" "/tmp$PWD/$6"
|
||||
fi
|
||||
echo "$6" > $PDF_FILE_CONFIG
|
||||
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||
[path]="/tmp$PWD/$6.png") \
|
||||
> "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
|
||||
function previewmagick() {
|
||||
if [[ ! -f "/tmp$PWD/$6.png" ]]; then
|
||||
convert -thumbnail $(identify -format "%wx%h" "$6") "$PWD/$6" "/tmp$PWD/$6.png"
|
||||
fi
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||
[path]="/tmp$PWD/$6.png") \
|
||||
> "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
|
||||
|
||||
function main() {
|
||||
case "$1" in
|
||||
"inc") inc "$@" ;;
|
||||
"dec") dec "$@" ;;
|
||||
"clear") previewclear "$@" ;;
|
||||
"clean") fileclean "$@" ;;
|
||||
"draw") preview "$@" ;;
|
||||
"videopreview") previewvideo "$@" ;;
|
||||
"epubpreview") previewepub "$@" ;;
|
||||
"gifpreview") previewgif "$@" ;;
|
||||
"pdfpreview") previewpdf "$@" ;;
|
||||
"magickpreview") previewmagick "$@" ;;
|
||||
"*") echo "Unknown command: '$@'" ;;
|
||||
esac
|
||||
}
|
||||
main "$@"
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env bash
|
||||
export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}"
|
||||
|
||||
function cleanup() {
|
||||
function cleanup {
|
||||
rm "$FIFO_UEBERZUG" 2>/dev/null
|
||||
pkill -P $$ 2>/dev/null
|
||||
}
|
||||
@ -11,5 +11,5 @@ mkfifo "$FIFO_UEBERZUG" >/dev/null
|
||||
trap cleanup EXIT 2>/dev/null
|
||||
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash 2>&1 >/dev/null &
|
||||
|
||||
/usr/bin/vifm
|
||||
vifm
|
||||
cleanup
|
||||
|
Loading…
Reference in New Issue
Block a user