misc: cleanup
This commit is contained in:
parent
ab01e65fad
commit
96bd33c2a0
114
neofetch
114
neofetch
|
@ -2698,38 +2698,42 @@ get_term() {
|
||||||
# Workaround for macOS systems that
|
# Workaround for macOS systems that
|
||||||
# don't support the block below.
|
# don't support the block below.
|
||||||
case "$TERM_PROGRAM" in
|
case "$TERM_PROGRAM" in
|
||||||
"iTerm.app") term="iTerm2" ;;
|
"iTerm.app") term="iTerm2" ;;
|
||||||
"Terminal.app") term="Apple Terminal" ;;
|
"Terminal.app") term="Apple Terminal" ;;
|
||||||
"Hyper") term="HyperTerm" ;;
|
"Hyper") term="HyperTerm" ;;
|
||||||
*) term="${TERM_PROGRAM/\.app}" ;;
|
*) term="${TERM_PROGRAM/\.app}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Most likely TosWin2 on FreeMiNT - quick check
|
# Most likely TosWin2 on FreeMiNT - quick check
|
||||||
[[ "$TERM" == "tw52" || "$TERM" == "tw100" ]] && \
|
[[ "$TERM" == "tw52" || "$TERM" == "tw100" ]] && \
|
||||||
term="TosWin2"
|
term="TosWin2"
|
||||||
|
|
||||||
|
[[ "$SSH_CONNECTION" ]] && \
|
||||||
|
term="$SSH_TTY"
|
||||||
|
|
||||||
# Check $PPID for terminal emulator.
|
# Check $PPID for terminal emulator.
|
||||||
while [[ -z "$term" ]]; do
|
while [[ -z "$term" ]]; do
|
||||||
if [[ "$SSH_CONNECTION" ]]; then
|
parent="$(get_ppid "$parent")"
|
||||||
term="$SSH_TTY"; break
|
[[ -z "$parent" ]] && break
|
||||||
else
|
name="$(get_process_name "$parent")"
|
||||||
parent="$(get_ppid "$parent")"
|
|
||||||
[[ -z "$parent" ]] && break
|
case "${name// }" in
|
||||||
name="$(get_process_name "$parent")"
|
"${SHELL/*\/}"|*"sh"|"screen"|"su"*) ;;
|
||||||
case "${name// }" in
|
|
||||||
"${SHELL/*\/}" | *"sh" | "screen" | "su"*) ;;
|
"login"*|*"Login"*|"init"|"(init)")
|
||||||
"login"* | *"Login"* | "init" | "(init)") term="$(tty)" ;;
|
term="$(tty)"
|
||||||
"ruby" | "1" | "systemd" | "sshd"* | "python"* |\
|
;;
|
||||||
"USER"*"PID"* | "kdeinit"* | "launchd"*)
|
|
||||||
break
|
"ruby"|"1"|"systemd"|"sshd"*|"python"*|"USER"*"PID"*|"kdeinit"*|"launchd"*)
|
||||||
;;
|
break
|
||||||
"gnome-terminal-") term="gnome-terminal" ;;
|
;;
|
||||||
*"nvim") term="Neovim Terminal" ;;
|
|
||||||
*"NeoVimServer"*) term="VimR Terminal" ;;
|
"gnome-terminal-") term="gnome-terminal" ;;
|
||||||
*"tmux"*) term="tmux" ;;
|
*"nvim") term="Neovim Terminal" ;;
|
||||||
*) term="${name##*/}" ;;
|
*"NeoVimServer"*) term="VimR Terminal" ;;
|
||||||
esac
|
*"tmux"*) term="tmux" ;;
|
||||||
fi
|
*) term="${name##*/}" ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Log that the function was run.
|
# Log that the function was run.
|
||||||
|
@ -3351,7 +3355,7 @@ image_backend() {
|
||||||
printf '\e[2J\e[H'
|
printf '\e[2J\e[H'
|
||||||
get_image_size
|
get_image_size
|
||||||
make_thumbnail
|
make_thumbnail
|
||||||
display_image
|
display_image || to_off "Image: $image_backend failed to display the image."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
@ -3708,54 +3712,52 @@ make_thumbnail() {
|
||||||
display_image() {
|
display_image() {
|
||||||
case "$image_backend" in
|
case "$image_backend" in
|
||||||
"caca")
|
"caca")
|
||||||
img2txt -W "$((width / font_width)))" \
|
img2txt \
|
||||||
-H "$((height / font_height))" \
|
-W "$((width / font_width)))" \
|
||||||
--gamma=0.6 "$image" ||\
|
-H "$((height / font_height))" \
|
||||||
to_off "Image: libcaca failed to display the image."
|
--gamma=0.6 \
|
||||||
|
"$image"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"jp2a")
|
"jp2a")
|
||||||
jp2a --width="$((width / font_width))" \
|
jp2a \
|
||||||
--height="$((height / font_height))" \
|
--width="$((width / font_width))" \
|
||||||
--colors "$image" ||\
|
--height="$((height / font_height))" \
|
||||||
to_off "Image: jp2a failed to display the image."
|
--colors \
|
||||||
|
"$image"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"kitty")
|
"kitty")
|
||||||
kitty icat \
|
kitty icat \
|
||||||
--align left \
|
--align left \
|
||||||
--place "$((width / font_width))x$((height / font_height))\
|
--place "$((width/font_width))x$((height/font_height))@${xoffset}x${yoffset}" \
|
||||||
@${xoffset}x${yoffset}" \
|
"$image"
|
||||||
"$image" ||\
|
|
||||||
to_off "Image: kitty failed to display the image."
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"pixterm")
|
"pixterm")
|
||||||
pixterm -tc "$((width / font_width))" \
|
pixterm \
|
||||||
-tr "$((height / font_height))" \
|
-tc "$((width / font_width))" \
|
||||||
"$image" ||\
|
-tr "$((height / font_height))" \
|
||||||
to_off "Image: pixterm failed to display the image."
|
"$image"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"sixel")
|
"sixel")
|
||||||
img2sixel -w "$width" \
|
img2sixel \
|
||||||
-h "$height" \
|
-w "$width" \
|
||||||
"$image" ||\
|
-h "$height" \
|
||||||
to_off "Image: libsixel failed to display the image."
|
"$image"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"termpix")
|
"termpix")
|
||||||
termpix --width "$((width / font_width))" \
|
termpix \
|
||||||
--height "$((height / font_height))" \
|
--width "$((width / font_width))" \
|
||||||
"$image" ||\
|
--height "$((height / font_height))" \
|
||||||
to_off "Image: termpix failed to display the image."
|
"$image"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"iterm2")
|
"iterm2")
|
||||||
image="$(base64 < "$image")"
|
|
||||||
|
|
||||||
printf -v iterm_cmd '\e]1337;File=width=%spx;height=%spx;inline=1:%s' \
|
printf -v iterm_cmd '\e]1337;File=width=%spx;height=%spx;inline=1:%s' \
|
||||||
"$width" "$height" "$image"
|
"$width" "$height" "$(base64 < "$image")"
|
||||||
|
|
||||||
# Tmux requires an additional escape sequence for this to work.
|
# Tmux requires an additional escape sequence for this to work.
|
||||||
[[ -n "$TMUX" ]] && printf -v iterm_cmd '\ePtmux;\e%b\e'\\ "$iterm_cmd"
|
[[ -n "$TMUX" ]] && printf -v iterm_cmd '\ePtmux;\e%b\e'\\ "$iterm_cmd"
|
||||||
|
@ -3764,8 +3766,9 @@ display_image() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"tycat")
|
"tycat")
|
||||||
tycat -g "${width}x${height}" "$image" ||\
|
tycat \
|
||||||
to_off "Image: tycat failed to display the image."
|
-g "${width}x${height}" \
|
||||||
|
"$image"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"w3m")
|
"w3m")
|
||||||
|
@ -3776,8 +3779,7 @@ display_image() {
|
||||||
# appearing in specific terminal emulators.
|
# appearing in specific terminal emulators.
|
||||||
sleep 0.05
|
sleep 0.05
|
||||||
printf '%b\n%s;\n%s\n' "0;1;$xoffset;$yoffset;$width;$height;;;;;$image" 3 4 |\
|
printf '%b\n%s;\n%s\n' "0;1;$xoffset;$yoffset;$width;$height;;;;;$image" 3 4 |\
|
||||||
"${w3m_img_path:-false}" -bg "$background_color" &>/dev/null ||\
|
"${w3m_img_path:-false}" -bg "$background_color" &>/dev/null
|
||||||
to_off "Image: w3m-img failed to display the image."
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue