screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question: action on reattach


From: Stefan `Sec` Zehl
Subject: Re: question: action on reattach
Date: Sat, 23 Mar 2019 11:27:11 +0100
User-agent: Mutt/1.11.2 (2019-01-07)

Hi,

On Thu, Mar 21, 2019 at 23:19 +0100, otheus uibk wrote:
> 3. A feature I sorely miss is the ability to trigger an action on
> re-attach. As a partial solution, I can exploit the SIGWINCH-on-resize
> behavior to do this, but I must pick up the mouse and resize the screen
> (horrors!) on my graphical terminal window. The motivation for having this
> is to trigger updates to shell environment variables which point to
> authentication agents, such as gpg-agent and ssh-agent and X11-forwarding
> stuff. If this feature already exists, can someone tell me the earliest
> version?

Interesting idea to have screen actually trigger it - I have tackled
that environment problem in a similar way, by (mis-)using sigINFO and
having a shell alias to trigger it. It's definitely zsh-specific, but
should be adaptable. ",," needs to be run before attaching the screen,
of course.

function ,, () {
        {
        local vars=''
        for a in TERM DISPLAY SSH_AUTH_SOCK SSH_CONNECTION XAUTHORITY ; do
                if [ -z "${(P)a}" ] ; then
                        echo "unset $a"
                else
                        echo "$a=\"${(P)a}\""
                        vars=($vars $a)
                fi
        done
        [ ! -z "$vars" ] && echo "export $vars"
        } > ~/.,
        kill -INFO `ps auxww| perl -anle '$F[0] eq $ENV{USER} && "@F[10..$#F]" 
=~ /zsh$/ && "/dev/tty$F[6]" ne "'$TTY'" && print $F[1]'`
        source ~/.,
}


sigINFOd=0

TRAPINFO () {
        up=$(tput up 2>/dev/null || tput cuu1 )
        if [[ -o zle ]] ; then
            zle -I
            if [[ "$sigINFOd" == "1" ]] ; then
                echo -n $up$up
            fi  
            . ~/.,
            echo "INFO: TERM=$TERM DISPLAY=$DISPLAY zle<"
            sigINFOd=1
        else    
            if [[ "$sigINFOd" == "1" ]] ; then
                echo -n $up
            fi  
            . ~/.,
            echo -n "INFO: TERM=$TERM DISPLAY=$DISPLAY nozle<\r"
        fi
}

precmd(){
        sigINFOd=0
}



CU,
        Sec
-- 
[ Recovering from a root breakin - someone says to cvsup and make world ]
Brandon S. Allbery: Not if cvsup itself has been trojaned.
John Polstra:       Cool, that would be one of the first code contributions
                    ever for CVSup. :-)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]