I need to check in my .vimrc whether or not the terminal in which vim is opened is running in Guake. How can I see this? The $TERM variable does not seem to be quite right...
Identify whether terminal is open in guake
terminal;guake
There is no foolproof way. TERM uses the same value for mostly-compatible emulators; most modern terminal emulators aside from screen and tmux report xterm.You can explore the process list to find Vim's parent's parent. That will tell you in what terminal emulator (if any) Vim is running in in the common case where Vim was launched from a shell which was started directly in the terminal emulator. You can even be a little smarter and traverse the process list, going from Vim to its parent, then its parent's parent, and so on, and stopping when you find a process that isn't running on the same terminal as its child: that process is probably a terminal emulator. This heuristic can be fooled in a number of ways in particular because it is possible (though uncommon) to start a program from anywhere and make it interact in another terminal by redirecting its input and output.Here's a lightly-tested script which shows the command line of the terminal emulator that the current process is running on, assuming that the process is started as a descendant of that terminal emulator with no redirection shenanigans.#! /bin/shset -fpid=$PPIDmy_tty=$(ps -p $$ -o tty=)while  [ $pid -ne 1 ] &&  set -- $(ps -p $pid -o ppid= -o tty= -o args=) &&  [ $2 = $my_tty ]do  pid=$1doneshift; shiftprintf '%s\n' $*Call this script which-terminal-emulator. In your .vimrc, you can uselet terminal_emulator=system('which-terminal-emulator')if terminal_emulator =~ '.*guake$'  endif