@@ -2698,38 +2698,42 @@ get_term() {
2698
2698
# Workaround for macOS systems that
2699
2699
# don't support the block below.
2700
2700
case " $TERM_PROGRAM " in
2701
- " iTerm.app" ) term=" iTerm2" ;;
2701
+ " iTerm.app" ) term=" iTerm2" ;;
2702
2702
" Terminal.app" ) term=" Apple Terminal" ;;
2703
- " Hyper" ) term=" HyperTerm" ;;
2704
- * ) term=" ${TERM_PROGRAM/ \. app} " ;;
2703
+ " Hyper" ) term=" HyperTerm" ;;
2704
+ * ) term=" ${TERM_PROGRAM/ \. app} " ;;
2705
2705
esac
2706
2706
2707
2707
# Most likely TosWin2 on FreeMiNT - quick check
2708
2708
[[ " $TERM " == " tw52" || " $TERM " == " tw100" ]] && \
2709
2709
term=" TosWin2"
2710
2710
2711
+ [[ " $SSH_CONNECTION " ]] && \
2712
+ term=" $SSH_TTY "
2713
+
2711
2714
# Check $PPID for terminal emulator.
2712
2715
while [[ -z " $term " ]]; do
2713
- if [[ " $SSH_CONNECTION " ]]; then
2714
- term=" $SSH_TTY " ; break
2715
- else
2716
- parent=" $( get_ppid " $parent " ) "
2717
- [[ -z " $parent " ]] && break
2718
- name=" $( get_process_name " $parent " ) "
2719
- case " ${name// } " in
2720
- " ${SHELL/* \/ } " | * " sh" | " screen" | " su" * ) ;;
2721
- " login" * | * " Login" * | " init" | " (init)" ) term=" $( tty) " ;;
2722
- " ruby" | " 1" | " systemd" | " sshd" * | " python" * |\
2723
- " USER" * " PID" * | " kdeinit" * | " launchd" * )
2724
- break
2725
- ;;
2726
- " gnome-terminal-" ) term=" gnome-terminal" ;;
2727
- * " nvim" ) term=" Neovim Terminal" ;;
2728
- * " NeoVimServer" * ) term=" VimR Terminal" ;;
2729
- * " tmux" * ) term=" tmux" ;;
2730
- * ) term=" ${name##*/ } " ;;
2731
- esac
2732
- fi
2716
+ parent=" $( get_ppid " $parent " ) "
2717
+ [[ -z " $parent " ]] && break
2718
+ name=" $( get_process_name " $parent " ) "
2719
+
2720
+ case " ${name// } " in
2721
+ " ${SHELL/* \/ } " |* " sh" |" screen" |" su" * ) ;;
2722
+
2723
+ " login" * |* " Login" * |" init" |" (init)" )
2724
+ term=" $( tty) "
2725
+ ;;
2726
+
2727
+ " ruby" |" 1" |" systemd" |" sshd" * |" python" * |" USER" * " PID" * |" kdeinit" * |" launchd" * )
2728
+ break
2729
+ ;;
2730
+
2731
+ " gnome-terminal-" ) term=" gnome-terminal" ;;
2732
+ * " nvim" ) term=" Neovim Terminal" ;;
2733
+ * " NeoVimServer" * ) term=" VimR Terminal" ;;
2734
+ * " tmux" * ) term=" tmux" ;;
2735
+ * ) term=" ${name##*/ } " ;;
2736
+ esac
2733
2737
done
2734
2738
2735
2739
# Log that the function was run.
@@ -3351,7 +3355,7 @@ image_backend() {
3351
3355
printf ' \e[2J\e[H'
3352
3356
get_image_size
3353
3357
make_thumbnail
3354
- display_image
3358
+ display_image || to_off " Image: $image_backend failed to display the image. "
3355
3359
;;
3356
3360
3357
3361
* )
@@ -3708,54 +3712,52 @@ make_thumbnail() {
3708
3712
display_image () {
3709
3713
case " $image_backend " in
3710
3714
" caca" )
3711
- img2txt -W " $(( width / font_width)) )" \
3712
- -H " $(( height / font_height)) " \
3713
- --gamma=0.6 " $image " || \
3714
- to_off " Image: libcaca failed to display the image."
3715
+ img2txt \
3716
+ -W " $(( width / font_width)) )" \
3717
+ -H " $(( height / font_height)) " \
3718
+ --gamma=0.6 \
3719
+ " $image "
3715
3720
;;
3716
3721
3717
3722
" jp2a" )
3718
- jp2a --width=" $(( width / font_width)) " \
3719
- --height=" $(( height / font_height)) " \
3720
- --colors " $image " || \
3721
- to_off " Image: jp2a failed to display the image."
3723
+ jp2a \
3724
+ --width=" $(( width / font_width)) " \
3725
+ --height=" $(( height / font_height)) " \
3726
+ --colors \
3727
+ " $image "
3722
3728
;;
3723
3729
3724
3730
" kitty" )
3725
3731
kitty icat \
3726
- --align left \
3727
- --place " $(( width / font_width)) x$(( height / font_height)) \
3728
- @${xoffset} x${yoffset} " \
3729
- " $image " || \
3730
- to_off " Image: kitty failed to display the image."
3732
+ --align left \
3733
+ --place " $(( width/ font_width)) x$(( height/ font_height)) @${xoffset} x${yoffset} " \
3734
+ " $image "
3731
3735
;;
3732
3736
3733
3737
" pixterm" )
3734
- pixterm -tc " $(( width / font_width )) " \
3735
- -tr " $(( height / font_height )) " \
3736
- " $image " || \
3737
- to_off " Image: pixterm failed to display the image. "
3738
+ pixterm \
3739
+ -tc " $(( width / font_width )) " \
3740
+ -tr " $(( height / font_height )) " \
3741
+ " $ image"
3738
3742
;;
3739
3743
3740
3744
" sixel" )
3741
- img2sixel -w " $width " \
3742
- -h " $height " \
3743
- " $image " || \
3744
- to_off " Image: libsixel failed to display the image. "
3745
+ img2sixel \
3746
+ -w " $width " \
3747
+ -h " $height " \
3748
+ " $ image"
3745
3749
;;
3746
3750
3747
3751
" termpix" )
3748
- termpix --width " $(( width / font_width )) " \
3749
- --height " $(( height / font_height )) " \
3750
- " $image " || \
3751
- to_off " Image: termpix failed to display the image. "
3752
+ termpix \
3753
+ --width " $(( width / font_width )) " \
3754
+ --height " $(( height / font_height )) " \
3755
+ " $ image"
3752
3756
;;
3753
3757
3754
3758
" iterm2" )
3755
- image=" $( base64 < " $image " ) "
3756
-
3757
3759
printf -v iterm_cmd ' \e]1337;File=width=%spx;height=%spx;inline=1:%s' \
3758
- " $width " " $height " " $image "
3760
+ " $width " " $height " " $( base64 < " $ image" ) "
3759
3761
3760
3762
# Tmux requires an additional escape sequence for this to work.
3761
3763
[[ -n " $TMUX " ]] && printf -v iterm_cmd ' \ePtmux;\e%b\e' \\ " $iterm_cmd "
@@ -3764,8 +3766,9 @@ display_image() {
3764
3766
;;
3765
3767
3766
3768
" tycat" )
3767
- tycat -g " ${width} x${height} " " $image " || \
3768
- to_off " Image: tycat failed to display the image."
3769
+ tycat \
3770
+ -g " ${width} x${height} " \
3771
+ " $image "
3769
3772
;;
3770
3773
3771
3774
" w3m" )
@@ -3776,8 +3779,7 @@ display_image() {
3776
3779
# appearing in specific terminal emulators.
3777
3780
sleep 0.05
3778
3781
printf ' %b\n%s;\n%s\n' " 0;1;$xoffset ;$yoffset ;$width ;$height ;;;;;$image " 3 4 | \
3779
- " ${w3m_img_path:- false} " -bg " $background_color " & > /dev/null || \
3780
- to_off " Image: w3m-img failed to display the image."
3782
+ " ${w3m_img_path:- false} " -bg " $background_color " & > /dev/null
3781
3783
;;
3782
3784
esac
3783
3785
}
0 commit comments