mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 03:41:27 +00:00
Merge image plugins
This commit is contained in:
parent
6f29138299
commit
2f9c700537
|
@ -83,7 +83,7 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/embed/AbaauM7gUJw)
|
||||||
- Open with desktop opener or specify a custom opener
|
- Open with desktop opener or specify a custom opener
|
||||||
- File-specific colors (or minimal _dirs in context color_)
|
- File-specific colors (or minimal _dirs in context color_)
|
||||||
- Icons (customize and compile-in)
|
- Icons (customize and compile-in)
|
||||||
- Plugins for image and video thumbnails
|
- Plugin for image, video and audio thumbnails
|
||||||
- Create, list, extract, mount (FUSE based) archives
|
- Create, list, extract, mount (FUSE based) archives
|
||||||
- Option to open all text files in `$EDITOR`
|
- Option to open all text files in `$EDITOR`
|
||||||
- Information
|
- Information
|
||||||
|
|
|
@ -35,9 +35,8 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
|
||||||
| [gutenread](gutenread) | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
|
| [gutenread](gutenread) | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
|
||||||
| [hexview](hexview) | View a file in hex in `$PAGER` | sh | [hx](https://github.com/krpors/hx)/xxd |
|
| [hexview](hexview) | View a file in hex in `$PAGER` | sh | [hx](https://github.com/krpors/hx)/xxd |
|
||||||
| [imgresize](imgresize) | Resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) |
|
| [imgresize](imgresize) | Resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) |
|
||||||
| [imgthumb](imgthumb) | View thumbnail of an image or dir of images | sh | [lsix](https://github.com/hackerb9/lsix) |
|
|
||||||
| [imgur](imgur) | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) | bash | - |
|
| [imgur](imgur) | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) | bash | - |
|
||||||
| [imgview](imgview) | Browse images, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)), [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images)| sh | [imv](https://github.com/eXeC64/imv)/[sxiv](https://github.com/muennich/sxiv)/[viu](https://github.com/atanunq/viu), less|
|
| [imgview](imgview) | View (thumbnail)images, set wallpaper, [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images) and [more](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)| sh | [imv](https://github.com/eXeC64/imv)/[sxiv](https://github.com/muennich/sxiv)/[viu](https://github.com/atanunq/viu)/<br>[catimg](https://github.com/posva/catimg)/[lsix](https://github.com/hackerb9/lsix)|
|
||||||
| [ipinfo](ipinfo) | Fetch external IP address and whois information | sh | curl, whois |
|
| [ipinfo](ipinfo) | Fetch external IP address and whois information | sh | curl, whois |
|
||||||
| [kdeconnect](kdeconnect) | Send selected files to an Android device [✓] | sh | kdeconnect-cli |
|
| [kdeconnect](kdeconnect) | Send selected files to an Android device [✓] | sh | kdeconnect-cli |
|
||||||
| [launch](launch) | GUI application launcher | sh | fzf |
|
| [launch](launch) | GUI application launcher | sh | fzf |
|
||||||
|
@ -70,7 +69,6 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
|
||||||
| [umounttree](umounttree) | Unmount a remote mountpoint from within | sh | fusermount |
|
| [umounttree](umounttree) | Unmount a remote mountpoint from within | sh | fusermount |
|
||||||
| [upgrade](upgrade) | Upgrade nnn manually on Debian 9 Stretch | sh | curl |
|
| [upgrade](upgrade) | Upgrade nnn manually on Debian 9 Stretch | sh | curl |
|
||||||
| [upload](upload) | Upload to Firefox Send or ix.io (text) or file.io (bin) | sh | [ffsend](https://github.com/timvisee/ffsend), curl, jq, tr |
|
| [upload](upload) | Upload to Firefox Send or ix.io (text) or file.io (bin) | sh | [ffsend](https://github.com/timvisee/ffsend), curl, jq, tr |
|
||||||
| [vidthumb](vidthumb) | Show video thumbnails in terminal | sh | [ffmpegthumbnailer](https://github.com/dirkvdb/ffmpegthumbnailer),<br>[lsix](https://github.com/hackerb9/lsix) |
|
|
||||||
| [wall](wall) | Set wallpaper or change colorscheme | sh | nitrogen/pywal |
|
| [wall](wall) | Set wallpaper or change colorscheme | sh | nitrogen/pywal |
|
||||||
| [x2sel](x2sel) | Copy file list from system clipboard to selection | sh | _see in-file docs_ |
|
| [x2sel](x2sel) | Copy file list from system clipboard to selection | sh | _see in-file docs_ |
|
||||||
| [xdgdefault](xdgdefault) | Set the default app for the hovered file type | sh | xdg-utils, fzf |
|
| [xdgdefault](xdgdefault) | Set the default app for the hovered file type | sh | xdg-utils, fzf |
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
# Description: View thumbnail of an image or a directory of images with lsix
|
|
||||||
#
|
|
||||||
# Dependencies: lsix
|
|
||||||
#
|
|
||||||
# Shell: POSIX compliant
|
|
||||||
# Author: Arun Prakash Jana
|
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
|
||||||
if [ -d "$1" ]; then
|
|
||||||
lsix "$1"/*
|
|
||||||
else
|
|
||||||
lsix "$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "Press any key to exit..."
|
|
||||||
read -r _
|
|
||||||
fi
|
|
127
plugins/imgview
127
plugins/imgview
|
@ -1,72 +1,101 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# Description: Open images in hovered directory and thumbnails
|
# Description: Open hovered or current directory in image viewer.
|
||||||
# open hovered image in sxiv or viu and browse other images in the directory
|
# Thumbnails for audio and video files are generated
|
||||||
|
# and deleted on exit. Supported image viewers open
|
||||||
|
# in thumbnail mode when the hovered entry is a directory.
|
||||||
#
|
#
|
||||||
# Dependencies:
|
# Dependencies:
|
||||||
# - imv (https://github.com/eXeC64/imv) or,
|
# - imv (https://github.com/eXeC64/imv) or,
|
||||||
# - sxiv (https://github.com/muennich/sxiv) or,
|
# - sxiv (https://github.com/muennich/sxiv) or,
|
||||||
# - viu (https://github.com/atanunq/viu), less
|
# - viu (https://github.com/atanunq/viu), or
|
||||||
|
# - catimg (https://github.com/posva/catimg), or
|
||||||
|
# - lsix (https://github.com/hackerb9/lsix)
|
||||||
#
|
#
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Arun Prakash Jana
|
# Author: Arun Prakash Jana, Luuk van Baal
|
||||||
|
|
||||||
abspath() {
|
target="$(readlink -f "$1")"
|
||||||
case "$1" in
|
|
||||||
/*) printf "%s\n" "$1";;
|
exit_prompt() {
|
||||||
*) printf "%s\n" "$PWD/$1";;
|
[ -n "$1" ] && printf "%s\n" "$1"
|
||||||
esac
|
printf "%s" "Press any key to exit..."
|
||||||
|
cfg=$(stty -g); stty raw -echo; head -c 1; stty "$cfg"
|
||||||
|
clear
|
||||||
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
listimages() {
|
nthumb_cleanup() {
|
||||||
find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \
|
[ -n "$!" ] && while [ -e /proc/"$!" ]; do sleep 1; done
|
||||||
'.*\(jpe?g\|bmp\|webp\|ico\|svg\|png\|gif\)$' -print0 | sort -z
|
if [ -f "$target" ]; then
|
||||||
|
rm -r "$(dirname "$target")"/.nthumbs
|
||||||
|
elif [ -d "$target" ]; then
|
||||||
|
rm -r "$target"/.nthumbs
|
||||||
|
fi &
|
||||||
|
}
|
||||||
|
|
||||||
|
make_thumbs() {
|
||||||
|
if [ -d "$target" ]; then cd "$target" || exit_prompt; fi
|
||||||
|
if mkdir .nthumbs >/dev/null; then
|
||||||
|
thumbs=1
|
||||||
|
else
|
||||||
|
exit_prompt
|
||||||
|
fi
|
||||||
|
for file in *; do
|
||||||
|
case "$(file -bL --mime-type -- "$file")" in
|
||||||
|
image/*) ln -s "$PWD/$file" "$PWD/.nthumbs/$file" ;;
|
||||||
|
audio/*) ffmpeg -i "$file" ".nthumbs/${file%%.*}.jpg" -y >/dev/null 2>&1;;
|
||||||
|
video/*) ffmpegthumbnailer -i "$file" -o .nthumbs/"${file%%.*}".jpg 2> /dev/null ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
cd .nthumbs || return
|
||||||
}
|
}
|
||||||
|
|
||||||
view_dir() {
|
view_dir() {
|
||||||
target="$(abspath "$2")"
|
find . -maxdepth 0 -print0 | xargs -0 "$1" --
|
||||||
count="$(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)"
|
|
||||||
|
|
||||||
if [ -n "$count" ]; then
|
|
||||||
if [ "$1" = 'sxiv' ]; then
|
|
||||||
listimages | xargs -0 "$1" -an "$count" --
|
|
||||||
else
|
|
||||||
listimages | xargs -0 "$1" -n "$count" --
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
shift
|
|
||||||
"$1" -- "$@" # fallback
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$1" ] || ! [ -s "$1" ]; then
|
|
||||||
printf "empty file"
|
|
||||||
read -r _
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if uname | grep -q "Darwin"; then
|
if uname | grep -q "Darwin"; then
|
||||||
if [ -f "$1" ]; then
|
[ -f "$1" ] && open "$1" >/dev/null 2>&1 &
|
||||||
open "$1" >/dev/null 2>&1 &
|
elif type lsix >/dev/null 2>&1; then
|
||||||
fi
|
if [ -d "$target" ]; then
|
||||||
# `imvr` is often callable as `imv` on Linux distros
|
cd "$target" || exit_prompt
|
||||||
# You might need to change the reference below
|
|
||||||
elif type imvr >/dev/null 2>&1; then
|
|
||||||
if [ -f "$1" ]; then
|
|
||||||
view_dir imvr "$1" >/dev/null 2>&1 &
|
|
||||||
elif [ -d "$1" ] || [ -h "$1" ]; then
|
|
||||||
imvr "$1" >/dev/null 2>&1 &
|
|
||||||
fi
|
fi
|
||||||
|
make_thumbs
|
||||||
|
clear
|
||||||
|
lsix
|
||||||
|
nthumb_cleanup
|
||||||
|
exit_prompt
|
||||||
elif type sxiv >/dev/null 2>&1; then
|
elif type sxiv >/dev/null 2>&1; then
|
||||||
if [ -f "$1" ]; then
|
make_thumbs
|
||||||
view_dir sxiv "$1" >/dev/null 2>&1 &
|
if [ -f "$target" ]; then
|
||||||
elif [ -d "$1" ] || [ -h "$1" ]; then
|
view_dir sxiv >/dev/null 2>&1 &
|
||||||
sxiv -aqt "$1" >/dev/null 2>&1 &
|
elif [ -d "$target" ]; then
|
||||||
|
sxiv -aqt . >/dev/null 2>&1 &
|
||||||
|
fi
|
||||||
|
elif type imv >/dev/null 2>&1; then
|
||||||
|
make_thumbs
|
||||||
|
if [ -f "$target" ]; then
|
||||||
|
view_dir imv >/dev/null 2>&1 &
|
||||||
|
elif [ -d "$target" ]; then
|
||||||
|
imv . >/dev/null 2>&1 &
|
||||||
|
fi
|
||||||
|
elif type imvr >/dev/null 2>&1; then
|
||||||
|
make_thumbs
|
||||||
|
if [ -f "$target" ]; then
|
||||||
|
view_dir imvr >/dev/null 2>&1 &
|
||||||
|
elif [ -d "$target" ]; then
|
||||||
|
imvr . >/dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
elif type viu >/dev/null 2>&1; then
|
elif type viu >/dev/null 2>&1; then
|
||||||
viu -n "$1" | less -R
|
clear
|
||||||
|
viu -n "$1"
|
||||||
|
exit_prompt
|
||||||
|
elif type catimg >/dev/null 2>&1; then
|
||||||
|
clear
|
||||||
|
catimg "$1"
|
||||||
|
exit_prompt
|
||||||
else
|
else
|
||||||
printf "Please install imv/sxiv/viu and check their callable names match the plugin source"
|
exit_prompt "Please install sxiv/imv/viu/catimg/lsix."
|
||||||
read -r _
|
|
||||||
exit 2
|
|
||||||
fi
|
fi
|
||||||
|
[ -n "$thumbs" ] && nthumb_cleanup &
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
# Description: Generate video thumbnails and view them
|
|
||||||
#
|
|
||||||
# Dependencies:
|
|
||||||
# - ffmpegthumbnailer: https://github.com/dirkvdb/ffmpegthumbnailer
|
|
||||||
# - lsix: https://github.com/hackerb9/lsix
|
|
||||||
#
|
|
||||||
# Shell: POSIX compliant
|
|
||||||
# Author: Arun Prakash Jana
|
|
||||||
|
|
||||||
mkdir .nthumbs > /dev/null 2>&1
|
|
||||||
|
|
||||||
for file in *; do
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
ffmpegthumbnailer -i "$file" -o .nthumbs/"${file%%.*}".jpg 2> /dev/null
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# render thumbnails in lsix
|
|
||||||
lsix .nthumbs/*
|
|
||||||
|
|
||||||
# remove the thumbnails
|
|
||||||
rm -rf .nthumbs
|
|
||||||
|
|
||||||
printf "Press any key to exit..."
|
|
||||||
read -r _
|
|
Loading…
Reference in a new issue