tmux provides a number of commands in the shell such as rename-session which operate on the session that the invoking shell belongs to.

It also provides commands like list-clients which list out the different tmux sessions that are currently running.

I am looking for a command along the lines of tmux pwd which will echo out the name of the tmux session to which my active shell session belongs.

e.g. Inside tmux session foo:

$ tmux pwd

Is there a command for this, or a roundabout way to get it?


Try executing this inside your tmux session:

tmux display-message -p '#S'


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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