You are not logged in.
Anyone who uses GNU/screen knows how awesome it is. I use it mainly in two situations:
when i have one terminal connection (ssh) and want to multitask
when i have a process that i never want to lose (rtorrent, irssi) while logging in/out playing with X etc.
Yesterday, i came up with a pretty sweet way (i think) of using screen for both of these situations without
changing current habits (what commands i use day to day)
affecting current keybinds
using any crazy complicated scripts
I thought i'd share this with you guys in case anyone else can find it useful.
basically i set up one main ~/.screenrc which defines all my screen options (shell, term, hardstatus, etc). then i have separate "screenrc_extension" files that only define what tabs to load when screen starts. i then choose which "screenrc_extension" by use of environment variables
> grep ^source .screenrc
source "$SCREEN_CONF_DIR/$SCREEN_CONF"
> echo $SCREEN_CONF_DIR/$SCREEN_CONF
/home/patrick/.screen/configs/main
> cat .screen/configs/main
# example: screen -t [name] [command]
screen -t mail mutt
screen -t music ncmpcpp
#screen -t calendar wyrd
so here you can (hopefully) see that when i run screen in a clean environment it uses the two exported environment variables to call .screen/configs/main and load the tabs i want 90% of the time.
everything else happens in ~/.bashrc:
# dynamically choose which tabs load in screen
export SCREEN_CONF_DIR="$HOME/.screen/configs"
export SCREEN_CONF="main"
alias rtorrent='SCREEN_CONF=rtorrent screen -S rtorrent -D -R rtorrent'
alias irssi='SCREEN_CONF=irssi screen -S irssi -D -R irssi'
the aliases are key.
> SCREEN_CONF=irssi cat $SCREEN_CONF_DIR/$SCREEN_CONF
# example screen -t [name] [command]
screen -t irc irssi
> SCREEN_CONF=rtorrent cat $SCREEN_CONF_DIR/$SCREEN_CONF
# example: screen -t [name] [command]
screen -t torrents rtorrent
so when i type 'rtorrent' the alias will set the environment variable so the right 'screenrc_extension' is used, re attach any running rtorrent-screens here and now, or create one if needed. the -S names the session so that any subsequent -D -Rs can find and reattach it explicitly.
and the same thing happens for 'irssi' (or any other app you'd want to use with this approach).
so i can use the same three commands (screen, rtorrent, irssi) just as always and i get this super-convenient behavior.
//github/
Offline
Awesome! Will definitely give this a go tonight.
Offline
Looks cool. I use screen pretty much the same way you do, so your idea fits nicely
Offline
Thanks for posting this, I think this will help me get in to using screen regularly.
Last edited by Archangel-13 (2009-12-23 01:11:45)
Offline