sh: Add timg aliases

Added shell aliases for 'image listings' which aims to mimic the `ls`
command in a very simple way.

Invoke it via `il` to display a grid of all images residing in current
directory. Images are being detected not by their extension but by
running a `file` operation on, so in very large directories this might
take a little (though, your terminal will probably buckle under the
weight of displaying thousands of images anyway, so use with care).

`IL` provides the same functionality but recurses into an arbitrary
amount of subdirectories. Very useful to get an overview of a certain
directory and its children but, again, think for a second before using
since this could easily spew thousands of pictures into your term.
This commit is contained in:
Marty Oehme 2022-11-15 18:39:25 +01:00
parent fdc85e5569
commit cf7d890787
Signed by: Marty
GPG Key ID: 73BA40D5AFAF49C9
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
#!/usr/bin/env sh
# Add simple 'image ls' for a directory using timg
#
# Prints a thumbnail gallery right in the terminal.
# WILL stutter when you go crazy in a hundred/thousand
# picture folder.
if exist timg; then
il() {
images=$(find . -maxdepth 1 -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}')
if [ -z "$images" ]; then {
echo no images found.
return
}; fi
echo "$images" | timg --grid=4x3 --upscale=i --center --title --frames=1 -f -
}
IL() {
images=$(find . -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}')
if [ -z "$images" ]; then {
echo no images found.
return
}; fi
echo "$images" | timg --grid=4x3 --upscale=i --center --title --frames=1 -f -
}
qr() {
# if we are in a pipe, read from stdin and set fct arguments to it
if [ ! -t 0 ]; then
set -- "$(cat /dev/stdin)"
fi
qrencode -s1 -m2 "$@" -o- | timg --upscale=i -
}
fi