Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Awesome bash+screen config, great for nested sessions
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Triffid Hunter
n00b
n00b


Joined: 28 Oct 2005
Posts: 4
Location: brisbane, australia

PostPosted: Sun Aug 13, 2006 10:56 am    Post subject: Awesome bash+screen config, great for nested sessions Reply with quote

For a nice status bar at the bottom of every screen session:

Code:
/etc/screenrc
+++ hardstatus alwayslastline "[ %c ][ %-w%{= KW}%50>%n \0337\033]2;%t\007\0338%t%{-}%+w%< ]" # if you just want terminal title updated
OR
+++ hardstatus alwayslastline "[ %c ][ %-w%{= KW}%50>%n \0337\033]2;%t\007\033k%t\033\\\0338%t%{-}%+w%< ]" # if you want both terminal title and parent screen window title updated when nesting screens

/etc/bash/bashrc
+++ # for screen
+++ if [[ ${EUID} == 0 ]] ; then
+++     PS1="\[\0337\033]2;\h\007\033k\h\033\134\0338\]$PS1"
+++ else
+++     PS1="\[\0337\033]2;\u@\h\007\033k\u@\h\033\134\0338\]$PS1"
+++ fi

Note that screen doesn't have any equivalent to bash's \[ and \] so you get a space at the end of the bar equal to the width of the title(s).

And to start/resume screen sessions at every login (NOT for root accounts):
Code:
~/.bash_profile, /etc/skel/.bash_profile:
# /etc/skel/.bash_profile:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/skel/.bash_profile,v 1.10 2002/11/18 19:39:22 azarah Exp $

+++ # either use the line below, or set each user's shell to /usr/bin/screen.
+++ # this is a TERRIBLE idea to apply to root accounts.
+++ exec screen -RR -s /bin/bash
+++ # or exec screen -xRR -s /bin/bash to always attach to the same session, even if multiple ssh sessions are opened simultaneously (same as setting shell to /usr/bin/screen)
+++
# the exec above stops this from occurring, leave it in as a fall-through though
#This file is sourced by bash when you log in interactively.
[ -f ~/.bashrc ] && . ~/.bashrc



The bar looks like this with nested screens:
(with terminal title only hardstatus line) wrote:
triffid@anteline ~ $
[ 20:43 ][ 0 triffid@anteline ]
[ 20:43 ][ 0 triffid@peladrine 1 triffid@peladrine ]
[ 20:43 ][ 0 triffid@lucienne 1 triffid@lucienne 2 triffid@phenix 3 triffid@godzilla 4 lucienne ]

(with parent title update hardstatus line) wrote:
triffid@anteline ~ $
[ 20:43 ][ 0 triffid@anteline ]
[ 20:43 ][ 0 triffid@peladrine 1 triffid@anteline ]
[ 20:43 ][ 0 triffid@anteline 1 triffid@lucienne 2 triffid@phenix 3 triffid@godzilla 4 lucienne ]

which as you can see, tells you exactly where you are at all times.

Comments, improvements, suggestions, fixes, other cool tricks are all welcome :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum