Lots of changes in vifm and sxiv configs

This commit is contained in:
Wiktor Zykubek 2020-05-16 17:49:43 +02:00
parent 9f546de3cc
commit 837e0c857d
9 changed files with 144 additions and 64 deletions

View File

@ -3,6 +3,7 @@
"==============
" Leader key
let mapleader = ' '
let g:move_key_modifier = 'A'
"~~~~~
" Git

View File

@ -7,7 +7,8 @@ alias \
v='nvim' \
vi='nvim' \
vim='nvim' \
suvi='sudo -E nvim'
suvi='sudo -E nvim' \
vifm='vifmrun'
alias \
l='ls' \

View File

@ -3,6 +3,19 @@
while read -r file
do
case "$1" in
"w") setwall "$file" &;;
"w")
setwall "$file" & ;;
"y")
readlink -f "$file" | xclip -selection clipboard &&
notify-send "\"$file\" copied to clipboard" & ;;
"Y")
xclip -selection clipboard -t image/png < $(readlink -f "$file") &&
notify-send -i "$(readlink -f "$file")" "copied to clipboard" & ;;
"d")
[ "$(printf "No\\nYes" | \
rofi -dmenu -i -l 2 -p "Really delete $file?")" = "Yes" ] &&
rm "$file" && notify-send "\"$file\" deleted." ;;
"g")
isinstalled gimp && pkill sxiv && gimp "$file" & ;;
esac
done

View File

@ -13,16 +13,16 @@ hi clear
hi Win ctermfg=white ctermbg=none cterm=none
hi Directory ctermfg=blue ctermbg=default cterm=bold
hi Link ctermfg=cyan ctermbg=default cterm=none
hi Link ctermfg=cyan ctermbg=default
hi BrokenLink ctermfg=red ctermbg=default cterm=bold
hi Socket ctermfg=magenta ctermbg=default cterm=bold
hi Device ctermfg=red ctermbg=default cterm=bold
hi Fifo ctermfg=red ctermbg=default cterm=bold
hi Executable ctermfg=green ctermbg=default cterm=bold
hi Selected ctermfg=black ctermbg=8 cterm=bold
hi CurrLine ctermfg=8 ctermbg=white cterm=bold,reverse
hi Selected ctermfg=192 ctermbg=234 cterm=italic
hi CurrLine ctermfg=8 ctermbg=191 cterm=bold,reverse
hi OtherLine ctermfg=191 ctermbg=none
hi TopLine ctermfg=none ctermbg=none cterm=none
hi OtherLine ctermfg=7 ctermbg=none
hi TopLineSel ctermfg=white ctermbg=none cterm=bold
hi StatusLine ctermfg=4 ctermbg=none cterm=none
hi WildMenu ctermfg=4 ctermbg=black cterm=reverse
@ -36,6 +36,9 @@ hi AuxWin ctermfg=default ctermbg=default cterm=none,underline,reverse
hi TabLine ctermfg=9 ctermbg=0 cterm=none
hi TabLineSel ctermfg=default ctermbg=default cterm=none,reverse
hi /^.*\.(mp3|ogg|oga|flac|m4a)$/ ctermfg=magenta
hi /^.*\.(jpg|jpeg|png|gif|tiff|webp|bmp|svg|svgz)$/ ctermfg=yellow
hi /^.*\.(zip|gz|bz2|xz|tar|tgz|tbz2|7z|rar|iso|rpm|deb)$/ ctermfg=red
hi /^.*\.(mp3|ogg|oga|flac|m4a)$/ ctermfg=13
hi /^.*\.(flv|mp4|webm|mkv)$/ ctermfg=13
hi /^.*\.(jpg|jpeg|png|gif|tiff|webp|bmp|svg|svgz)$/ ctermfg=11
hi /^.*\.(zip|gz|bz2|lz4|xz|tar|tgz|tbz2|7z|rar|iso|rpm|deb)$/ ctermfg=167 cterm=bold
hi /^.*\.(docx|odt|pptx|odp)$/ ctermfg=60
hi /^.*\.(pdf)$/ ctermfg=61

View File

@ -38,21 +38,20 @@ mark b ~/bin/
mark h ~/
" Sample mappings
unmap u
nnoremap ` :cd ~<cr>
nnoremap ~ :cd ~<cr>
nnoremap S :shell<cr>
nnoremap S :source ~/.config/vifm/vifmrc; source ~/.config/vifm/colors/biual.vifm<cr>
nnoremap q :q<cr>
nnoremap s :select<cr>
nnoremap u :unselect<cr>
nnoremap w :view<cr>
vnoremap w :view<cr>gv
nnoremap cc cw<c-u>
nnoremap I za<c-u>
nnoremap <C-A-j> <C-w><C-j>
nnoremap <C-A-k> <C-w><C-k>
nnoremap <C-A-l> <C-w><C-l>
nnoremap <C-A-h> <C-w><C-h>
nnoremap x :!sxiv -btf *<Cr>
unmap Y
nnoremap Y :!xclip -selection clipboard -t image/png < %c<cr>:echo expand('%"c:p') "is copied to clipboard"<cr>
" ------------------------------------------------------------------------------
@ -170,16 +169,8 @@ filetype *.[1-8] man ./%c
fileviewer *.[1-8] man ./%c | col -b
" Images
filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
\ {View in feh}
\ sxiv -b -f
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
\ gimp %f
" OpenRaster
filextype *.ora
\ {Edit in MyPaint}
\ mypaint %f,
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.ico,*.gif,*.xpm vifmimg draw %px %py %pw %ph %c %pc vifmimg clear
filextype *.bmp,*.jpg,*.jpeg,*.png,*.ico,*.gif,*.xpm sxiv -fb 2>/dev/null &
" Mindmap
filextype *.vym
@ -212,8 +203,7 @@ filetype *.asc
\ !!gpg --verify %c,
" Torrent
filetype *.torrent ktorrent %f &
fileviewer *.torrent dumptorrent -v %c
filetype *.torrent torradd %f &
" FuseZipMount
filetype *.zip,*.jar,*.war,*.ear,*.oxt,*.apkg
@ -262,22 +252,17 @@ filetype *.7z
fileviewer *.7z 7z l %c
" Office files
filextype *.odt,*.doc,*.docx,*.xls,*.xlsx,*.odp,*.pptx libreoffice %f &
filextype *.odt,*.doc,*.docx,*.xls,*.xlsx,*.odp,*.pptx, *.ppt libreoffice %f &
fileviewer *.doc catdoc %c
fileviewer *.docx docx2txt.pl %f -
" TuDu files
filetype *.tudu tudu -f %c
" Qt projects
filextype *.pro qtcreator %f &
" Directories
filextype */
\ {View in thunar}
\ Thunar %f &,
filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus mpv --no-audio-display --input-ipc-server=/tmp/mpvsoc$(date +%%s) %c
" Syntax highlighting in preview
fileviewer * highlight -O ansi -s dante %c
"
" Explicitly set highlight type for some extensions
"
@ -286,7 +271,6 @@ filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus mpv -
" 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
"

View File

@ -2,4 +2,4 @@
# File manager.
"$TERMINAL" -e vifm
"$TERMINAL" -e vifmrun

56
.local/bin/scripts/vifmimg Executable file
View File

@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Preview images in vifm via ueberzug.
readonly ID_PREVIEW="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
echo -e "Loading preview..\nFile: $6"
[[ ! -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
echo -e "Loading preview..\nFile: $6"
[[ ! -d "/tmp${PWD}/$6/" ]] && mkdir -p "/tmp${PWD}/$6/" && convert -coalesce "${PWD}/$6" "/tmp${PWD}/$6/$6.png"
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
elif [[ "$1" == "pdfpreview" ]]; then
echo -e "Loading preview..\nFile: $6"
[[ ! -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

22
.local/bin/scripts/vifmrun Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Run vifm with ueberzug support.
export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}"
function cleanup {
rm "$FIFO_UEBERZUG" 2>/dev/null
pkill -P $$ 2>/dev/null
}
rm "$FIFO_UEBERZUG" 2>/dev/null
mkfifo "$FIFO_UEBERZUG"
trap cleanup EXIT
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash &
if [ -n "$1" ]; then
vifm $1 $2
else
vifm $(pwd) $(pwd)
fi
cleanup