浏览代码

sxiv: load dir along with file

master
Arun Prakash Jana 5 年前
父节点
当前提交
4aa12a2dfb
找不到此签名对应的密钥 GPG 密钥 ID: A75979F35C080412
共有 2 个文件被更改,包括 49 次插入3 次删除
  1. +25
    -2
      plugins/imgview
  2. +24
    -1
      plugins/nuke

+ 25
- 2
plugins/imgview 查看文件

@@ -6,6 +6,29 @@
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: Arun Prakash Jana # Author: Arun Prakash Jana


abspath() {
case "$1" in
/*) printf "%s\n" "$1";;
*) printf "%s\n" "$PWD/$1";;
esac
}

listimages() {
find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \
'.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z
}

sxiv_view_dir() {
target="$(abspath "$1")"
count="$(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)"

if [ -n "$count" ]; then
listimages | xargs -0 sxiv -n "$count" --
else
sxiv -- "$@" # fallback
fi
}

if [ -z "$1" ] || ! [ -s "$1" ]; then if [ -z "$1" ] || ! [ -s "$1" ]; then
printf "empty file" printf "empty file"
read -r _ read -r _
@@ -14,9 +37,9 @@ fi


if command -v sxiv >/dev/null 2>&1; then if command -v sxiv >/dev/null 2>&1; then
if [ -f "$1" ]; then if [ -f "$1" ]; then
sxiv -q "$1" "$PWD" sxiv_view_dir "$1" >/dev/null 2>&1 &
elif [ -d "$1" ] || [ -h "$1" ]; then elif [ -d "$1" ] || [ -h "$1" ]; then
sxiv -qt "$1" sxiv -qt "$1" >/dev/null 2>&1 &
fi fi
elif command -v viu >/dev/null 2>&1; then elif command -v viu >/dev/null 2>&1; then
viu -n "$1" | less -R viu -n "$1" | less -R


+ 24
- 1
plugins/nuke 查看文件

@@ -240,6 +240,29 @@ handle_extension() {
esac esac
} }


abspath() {
case "$1" in
/*) printf "%s\n" "$1";;
*) printf "%s\n" "$PWD/$1";;
esac
}

listimages() {
find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \
'.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z
}

sxiv_load_dir() {
target="$(abspath "$1")"
count="$(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)"

if [ -n "$count" ]; then
listimages | xargs -0 sxiv -n "$count" --
else
sxiv -- "$@" # fallback
fi
}

handle_multimedia() { handle_multimedia() {
## Size of the preview if there are multiple options or it has to be ## Size of the preview if there are multiple options or it has to be
## rendered from vector graphics. If the conversion program allows ## rendered from vector graphics. If the conversion program allows
@@ -263,7 +286,7 @@ handle_multimedia() {
## Image ## Image
image/*) image/*)
if [ $GUI -ne 0 ] && which sxiv >/dev/null 2>&1; then if [ $GUI -ne 0 ] && which sxiv >/dev/null 2>&1; then
sxiv -q "${FPATH}" & sxiv_load_dir "${FPATH}" >/dev/null 2>&1 &
exit 0 exit 0
elif which viu >/dev/null 2>&1; then elif which viu >/dev/null 2>&1; then
viu -n "${FPATH}" | less -R viu -n "${FPATH}" | less -R


||||||
x
 
000:0
正在加载...
取消
保存