9

I want to use a combination of the date and time at startup as filename for GNU screen's logfile. In screenrc, if I put

logfile '~/log/screen_%H_%m%d%Y_%0c-%t.%n'

I get a dynamically generated file, e.g.

screen_nanna13_06062012_08:03-bash.0

Now I want screen to display this filename in the hardstatus bar. I cannot use

hardstatus string '~/log/screen_%H_%m%d%Y_%0c-%t.%n'

because the placeholders are updated whenever the time changes.

The solutions I can come up with involve a bash code executed before screen-startup but that's not good because the separate screen-windows are supposed to get their own dynamic logfile.

Is there a variable-substitution mechanism in screen?

2 Answers 2

2

I found a solution using screen's backtick command:

backtick 1 0 0 date +%d%b%Y_%k:%M
logfile '~/log/%H_%1`-%t.%n'
hardstatus string '~/log/%H_%1`-%t.%n'

uses the UNIX date command to load the current date/time into the %1` variable. The only problem is, that the date does not change in the logfile's name in case a new window is created later during the session (but for me, that is even a feature because it allows for a better identification of the appropriate logfile).

1

This command is exactly what you are trying to achieve and it also changes the date in the logfile's name in case a new window is created:

backtick 1 1 0 /bin/date +%Y-%m-%d_%k.%M.%S # generate %1`
logfile '~/log/%H_%1`-%t.%n'
hardstatus string '~/log/screenlog_%H_%1`_win.%n.txt'

Source: Screen man page

PS. backtick 1 0 0 was not working at all in ver. 4.08.00 when I tried it. It just completely ignored it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .