Condense term function
This commit is contained in:
parent
a7f7218b24
commit
37e7d8e4b3
63
neofetch
63
neofetch
|
@ -1739,39 +1739,40 @@ getfont () {
|
||||||
# Terminal Emulator {{{
|
# Terminal Emulator {{{
|
||||||
|
|
||||||
getterm () {
|
getterm () {
|
||||||
# Workaround for OS X systems that
|
# Check $PPID for terminal emulator.
|
||||||
# don't support the block below.
|
case "$os" in
|
||||||
case "$TERM_PROGRAM" in
|
"Mac OS X")
|
||||||
"iTerm.app") term="iTerm2" ;;
|
# Workaround for OS X systems that
|
||||||
"Terminal.app") term="Apple Terminal" ;;
|
# don't support the block below.
|
||||||
*) term="${TERM_PROGRAM/\.app}" ;;
|
case "$TERM_PROGRAM" in
|
||||||
|
"iTerm.app") term="iTerm2" ;;
|
||||||
|
"Terminal.app") term="Apple Terminal" ;;
|
||||||
|
*) term="${TERM_PROGRAM/\.app}" ;;
|
||||||
|
esac
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
|
||||||
|
"Windows")
|
||||||
|
parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')"
|
||||||
|
parent=${parent/'PPID'}
|
||||||
|
|
||||||
|
name="$(ps -p $parent | awk '{printf $8}')"
|
||||||
|
name=${name/'COMMAND'}
|
||||||
|
name=${name/*\/}
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
parent="$(ps -p ${1:-$PPID} -o ppid=)"
|
||||||
|
name="$(ps -p $parent -o comm=)"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Check $PPID for terminal emulator.
|
case "${name// }" in
|
||||||
if [ -z "$term" ]; then
|
"${SHELL/*\/}" | *"sh" | "tmux" | "screen") getterm "$parent" ;;
|
||||||
case "$os" in
|
"login" | "init") term="$(tty)"; term=${term/*\/} ;;
|
||||||
"Windows")
|
"ruby" | "1" | "systemd" | "sshd") unset term ;;
|
||||||
parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')"
|
*) term="$name" ;;
|
||||||
parent=${parent/'PPID'}
|
esac
|
||||||
|
|
||||||
name="$(ps -p $parent | awk '{printf $8}')"
|
|
||||||
name=${name/'COMMAND'}
|
|
||||||
name=${name/*\/}
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
parent="$(ps -p ${1:-$PPID} -o ppid=)"
|
|
||||||
name="$(ps -p $parent -o comm=)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "${name// }" in
|
|
||||||
"${SHELL/*\/}" | *"sh" | "tmux" | "screen") getterm "$parent" ;;
|
|
||||||
"login" | "init") term="$(tty)"; term=${term/*\/} ;;
|
|
||||||
"ruby" | "1" | "systemd" | "sshd") unset term ;;
|
|
||||||
*) term="$name" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
Reference in New Issue