Timeline for Executing script only on terminal startup with tmux
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 7, 2023 at 11:12 | answer | added | grawity_u1686 | timeline score: 0 | |
Sep 27, 2020 at 18:26 | comment | added | gilbertohasnofb |
Everything that comes after [[ -z "$TMUX" ]] && exec tmux is execute inside tmux though, e.g. [[ -z "$TMUX" ]] && exec tmux; echo "inside tmux" . But after the first line the $TMUX variable is set and so I can't use that as a conditional for the echo in this example (or script in my original case)
|
|
Sep 27, 2020 at 18:23 | comment | added | gilbertohasnofb | @dirkt Thanks for the info. Would you have any suggestion on how to tackle this then? | |
Sep 27, 2020 at 17:24 | comment | added | dirkt |
Because exec replaces the current process with the called process, so after exec , nothing in the script gets executed. Also, even if you drop exec , nothing of that will get executed "inside" tmux .
|
|
Sep 27, 2020 at 15:27 | comment | added | gilbertohasnofb |
Thank you for your reply. I tried using the solutions discussed in that post but unfortunately it did not work out for me. I will try to research what could be done through gnome terminal, but I am puzzled as to why my simple .bashrc solution doesn't work. The main question for me is how to execute a script inside tmux immediately after exec tmux is summoned. (I made some edits in my question above)
|
|
Sep 27, 2020 at 15:26 | history | edited | gilbertohasnofb | CC BY-SA 4.0 |
added 562 characters in body
|
Sep 27, 2020 at 10:27 | comment | added | dirkt |
Does this answer help? You can detect if the shell is started within tmux or not, so that should allow you to choose which scripts to run. Another option is to configure the terminal to run some other command instead of just a plain shell (instead of useing bashrc for that), though I have no idea how to do that in Gnome terminal, as I don't use Gnome terminal.
|
|
Sep 27, 2020 at 0:55 | history | asked | gilbertohasnofb | CC BY-SA 4.0 |