GNU Screen as a default shell for remote account
Forum » Personal / Blog » GNU Screen as a default shell for remote account
Started by: dpcdpc
On: 1266450250|%e %b %Y, %H:%M %Z|agohover
Number of posts: 5
rss icon RSS: New posts
Summary:
I have a shell account on great polish shell account provider: Rootnode. Today I've discovered a way to greatly improve the way I work with it from multiple locations. I use a GNU Screen as default-like shell in a multi-view mode.
GNU Screen as a default shell for remote account
dpcdpc 1266450250|%e %b %Y, %H:%M %Z|agohover

Everything is nicely scripted in .bashrc.screen:

if [[ $- != *i* ]] ; then
        # Shell is non-interactive.  Be done now!
        return
fi

if [[ "$IN_THE_SCREEN" != "TRUE" ]]; then
        export IN_THE_SCREEN="TRUE"
        exec screen -xRR -S main
fi

As I use bash as a default shell, I plug this code into .bashrc with just one line:

[ -f "$HOME/.bashrc.screen" ] && source "$HOME/.bashrc.screen"

This way I don't have to remember about running screen manually which obviously has many advantages. And I can connect/disconnect from multiple locations and work on one default session without disconnecting any ssh client already connected. It's like remote desktop session - only for shell account.

Last edited on 1266965871|%e %b %Y, %H:%M %Z|agohover By dpc + Show more
Reply  |  Options
Unfold GNU Screen as a default shell for remote account by dpcdpc, 1266450250|%e %b %Y, %H:%M %Z|agohover
Re: GNU Screen as a default shell for remote account
dpcdpc 1277143107|%e %b %Y, %H:%M %Z|agohover

Actually, my .bashrc.screen now looks more like this:

if [[ $- != *i* ]] ; then
        # Shell is non-interactive.  Be done now!
        return
fi

# if in the shell - set tab caption to hostname
[[ "${TERM%%-*}" == "screen" ]] && {
        screen -X title "${HOSTNAME%%.*}"
        ssh() { screen -X title "${1##*@}"; command ssh "$@"; screen -X title "${HOSTNAME%%.*}";}
}

# if connected remotely - spawn/attache to screen for ssh session
# don't do this if already done
if [[ ! -z "$SSH_TTY" ]]; then
        if [[ "$SSH_IN_THE_SCREEN" != "TRUE" ]]; then
                export SSH_IN_THE_SCREEN="TRUE"
                exec screen -xRR -S ssh
        fi
fi
Reply  |  Options
Unfold Re: GNU Screen as a default shell for remote account by dpcdpc, 1277143107|%e %b %Y, %H:%M %Z|agohover
Re: GNU Screen as a default shell for remote account
seb (guest) 1283544528|%e %b %Y, %H:%M %Z|agohover

Thanks very useful :)

Maybe you could help me a little more?
On my laptop, i run screen and connect to my desktop using your script.
I have a screen in another, a CTRL-A CTRL-C create a new screen on my laptop (The first one).
Is there a way to control one screen or another?

btw thank you for the trick

Reply  |  Options
Unfold Re: GNU Screen as a default shell for remote account by seb (guest), 1283544528|%e %b %Y, %H:%M %Z|agohover
Re: GNU Screen as a default shell for remote account
dpcdpc 1283605427|%e %b %Y, %H:%M %Z|agohover

The @ sign after normal Ctrl+Space is like Ctrl+Space for inner screen so the combination to do what you like is:

Ctrl + Space, @, c

If you had 3 nested screens that would be:

Ctrl + Space, @, @, c
Unfold Re: GNU Screen as a default shell for remote account by dpcdpc, 1283605427|%e %b %Y, %H:%M %Z|agohover
Re: GNU Screen as a default shell for remote account
dpcdpc 1283607613|%e %b %Y, %H:%M %Z|agohover

You may want to take a look at this:
http://github.com/dpc/homeskel/

Reply  |  Options
Unfold Re: GNU Screen as a default shell for remote account by dpcdpc, 1283607613|%e %b %Y, %H:%M %Z|agohover
New Post
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License