Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to present the GNU Screen session name and window title in the prompt of the shell (let us say, the Bash prompt defined by PS1)?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Screen supplies some environment variables (from screen(1) manpage):

STY              Alternate socket name.
WINDOW           Window number of a window (at creation time).

The "at creation time" means that if you renumber a window (using screen's number command), the shell will not be told about the change and $WINDOW will still be the same as the first window number.

You could use something like:

PS1='\u@\h(${STY}:${WINDOW}):\w$ '
share|improve this answer
1  
Perfect! This is what I was looking for. BTW, there is a way to get the window title, instead of the window number? –  brandizzi Sep 19 '11 at 1:13
    
Not that I know of, there is no api for screen, and when you issue commands there is no output - it goes to the current window in the screen. For example screen -xr 2466 -X windows. –  Arcege Sep 19 '11 at 1:26

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.