开发者

Is there a command that will tell me what screen/tmux session I'm in?

I use screen, but am willing to switch to tmux if it and only it has this functionality.

I have a screen named "X", and also other screens with different names. I would like a script to execute something different 开发者_运维百科based on which screen it is run from. I would like to use a command such as:

screen name_of_current

To tell me the name of the screen (if any) I am currently in. Does such a thing exist in screen or tmux?


You can use $TMUX which will tell you where the window was when it was originally created. But if you've moved it or linked it into multiple sessions it'll be inaccurate.

You can also use eg tmux display -p '#S' but although the session should be accurate other items (such as #W #I #P) are the CURRENT window and pane not necessarily where the command was run.

In the Subversion repository latest of tmux, each pane has a unique identifier in $TMUX_PANE so you can then do:

$ tmux display -pt $TMUX_PANE '#S:#I.#P'

Which should be accurate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜