gpakosz / .tmux

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

Not reading main tmux.conf #645

Closed naturedamends closed 1 year ago

naturedamends commented 1 year ago

this is ran inside a docker container, ubuntu:latest. i've seen it work, not sure what's happened.

Its not working even if I link tmux.conf to ~/.tmux.conf

 tmux -V
tmux 3.2a

setup script:

set -e

OM_TMUX="$HOME/.oh-my-tmux"
git clone https://github.com/gpakosz/.tmux.git "$OM_TMUX"

TMUX_CONF_FOLDER="$HOME/.config/tmux"
TMUX_MAIN_CONF="$TMUX_CONF_FOLDER/tmux.conf"

# install gloabl my-oh-tmux tmux conf
mkdir -p "$TMUX_CONF_FOLDER"
ln -s "$OM_TMUX/.tmux.conf" "$TMUX_MAIN_CONF"

# install user config
TMUX_LOCATION="$TMUX_MAIN_CONF.local"
[ -L "$TMUX_LOCATION" ] && rm "$TMUX_LOCATION"
ln -s "$DOTFILES_SHARED/.tmux.conf" "$TMUX_LOCATION"
ls -la ~/.config/tmux
total 12
drwxr-xr-x 2 natured natured 4096 May  8 08:58 .
drwxr-xr-x 1 natured natured 4096 May  8 09:01 ..
lrwxrwxrwx 1 natured natured   36 May  8 08:58 tmux.conf -> /home/natured/.oh-my-tmux/.tmux.conf
lrwxrwxrwx 1 natured natured   59 May  8 08:58 tmux.conf.local -> /home/natured/repos/dotfiles/machines/env/shared/.tmux.conf
ls -la
total 320
drwxr-x--- 1 natured natured   4096 May  8 09:49 .
drwxr-xr-x 1 root    root      4096 May  7 17:49 ..
-rw-r--r-- 1 natured natured    220 Jan  6  2022 .bash_logout
-rw-r--r-- 1 natured natured   3823 May  7 07:16 .bashrc
drwxr-xr-x 7 natured natured   4096 May  8 09:03 .cache
drwxr-xr-x 1 natured natured   4096 May  8 09:01 .config
drwxr-xr-x 4 natured natured   4096 May  8 09:01 .dotnet
drwxr-x--- 1 natured natured   4096 May  8 09:02 .local
drwxr-xr-x 4 natured natured   4096 May  8 08:58 .npm
drwxr-xr-x 3 natured natured   4096 May  8 09:01 .nuget
drwxr-xr-x 4 natured natured   4096 May  8 08:58 .oh-my-tmux
drwxr-xr-x 1 natured natured   4096 May  8 08:58 .oh-my-zsh
-rw-r--r-- 1 natured natured    807 Jan  6  2022 .profile
drwxr-xr-x 1 root    root      4096 May  8 08:57 repos
drwxr-xr-x 3 natured natured   4096 May  8 08:58 .ssh
-rw-r--r-- 1 natured natured      0 May  8 08:58 .sudo_as_admin_successful
drwxr-xr-x 3 natured natured   4096 May  8 09:02 .vim
drwxr-xr-x 3 natured natured   4096 May  8 09:03 .yarn
-rw-r--r-- 1 natured natured  49213 May  8 09:41 .zcompdump
-rw-r--r-- 1 natured natured  51406 May  8 09:41 .zcompdump-63131fbcbc05-5.8.1
-r--r--r-- 1 natured natured 117560 May  8 09:41 .zcompdump-63131fbcbc05-5.8.1.zwc
lrwxrwxrwx 1 natured natured     58 May  8 08:58 .zshenv -> /home/natured/repos/dotfiles/machines/env/dev/variables.sh
-rw------- 1 natured natured    364 May  8 09:49 .zsh_history
-rw-r--r-- 1 natured natured    318 May  8 08:58 .zshrc

So i'm just left with the default image

I can force it to use the config by passing it path as a argument via the tumx -f flag. So it works fine.

If i source-file I get the following image

I have added to the user conf section of the .local

# start with mouse mode enabled
set -g mouse on
set -g default-shell /usr/bin/zsh
gpakosz commented 1 year ago

Hello @naturedamends 👋

I'm sorry I have no idea what's going on. Please,

From there, we'll be able to figure it out.

gpakosz commented 1 year ago

BTW what's this _zsh_tmux_plugin_run window title?

naturedamends commented 1 year ago

@gpakosz

Then follow the manual installation instructions listed in

I've tried my best

Make sure you have no tmux procress running

I can confirm there was no existing sessions.

This is a fresh container, created with a docker file. I'll try to create a minimal docker file that produces the same, since the image i'm using has some stuff in there I don't want to export publicly.

It was working in this docker container which Is why i'm not understanding. The only thing that has changed is i've installed zsh and oh-my-zsh

BTW what's this _zsh_tmux_plugin_run window title?

Not sure, it may be related to Iterm Tmux intergration oh-my-zsh, however I was expecting that to work out of the box

https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/tmux/tmux.plugin.zsh

: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
# Wrapper function for tmux.
function _zsh_tmux_plugin_run() {
  if [[ -n "$@" ]]; then
    command tmux "$@"
    return $?
  fi

  local -a tmux_cmd
  tmux_cmd=(command tmux)
  [[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
  [[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u)

  # Try to connect to an existing session.
  if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
    [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach -t $ZSH_TMUX_DEFAULT_SESSION_NAME
  else
    [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach
  fi

  # If failed, just run tmux, fixing the TERM variable if requested.
  if [[ $? -ne 0 ]]; then
    if [[ "$ZSH_TMUX_FIXTERM" == "true" ]]; then
      tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG")
    elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
      tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
    fi
    if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
      $tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME
    else
      $tmux_cmd new-session
    fi
  fi

  if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then
    exit
  fi
}
naturedamends commented 1 year ago

BTW what's this _zsh_tmux_plugin_run window title?

Running

command tmux

Produces the expected output. 🥇 thanks. Not sure if this is upstream. But feel free to close 👍

Can confirm changing your config variable before oh-my-zsh is loaded works

╰─⠠⠵ echo "$ZSH_TMUX_CONFIG"
/home/natured/.config/tmux/tmux.conf
╭─natured at trusty in ~/repos/workspace/dotfiles on feature/staging✔ 23-05-08 - 17:05:16
╰─⠠⠵ tmux

@gpakosz https://github.com/gpakosz/.tmux/pull/648 here's a pr if you want to merge it. Keep up the good work.

deepanchal commented 1 year ago

Setting $ZSH_TMUX_CONFIG in ~/.zshrc doesn't work. You will have to set this env var in your ~/.zshenv file. See: https://zsh.sourceforge.io/Intro/intro_3.html?ref=zerotohero.dev

# ZSH Config Vars
export ZSH_TMUX_CONFIG="$XDG_CONFIG_HOME/tmux/tmux.conf"
bubanoid commented 11 months ago

I faced a very similar problem.

tmux -V
tmux 3.3a

I have zsh as a default shell, oh-my-zsh is installed too, but without tmux plugin. I followed the instructions and installed oh-my-tmux in the ~/.config/tmux folder. Unfortunately, it doesn't work out of the box. Isn't there missing some steps in the instructions?

It looks like it is necessary to create a soft link for the ~/.tmux.conf file or set TMUX_CONF and TMUX_CONF_LOCAL to the ~/.config/tmux/tmux.conf and ~/.config/tmux/tmux.conf.local correspondently.

naturedamends commented 11 months ago

I faced a very similar problem.

tmux -V

tmux 3.3a

I have zsh as a default shell, oh-my-zsh is installed too, but without tmux plugin. I followed the instructions and installed oh-my-tmux in the ~/.config/tmux folder. Unfortunately, it doesn't work out of the box. Isn't there missing some steps in the instructions?

It looks like it is necessary to create a soft link for the ~/.tmux.conf file or set TMUX_CONF and TMUX_CONF_LOCAL to the ~/.config/tmux/tmux.conf and ~/.config/tmux/tmux.conf.local correspondently.

Tell the plug-in about your config location? https://github.com/gpakosz/.tmux/pull/648m

bubanoid commented 11 months ago

I identified the root cause of my issue. I created an empty ~/.tmux.conf and missed that completely. When attempting to apply the correct tmux configuration file located in any other than the home directory it has no effect. This was due to the TMUX_CONF environment variable being set to the existing ~/.tmux.conf file. So, I needed to remove the ~/.tmux.conf file first.

Sorry for bothering you.