Skip to content

Commit 93d067a

Browse files
committed
alias montage="magick montage" for IM7
Montage is not deprecated, yet, but it looks like it is going to be. Also, switched to using an alias (instead of a variable) for convert as it looks cleaner. Downside is that if they don't have a sixel terminal, the error message will tell users to type `convert` even for IM7. For now, that's fine. Perhaps of note about the return value of `type` and `command`: This command | Is equivalent to these commands ----------------------|---------------------------------- type foo | command -v foo type foo bar | type foo && type bar command -v foo bar | command -v foo || command -v bar Therefore, `command -v magick montage` does an implicit "OR", which is what we want when checking if either of IM6 or IM7 is installed.
1 parent 2b7c9e7 commit 93d067a

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

lsix

+13-15
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# Requirements: just ImageMagick (and a Sixel terminal, of course)
77

8-
# Version 1.9
8+
# Version 1.9.1
99
# B9 June 2024
1010

1111
# See end of file for USAGE.
@@ -54,22 +54,20 @@ if [[ ${BASH_VERSINFO[0]} -eq 3 ]]; then
5454
fi
5555
fi
5656

57+
shopt -s expand_aliases # Allow aliases for working around quirks.
58+
5759
# For ImageMagick 6 <-> 7 compatibility.
58-
magick=$(type -p magick)
59-
if [[ ! $magick ]]; then
60-
convert="convert"
61-
else
62-
convert="$magick"
60+
if type magick &>/dev/null; then
61+
alias convert='magick'
62+
alias montage='magick montage'
6363
fi
6464

65-
if ! command -v $magick montage >/dev/null; then
65+
if ! command -v magick montage &>/dev/null; then # (implicit 'or')
6666
echo "Please install ImageMagick" >&2
6767
exit 1
6868
fi
6969

70-
shopt -s expand_aliases # Allow aliases for working around quirks.
71-
72-
if command -v gsed >/dev/null; then
70+
if type gsed &>/dev/null; then
7371
alias sed=gsed # Use GNU sed for MacOS & BSD.
7472
fi
7573

@@ -107,7 +105,7 @@ autodetect() {
107105
108106
You may test your terminal by viewing a single image, like so:
109107
110-
$convert foo.jpg -geometry 800x480 sixel:-
108+
convert foo.jpg -geometry 800x480 sixel:-
111109
112110
If your terminal actually does support sixel, please file a bug
113111
report at http://github.com/hackerb9/lsix/issues
@@ -245,13 +243,13 @@ main() {
245243
onerow[len++]="file://$1"
246244
shift
247245
done
248-
$magick montage "${onerow[@]}" $imoptions gif:- \
249-
| $convert - -colors $numcolors sixel:-
246+
montage "${onerow[@]}" $imoptions gif:- \
247+
| convert - -colors $numcolors sixel:-
250248
done
251249
}
252250

253251
processlabel() {
254-
# This routine is all about appeasing ImageMagick.
252+
# This routine is mostly to appease ImageMagick.
255253
# 1. Remove silly [0] suffix and : prefix.
256254
# 2. Quote percent backslash, and at sign.
257255
# 3. Replace control characters with question marks.
@@ -308,7 +306,7 @@ read -s -t 60 -d "c" -p $'\e[c' >&2
308306
# * If your terminal supports changing the number of color registers
309307
# to improve the picture quality, lsix will do so.
310308

311-
# * Only software needed is ImageMagick (e.g., apt-get install imagemagick).
309+
# * Only software needed is ImageMagick (e.g., apt install imagemagick).
312310

313311
# Your terminal must support SIXEL graphics. E.g.,
314312
#

0 commit comments

Comments
 (0)