Can one detect what terminal application is being used? I want the actual application, not TERM env in the question.
I'd like to detect iTerm 2 / Terminal.app so I could set OSX specific keyboard mappings, otherwise PC.
Can one detect what terminal application is being used? I want the actual application, not TERM env in the question.
I'd like to detect iTerm 2 / Terminal.app so I could set OSX specific keyboard mappings, otherwise PC.
You need to SSH forward local environment variables, as explained here:
http://groups.google.com/group/iterm2-discuss/msg/7cc214c487d31bc8
I made the following script:
#!/bin/bash
pid=$$ # Current PID
ps -f $$ | head -n 1 # Show the header of ps
while [ $pid -gt 0 ]; do # No more parent when we reach 0 (the kernel)
ps -f $pid | tail -n +2 # ps current pid and remove header
pid=$(ps -o ppid $pid|tail -n 1) # Get parent pid
done
It takes the current PID ($$ in bash) and recursively gets the parent PID until we reach 0 (which is the kernel), printing the ps -f output along the way (and a header to start, with ps -f | head -n 1)
Two limitations I can think of:
sshd and not the graphical terminal application.However you should be able to grep its output and detect if one of the parent process is iTerm.app or Terminal.app when run locally.