diff options
author | Hugues Hiegel <hugues.hiegel@qosmos.com> | 2013-02-25 18:21:31 +0100 |
---|---|---|
committer | Hugues Hiegel <hugues.hiegel@qosmos.com> | 2013-02-25 18:21:31 +0100 |
commit | 2c83939a5779bc890fb33ea115a943cba2b1f5e0 (patch) | |
tree | a160c85713d2f7027d9c22cf550ba77e85f99e21 | |
parent | ae04f9ce9f61f871dc790019f9bd4c2957b49f8f (diff) |
[Env] Process tree checkup to get urxvt/tmux/screen
-rw-r--r-- | 01_Internal.zsh | 23 | ||||
-rw-r--r-- | 10_Environment.zsh | 12 |
2 files changed, 34 insertions, 1 deletions
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"}:-"-"} |