How to properly launch tmux on terminal startup?
Clash Royale CLAN TAG#URR8PPP
I've used this snippet to launch tmux when the terminal is launched:
# TMUX startup
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
fi
But with this I can't exit tmux without the terminal screen being closed too.
I've tried:
Ctrl + b :detach
exit
And looking for the PID and killing it. All those methods close the terminal too.
How should I configure tmux to start when launching the terminal but still being able to close it without the terminal closing? Any tips are appreciated!
command-line bash shortcut-keys bashrc tmux
add a comment |
I've used this snippet to launch tmux when the terminal is launched:
# TMUX startup
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
fi
But with this I can't exit tmux without the terminal screen being closed too.
I've tried:
Ctrl + b :detach
exit
And looking for the PID and killing it. All those methods close the terminal too.
How should I configure tmux to start when launching the terminal but still being able to close it without the terminal closing? Any tips are appreciated!
command-line bash shortcut-keys bashrc tmux
I've just tried and replacing the snipped I used with justtmux
works, but I get a:sessions should be nested with care, unset $TMUX to force
. I've also tried leaving the snipped I used as it is and adding atmux
at the end of the~/.bashrc
but then detaching still exits the terminal.
– bpinaya
Feb 19 at 10:37
add a comment |
I've used this snippet to launch tmux when the terminal is launched:
# TMUX startup
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
fi
But with this I can't exit tmux without the terminal screen being closed too.
I've tried:
Ctrl + b :detach
exit
And looking for the PID and killing it. All those methods close the terminal too.
How should I configure tmux to start when launching the terminal but still being able to close it without the terminal closing? Any tips are appreciated!
command-line bash shortcut-keys bashrc tmux
I've used this snippet to launch tmux when the terminal is launched:
# TMUX startup
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
fi
But with this I can't exit tmux without the terminal screen being closed too.
I've tried:
Ctrl + b :detach
exit
And looking for the PID and killing it. All those methods close the terminal too.
How should I configure tmux to start when launching the terminal but still being able to close it without the terminal closing? Any tips are appreciated!
command-line bash shortcut-keys bashrc tmux
command-line bash shortcut-keys bashrc tmux
edited Feb 19 at 10:26
dessert
24.6k672105
24.6k672105
asked Feb 19 at 10:25
bpinayabpinaya
608
608
I've just tried and replacing the snipped I used with justtmux
works, but I get a:sessions should be nested with care, unset $TMUX to force
. I've also tried leaving the snipped I used as it is and adding atmux
at the end of the~/.bashrc
but then detaching still exits the terminal.
– bpinaya
Feb 19 at 10:37
add a comment |
I've just tried and replacing the snipped I used with justtmux
works, but I get a:sessions should be nested with care, unset $TMUX to force
. I've also tried leaving the snipped I used as it is and adding atmux
at the end of the~/.bashrc
but then detaching still exits the terminal.
– bpinaya
Feb 19 at 10:37
I've just tried and replacing the snipped I used with just
tmux
works, but I get a: sessions should be nested with care, unset $TMUX to force
. I've also tried leaving the snipped I used as it is and adding a tmux
at the end of the ~/.bashrc
but then detaching still exits the terminal.– bpinaya
Feb 19 at 10:37
I've just tried and replacing the snipped I used with just
tmux
works, but I get a: sessions should be nested with care, unset $TMUX to force
. I've also tried leaving the snipped I used as it is and adding a tmux
at the end of the ~/.bashrc
but then detaching still exits the terminal.– bpinaya
Feb 19 at 10:37
add a comment |
1 Answer
1
active
oldest
votes
The problem is the exec
command. As explained here, exec
will replace the current shell with whatever you tell it execute. So you don't have a shell that is running tmux
, you just have tmux
and therefore exiting it will also exit the terminal.
Just remove the exec
and it should work as expected:
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && tmux
fi
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1119478%2fhow-to-properly-launch-tmux-on-terminal-startup%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is the exec
command. As explained here, exec
will replace the current shell with whatever you tell it execute. So you don't have a shell that is running tmux
, you just have tmux
and therefore exiting it will also exit the terminal.
Just remove the exec
and it should work as expected:
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && tmux
fi
add a comment |
The problem is the exec
command. As explained here, exec
will replace the current shell with whatever you tell it execute. So you don't have a shell that is running tmux
, you just have tmux
and therefore exiting it will also exit the terminal.
Just remove the exec
and it should work as expected:
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && tmux
fi
add a comment |
The problem is the exec
command. As explained here, exec
will replace the current shell with whatever you tell it execute. So you don't have a shell that is running tmux
, you just have tmux
and therefore exiting it will also exit the terminal.
Just remove the exec
and it should work as expected:
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && tmux
fi
The problem is the exec
command. As explained here, exec
will replace the current shell with whatever you tell it execute. So you don't have a shell that is running tmux
, you just have tmux
and therefore exiting it will also exit the terminal.
Just remove the exec
and it should work as expected:
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && tmux
fi
answered Feb 19 at 11:21
terdon♦terdon
67k13139221
67k13139221
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1119478%2fhow-to-properly-launch-tmux-on-terminal-startup%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I've just tried and replacing the snipped I used with just
tmux
works, but I get a:sessions should be nested with care, unset $TMUX to force
. I've also tried leaving the snipped I used as it is and adding atmux
at the end of the~/.bashrc
but then detaching still exits the terminal.– bpinaya
Feb 19 at 10:37