1

In my .zshrc, I have ENABLE_TMUX="TRUE" for one of the lines. This doesn't seem to work, as tmux never launches on a new shell, and the environment variable ENABLE_TMUX is always false when I start a shell. The rest of my zshrc works fine, however. I'm not sure why this wouldn't work.

### START TMUX IF ENABLED ABOVE ###
if [ "$ENABLE_TMUX" = "TRUE" ]; then
    # start tmux if not already running
    if [[ ! "$TTY" =~ "/dev/tty" ]]; then
        case $(ps -p $(ps -p $$ -o ppid=) o args=) in
            tmux*|*vscode*|*xterm*|*kdevelop*|*ascii*)
                sleep 0
                ;;
            *)
                tmux
                ;;
        esac
    fi
fi
###

This is the function that starts tmux. Not sure what's wrong here, if anything. I am on Xubuntu 18.04.

  • I've just tried it and it works for me, make sure that this function is run at all by adding several printfs or echos here and there and if it is that means you do not enter if condition at all or enter the first case or tmux fails to start. Try to run tmux in interactive shell first to make sure. – Arkadiusz Drabczyk Apr 29 at 19:33
  • Sorry, I missed that you said that ENABLE_TMUX is always FALSE - it means that it has be explicitly set to FALSE somewhere before reaching this function as variables do not take FALSE as value implicitly. Try to do ENABLE_TMUX=TRUE in the line above if [ "$ENABLE_TMUX" = "TRUE" ]; then and it should work. You could also show your entire ~/.zshrc if you are not sure what's going on. – Arkadiusz Drabczyk Apr 29 at 19:39
  • Not sure what's causing it to reset itself before the function, but setting it to true immediately before the function works. I'll dig through my zshrc and try to find what was causing the problem, but this is fine too. Thanks! – Luke Meissner Apr 29 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.