gpakosz / .tmux

🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
MIT License
21.73k stars 3.34k forks source link

Create predefined sessions on `tmux` start #688

Closed ww7 closed 8 months ago

ww7 commented 8 months ago

I want to have some predefined named sessions at tmux start, added to .tmux.local

new-session -d -s dummy # to start session index from 1
new-session -d -s w # locals
new-session -d -s s # remotes

(also tried to add -A)

But after config reload via prefix+r shows error:

'"$TMUX_PROGRAM" source "$TMUX_CONF_LOCAL"' returned 1

At the same time, config reloads. Would it be possible to omit or suppress this error?

ww7 commented 8 months ago

Command

run '"$TMUX_PROGRAM" has-session -t dummy 2>/dev/null || tmux new-session -A -s dummy -d; tmux attach-session -t dummy'

Also shows same error.

gpakosz commented 8 months ago

Hello @ww7 👋

I did try to add the same command you're mentioning to my .local customization files and there's no error. You likely added something else.

Please make sure your didn't alter the .conf file and maybe try again with a stock .local file.

ww7 commented 8 months ago

Hello @gpakosz

On my side the same error with fresh Oh my tmux!

Seems config reload trying to create a session when it already exists.

gpakosz commented 8 months ago

Seems config reload trying to create a session when it already exists.

Does it happen without using Oh my tmux!?

What OS are you using btw?

ww7 commented 8 months ago

@gpakosz

What OS are you using btw?

macOS Sonoma and Linux Ubuntu 20.04, on both reload of config shows error, on latestOh my tmux!

Does it happen without using Oh my tmux!?

On such empty .tmux.conf

new -A -d -s dummy 
bind r run '/usr/bin/tmux source /root/.tmux.conf'
set-option -g detach-on-destroy off

resulting '/usr/bin/tmux source /root/.tmux.conf' returned 1

ww7 commented 8 months ago

As the previous Tmux configuration-based approach makes error, I solved this with Bash functions.