[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: session save to disk?
From: |
David Collins |
Subject: |
Re: session save to disk? |
Date: |
Tue, 1 Sep 2009 20:22:52 +0100 |
Hi Gereld, thanks for sending me your scripts. I haven't had time to
go through it yet but it looks very complete.
My script is considerably less functional. As it stands it needs to be
executed in each shell open in the screen session. The script will
basically dump the pwd, a supplied title, and supplied command into a
screenrc file
-f will remove a previous file
-t will set the title
-l is used on the last shell to tell the file to source the main screenrc
-- `command` is used to execute a command on startup
I didn't really think about my options too much when I wrote this and
most of the hard work could be done by just parsing the window list
and some screen -X magic do it all a lot easier.
Here it is anyway
-----------------------------------8<---------------------------------------------
#!/bin/bash
## if screen needs to be reopened and x window has been
## disconnected use this:
## in the first window run screen_open -f and run
## screen_open in the rest. In the last run
## screen_open -l.
## this will create a file $screen_open_file that contain
## the current pwds. when screen is run it will source
## this file and open all the window in the wanted dir
## if command is supplied with -c that will be run also
##
## screen_open [-f] [-l] [-t title] [-- command]
##
last=0
command=""
name=`basename $SHELL`
nameset=0
screen_open_file='/tmp/screen_open'
for f in $*; do
if [[ $f = -f ]]; then
echo "First window"
[ -f $screen_open_file ] && rm $screen_open_file
shift
fi
if [[ $f = -l ]]; then
echo "Last window"
last=1
shift
fi
if [[ $f = -t ]]; then
echo "Window name"
shift
name=$1
shift
fi
done
## collect commands
command=$*
echo chdir `pwd` >>
$screen_open_file
echo screen -t $name $WINDOW >> $screen_open_file
[ "$command" ] && echo stuff "'$command'^M">> $screen_open_file
if [ $last -eq 1 ]; then
echo chdir $HOME >> $screen_open_file
echo source ~/.screenrc >>
$screen_open_file
fi
- Re: session save to disk?,
David Collins <=