Skip to content

Commit 5a223f1

Browse files
bcottonjoshmedeski
authored andcommitted
feat: add SESH_SESSION_NAME environment variable
When creating new tmux sessions, sesh now automatically sets the SESH_SESSION_NAME environment variable to the name of the session. This enables scripts and programs to know the current session name. - Add -e SESH_SESSION_NAME to tmux new-session command - Document the new feature in README.md under Environment Variables section
1 parent c6bea95 commit 5a223f1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ startup_command = "nvim tmux.conf"
273273
preview_command = "bat --color=always ~/c/dotfiles/.config/tmux/tmux.conf"
274274
```
275275

276+
### Environment Variables
277+
278+
When creating a new tmux session, sesh now automatically sets the `SESH_SESSION_NAME` environment variable to the name of the session. This can be useful for scripts or programs that need to know the current session name.
279+
276280
### Listing Configurations
277281

278282
Session configurations will load by default if no flags are provided (the return after tmux sessions and before zoxide results). If you want to explicitly list them, you can use the `-c` flag.
@@ -308,3 +312,4 @@ Made with [contrib.rocks](https://contrib.rocks).
308312
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=joshmedeski/sesh&type=Date" />
309313
</picture>
310314
</a>
315+

tmux/tmux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (t *RealTmux) SendKeys(targetPane string, keys string) (string, error) {
3939
}
4040

4141
func (t *RealTmux) NewSession(sessionName string, startDir string) (string, error) {
42-
return t.shell.Cmd("tmux", "new-session", "-d", "-s", sessionName, "-c", startDir)
42+
return t.shell.Cmd("tmux", "new-session", "-d", "-s", sessionName, "-c", startDir, "-e", "SESH_SESSION_NAME="+sessionName)
4343
}
4444

4545
func (t *RealTmux) CapturePane(targetSession string) (string, error) {

0 commit comments

Comments
 (0)