How can I identify the current terminal emulator from a bash script?
I'm not sure how to tell iTerm and iTerm2 apart, but check the $TERM_PROGRAM
envar. For me (Mac OS X 10.7), it returns Apple_Terminal
for Terminal.app
, and iTerm.app
for iTerm2.
Working fine on Ubuntu & mint Linux--
ps -o comm= -p "$(($(ps -o ppid= -p "$(($(ps -o sid= -p "$$")))")))"