★ wanayoo — archive 1999 https://github.com/tmux-python/tmuxp/issues/634Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I set the session_name dynamically based on the current directory? #634

Open
sluther-electro opened this issue Oct 25, 2020 · 2 comments

Comments

@sluther-electro
Copy link

@sluther-electro sluther-electro commented Oct 25, 2020

I've created a shared tmux config in ~/.tmuxp/org.yml. I'd like to set the session_name dynamically based on the directory I'm launching tmux from using a shared config file.

I.e. if my path is /Users/sluther/Projects/org/project_1 and I use tmuxp load org to start tmux, I want the session_name to be set to project_1. I've tried the following:

Here's my before-org.sh script

#!/bin/sh
export TMUX_SESSION_NAME=${PWD##*/}

And here's my org.yml file:

session_name: "$TMUX_SESSION_NAME"
start_directory: "$PWD"
before_script: ~/.tmuxp/org-before.sh

Is there any way to make this work?

@akoerner
Copy link

@akoerner akoerner commented Oct 28, 2020

Without any extra elaborate thoughts envsubst could be used along with bash process substitution :
https://unix.stackexchange.com/questions/294835/replace-environment-variables-in-a-file-with-their-actual-values

And its supported natively ...
https://tmuxp.git-pull.com/examples.html#environment-variable-replacing

@joseph-flinn
Copy link
Member

@joseph-flinn joseph-flinn commented Oct 31, 2020

@sluther-electro Unfortunately, I don't see a way that the session name can be dynamically set in the current release of tmuxp (1.5.6). However, version 1.6.0 is in the works and is about ready to be released and it includes a plugin system that provides hooks into the libtmux objects, the session object being one of those. Renaming the session could be supported through a plugin.

Let me know if you are interested in getting a jump start on developing a plugin and I can send over screenshots/html of the documentation for the Plugin System of version 1.6.0. To get a sneak peek, you could go take a look at the changes being worked on here: https://github.com/joseph-flinn/tmuxp/tree/plugin-system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.