tmux-python / tmuxp

🖥️ Session manager for tmux, build on libtmux.
https://tmuxp.git-pull.com/
MIT License
4.05k stars 231 forks source link

environment option not work on PATH variable #489

Open joselbr2099 opened 5 years ago

joselbr2099 commented 5 years ago

I am trying to load the PATH variable in a tmuxp session and this variable should be available in any new window of the session:

global_options:
default-command: /bin/bash 
environment:
  EDITOR: /usr/bin/vim
  PATH: ${PATH}$HOME/.config/myproj/
session_name: myproj
windows:
- window_name: main-dev
  focus: true
  layout: horizontal
  panes:
  - shell_command:
    - printf '\033]2;%s\033\\' 'Editor' 
    focus: true

${PATH}$HOME/.config/myproj/ it only loads in the current window but when a new window is created the variable disappears while EDITOR is loaded in any new window and does not disappear

Step 2: Provide tmuxp details

, `tmux show-window-options -g`

aggressive-resize on allow-rename off alternate-screen on automatic-rename on automatic-rename-format "#{?pane_in_mode,[tmux],#{pane_current_command}}#{?pane_dead,[dead],}" clock-mode-colour blue clock-mode-style 24 main-pane-height 24 main-pane-width 80 mode-keys vi mode-style fg=black,bg=yellow monitor-activity off monitor-bell on monitor-silence 0 other-pane-height 0 other-pane-width 0 pane-active-border-style fg=green pane-base-index 0 pane-border-format "#{?pane_active,#[reverse],}#{pane_index}#[default] \"#{pane_title}\"" pane-border-status off pane-border-style default remain-on-exit off synchronize-panes off window-active-style default window-size smallest window-status-activity-style reverse window-status-bell-style reverse window-status-current-format "#I:#W#{?window_flags,#{window_flags}, }" window-status-current-style default window-status-format "#I:#W#{?window_flags,#{window_flags}, }" window-status-last-style default window-status-separator " " window-status-style default window-style default wrap-search on xterm-keys on

  * output of `tmuxp freeze <SESSION_NAME>`

session_name: myproj windows:

Step 3: Describe your environment

Step 4: Describe the problem:

Steps to reproduce:

  1. create dev.yam file
  2. tmuxp load dev.yaml
  3. in the current window: echo $PATH and echo $EDITOR the variable $HOME/.config/myproj/ appears $EDITOR show "vim" ctrl+b+c //new window in new windows: echo $PATH and echo $EDITOR the variable $HOME/.config/myproj/ does not appears $EDITOR show "vim"

Observed Results:

Expected Results:

boertel commented 3 years ago

I had the same issue with 1.5.4. Then I upgrade to 1.6.2 to see if it was fixed but no :( but I found that doing the following works:

session_name: myproject
shell_command_before:
  - PATH=$PATH:$(pwd)/bin/
  - '[ -d `pipenv --venv` ] && source `pipenv --venv`/bin/activate && reset'
  - nvm use default
windows:
...

That is my workaround, not sure how accurate that is but it works for me :) I hope it can be helpful for someone.

Note: As you can see I'm using pipenv and nvm here, and I need to place the PATH instruction first otherwise it will get overwritten by pipenv and nvm

tony commented 3 years ago

@boertel Happy that you were able to find a workaround

For both you and @joselbr2099 (and anyone else who bumps into this):If we had this recreated in a test PR (to recreate the issue), that would be ideal (I could write a fix for it)