tmuxinator / tmuxinator

Manage complex tmux sessions easily
MIT License
12.55k stars 627 forks source link

Don't run the commands appropriately #856

Open devrrior opened 2 years ago

devrrior commented 2 years ago

Describe the bug When I start one of my projects, the commands which I set to run in the panes don't run correctly.

To Reproduce Just run tmuxinator start project

Expected behavior I expected my windows to execute the commands correctly.

Environment

Additional information

image image image image

My config

name: chat-message
root: ~/repos/chat-messages
on_project_start: docker-compose up -d
# on_project_exit: docker-compose down

windows:
  - frontend:
      root: ~/repos/chat-messages/frontend
      panes:
        - editor:
            - vim +'Telescope find_files'

  - backend:
      root: ~/repos/chat-messages/backend
      panes:
        - editor:
            - vim +'Telescope find_files'

  - server:
      layout: main-vertical
      panes:
        - react-server:
            - cd frontend/
            - clear
            - docker-compose logs --follow frontend

        - backend-server:
            - cd backend/
            - clear
            - docker-compose logs --follow backend
devdrops commented 2 years ago

Same issue here. I'm suspicious that this issue may happens on MacOS only, because this issue does not happen on my Linux environment.

Config file:

# /Users/davimarcondesmoreira/.config/tmuxinator/my-dotfiles.yml

name: my-dotfiles
root: /Users/davimarcondesmoreira/Projects/Devdrops/etc/my-dotfiles

on_project_start: git fetch --all
startup_window: VIM
windows:
  - VIM: vim .
  - ENV:
    layout: even-horizontal
    panes:
      - git status
      - git status
  - GIT:
    layout: main-horizontal
    panes:
      - CURRENT_STATUS:
        - git status -u
      - FILES_AND_TIME:
        - tmux split-window -t 2.1 -h
        - tmux resize-pane -t 2.1 -R 40
        - tmux clock-mode -t 2.2
        - tmux send-keys -t 2.1 "git diff origin/main...`git rev-parse --abbrev-ref HEAD` --name-only --diff-filter=AM" Enter

Output from show-messages:

11:13: /dev/ttys000 command: show-messages
11:13: /dev/ttys000 key :: command-prompt
11:13: /dev/ttys000 command: attach-session -t my-dotfiles
11:13: /dev/ttys000 command: select-pane -t my-dotfiles:VIM.0
11:13: /dev/ttys000 command: select-window -t my-dotfiles:VIM
11:13: /dev/ttys000 command: send-keys -t my-dotfiles:0 "vim ." C-m
11:13: /dev/ttys000 command: new-window -c /Users/davimarcondesmoreira/Projects/Devdrops/etc/my-dotfiles -n GIT -t my-dotfiles:2
11:13: /dev/ttys000 command: new-window -c /Users/davimarcondesmoreira/Projects/Devdrops/etc/my-dotfiles -n ENV -t my-dotfiles:1
11:13: /dev/ttys000 command: send-keys -t my-dotfiles:0 "cd /Users/davimarcondesmoreira/Projects/Devdrops/etc/my-dotfiles" C-m
11:13: /dev/ttys000 command: new-session -d -n VIM -s my-dotfiles
PrimaMateria commented 2 years ago

Same issue also reproducible on Linux running in WSL2. I am installing from apt so in my case I have:

ignu commented 2 years ago

Same here. I was setting up a new machine and absolutely losing it because I couldn't figure out what was wrong with my yml.

caliguIa commented 9 months ago

same here

DefinitelyNotSimon13 commented 1 month ago

did anyone manage to fix this? same for me

akofink commented 1 month ago

If someone could give me the output of tmuxinator debug <project>, it might help debugging this issue. 🙇

I am not able to reproduce it locally yet, but it seems similar to https://github.com/tmuxinator/tmuxinator/issues/909

DefinitelyNotSimon13 commented 1 month ago

@akofink

so for me the problem actually seems to be, that the keys are send before oh-my-posh is fully loaded. As such I assume the issue is not because of tmuxinator.

For good measure heres the output anyway:

#!/bin/zsh

# Clear rbenv variables before starting tmux
unset RBENV_VERSION
unset RBENV_DIR

tmux start-server;

cd /home/simon/1_Coding/todo-list

# Run on_project_start command.

  # Run pre command.

  # Run on_project_first_start command.

  # Create the session and the first window. Manually switch to root
  # directory if required to support tmux < 1.9
  TMUX= tmux new-session -d -s todo-list -n editor -c /home/simon/1_Coding/todo-list

  # Create other windows.
  tmux new-window -c /home/simon/1_Coding/todo-list -t todo-list:2 -n bacon

  # Window "editor"

  tmux set-window-option -t todo-list:1 pane-border-status top
  tmux set-window-option -t todo-list:1 pane-border-format "#{pane_index}: #{pane_title}"

  tmux send-keys -t todo-list:1.1 nvim C-m

  tmux splitw -c /home/simon/1_Coding/todo-list -t todo-list:1
  tmux select-layout -t todo-list:1 tiled

  tmux send-keys -t todo-list:1.2 cargo\ check C-m

  tmux select-layout -t todo-list:1 tiled

  tmux select-layout -t todo-list:1 main-vertical
  tmux select-pane -t todo-list:1.1

  # Window "bacon"

  tmux set-window-option -t todo-list:2 pane-border-status top
  tmux set-window-option -t todo-list:2 pane-border-format "#{pane_index}: #{pane_title}"

  tmux send-keys -t todo-list:2 bacon\ clippy C-m

  tmux select-window -t todo-list:1
  tmux select-pane -t todo-list:1.1

  if [ -z "$TMUX" ]; then
    tmux -u attach-session -t todo-list
  else
    tmux -u switch-client -t todo-list
  fi

# Run on_project_exit command.
akofink commented 1 month ago

That makes sense! Thank you for this insight, it is really useful. 💯

DefinitelyNotSimon13 commented 1 month ago

ofc!

For anyone who might come across this later on, a workaround that worked for me: I use zsh-defer on the eval "$(oh-my-posh init zsh ...)" command. To avoid showing the default for a split second, I also set PS1="" at the beginning of my .zshrc file.

# .zshrc
PS1=""
# [...]

zsh-defer eval "($oh-my-posh) init zsh --config [...]
jasper-at-windswept commented 2 weeks ago

@DefinitelyNotSimon13 ~I'm having this same issue on NixOS, neovim just doesn't open but it shows the command above oh-my-posh.~ I applied the above mentioned fix but it did not work.

Edit: I found out Nix wasn't adding the zsh-defer line properly and it is all working now thanks!

Here is my project:

name: nodenvim
root: /run/media/allusive/SSD/Projects/NodeProjects/

windows:
  - editor:
      layout: cf13,204x46,0,0{147x46,0,0[147x34,0,0,0,147x11,0,35,2],56x46,148,0,1}
      # synchronize: after
      panes:
      - neovim:
        - nvim
      - #empty
      - #empty