From 2c83939a5779bc890fb33ea115a943cba2b1f5e0 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Mon, 25 Feb 2013 18:21:31 +0100 Subject: [Env] Process tree checkup to get urxvt/tmux/screen --- 01_Internal.zsh | 23 +++++++++++++++++++++++ 10_Environment.zsh | 12 +++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/01_Internal.zsh b/01_Internal.zsh index c7297fe..a4bdf43 100644 --- a/01_Internal.zsh +++ b/01_Internal.zsh @@ -428,3 +428,26 @@ _rehash () } zle -N _rehash + +# Process helper +_process_tree() +{ + for leaf in ${@:-$$} + do + ps -eo pid,ppid,command | awk -v leaf="$leaf" \ + '{ + parent[$1]=$2 ; + command[$1]=$3 ; + } + function print_ancestry(pid) + { + if (pid != 1) { print_ancestry(parent[pid]) ; printf " :: " } + printf command[pid]; + }; + END { + print_ancestry(leaf) + print "" + }' + done +} + diff --git a/10_Environment.zsh b/10_Environment.zsh index 66774ce..6dfbe78 100644 --- a/10_Environment.zsh +++ b/10_Environment.zsh @@ -27,7 +27,17 @@ C_="%{$c_" _C="$_c%}" unset has_termcaps -[ $TERM = "rxvt-unicode" -o $TERM = "screen" ] && has_termcaps="true" +case "$( _process_tree )" in + *":: screen ::"*) + # Discards termcaps even if screen is launched from an urxvt.. + ;; + *":: urxvt ::"*|\ + *":: tmux ::"*) + has_termcaps="true" + ;; + *) + ;; +esac T_=${has_termcaps:+$termcap[as]} _T=${has_termcaps:+$termcap[ae]} _tq_=${${has_termcaps:+"q"}:-"-"} -- cgit v1.2.3