2

is there a way to send/pass the current window number to a backtick command in GNU screen? Or would I have to use a different terminal multiplexer?

Thank you.

Edit:

This is my backtick:

backtick 0 2 2 $HOME/bin/status/status

Inside my "hardstatus string" line the backtick is inserted:

hardstatus string "... %{=b dw}[ %{-b dc}%0`%{=b dw} ]"

Inside the status script (more precisely inside scripts run by $HOME/bin/status/status) I would like to know which window is currently shown.

1
  • Please elaborate. What would you like to do with the screen number? Aug 17, 2010 at 10:52

1 Answer 1

3

From the environment section of the screen man page, the WINDOW environment variable contains "Window number of a window (at creation time)." Note that this will not be available if you su - within the window (or otherwise wipe out the environment of your user).


If you're trying to add a visual indicator of the current window by inserting the window number in the shell prompt, do you know that the status line at the bottom of the screen can show you this?

Here's the bit from my .screenrc file which configures this for me:

# An alternative hardstatus to display a bar at the bottom listing the
# window names and highlighting the current window name in blue. 
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %l %m/%d %c "

The string escapes section of the man page goes into more detail about what you can put into the status line.

5
  • Thanks for the environmnet hint. Unfortunately WINDOW is only set for the corresponding terminal, the backtick script has the original environment. Passing %n as an argument in the backtick definition line doesn't work either.
    – exic
    Aug 17, 2010 at 14:38
  • Can you elaborate on what you're trying to accomplish? Aug 17, 2010 at 15:01
  • I'd like to do something like this: if current-screen-windownumber is 1 then delete some log file.
    – exic
    Aug 18, 2010 at 9:35
  • 1
    Something about that strikes me as odd. I view screen as a mere presentation tool -- not tightly integrated with the functionality of the system. By deleting a log file based on which screen you're currently looking at, you're combining the two. If you're logging output of a command running within screen you could either redirect the output to a file (optionally using tee so that you could watch also) or you could use screen's log command to capture the output. Aug 19, 2010 at 18:55
  • Thanks, nice one! Oct 11, 2022 at 10:00

You must log in to answer this question.

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