Reputation: 4269
I'm trying to write a script that makes GNU screen call virtualenvwrapper's workon
command to jump to an existing virtualenv based on the screen session name.
I've managed to make it work when the session starts, but I want to be able to run commands everytime a window is created, and I can't find hooks or anything similar to it.
Does screen allow a way to run commands everytime a window is created within a session?
Upvotes: 1
Views: 404
Reputation: 5346
Try putting the logic into your ~/.profile
(if using the deflogin on
setting) or ~/.mkshrc
(or similar, depending on your shell) file. Something like this:
if test -n "$STY"; then
# we are inside GNU screen
screenpid=${STY%%.*}
screenname=${STY#*.}
# do your magic
fi
In this scenario, $screenname
will contain either the name passed to the -S
option of GNU screen, or something like ttyp0.shorthostname
or pts-9.shorthostname
(depending on the OS) if -S
was not used.
Upvotes: 2