Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Please elaborate. What would you like to do with the screen number? –  Doug Harris Aug 17 '10 at 10:52

1 Answer 1

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.

share|improve this answer
    
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 '10 at 14:38
    
Can you elaborate on what you're trying to accomplish? –  Doug Harris Aug 17 '10 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 '10 at 9:35
    
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. –  Doug Harris Aug 19 '10 at 18:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.