#!/usr/bin/perl -w # To use 'set-screen' (better names welcome), you run it in the shell # whose environment you want to take a snapshot of. This must be a # shell within the screen session and on the same host, but can be a # (sub)+shell of the original screen window, as long as the STY # environment variable is preserved. Then, when you create a new # window, all the environment variable settings and the working # directory for the new shell in the new window will be identical to # those for the old shell. This is handy when, for example, you want # to use ssh-agent settings, or DISPLAY settings, or whatever, which # have changed from what they were when you first started screen, but # you don't want to manually enter the "setenv" commands for each # variable. Or if you change your .zprofile to set some environment # variables differently, and want to make use of the changes in # previously-running screen sessions. Of course, it will only affect # new windows, not existing ones. # You can also do 'STY= set-screen' from a shell outside # of the screen session you want to modify. Anyway. It seems like this # functionality must be built in to screen, but I couldn't find it, # and I haven't looked elsewhere since it was so simple to write. use Cwd; use Getopt::Long; Getopt::Long::Configure ("bundling", "no_ignore_case"); my $sty = $ENV{STY}; my($help, @vars, $session, $chdir, $term, $all); GetOptions('-h|help' => \$help, '-E=s' => \@vars, '-c' => \$chdir, '-t' => \$term, '-S=s' => \$sty, '-a' => \$all, ) or exit 1; if($help) { print <