tmux-python / tmuxp

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

start_directory for the first pane is ignored #75

Closed ThiefMaster closed 6 years ago

ThiefMaster commented 10 years ago

It works like this but it'd be much more intuitive if I could set start_directory for the first pane instead:

session_name: test
windows:
  -
    window_name: puppet
    layout: tiled
    start_directory:  /tmp/test1
    panes:
      -
        focus: true
        shell_command:
      -
        start_directory: /tmp/test2
        shell_command:
      -
        start_directory: /tmp/test3
        shell_command:
      -
        start_directory: /tmp/test4
        shell_command:
tony commented 10 years ago

@ThiefMaster : Good catch, Looks possible, tmux 1.8 + allows split-window [-c start-directory].

I have a lot on my plate at the moment, this project is highly test-based (since one part and easily break others) so this is waiting on time to free up + some test suite improvements I have in the works to get done.

In the mean time, individual panes can change directory via cd. But start_directory is clearly the more elegant (and tmux-friendly) way.

I publish some shortcuts at http://tmuxp.readthedocs.org/en/latest/examples.html and in my .tmuxp dotfiles

fpietka commented 8 years ago

Not sure this is considered as related, but start_directory for the project doesn't change the starting folder of new windows.

tony commented 8 years ago

@fpietka New windows created by tmux after tmuxp is finished loading?

fpietka commented 8 years ago

Yes. It still starts in the folder we typed the command, regardless of the start_directory

tony commented 8 years ago

@fpietka can you give me an example of the config you are using and the current behavior vs expected behavior so I can be sure?

tony commented 8 years ago

@fpietka I think that behavior to tmux changing.

Set options in your tmux config (https://github.com/tony/tmux-config/blob/master/.tmux.conf)

run-shell "tmux set-environment -g TMUX_VERSION_MAJOR $(tmux -V | cut -d' ' -f2 | cut -d'.' -f1 | sed 's/[^0-9]*//g')"
run-shell "tmux set-environment -g TMUX_VERSION_MINOR $(tmux -V | cut -d' ' -f2 | cut -d'.' -f2 | sed 's/[^0-9]*//g')"

# fix pane_current_path on new window and splits
if-shell "#{$TMUX_VERSION_MAJOR} -gt 1 -o \( #{$TMUX_VERSION_MAJOR} -eq 1 -a #{$TMUX_VERSION_MINOR} -ge 8 \)" 'unbind c; bind c new-window -c "#{pane_current_path}"'
if-shell "#{$TMUX_VERSION_MAJOR} -gt 1 -o \( #{$TMUX_VERSION_MAJOR} -eq 1 -a #{$TMUX_VERSION_MINOR} -ge 8 \)" "unbind '\"'; bind '\"' split-window -v -c '#{pane_current_path}'"
if-shell "#{$TMUX_VERSION_MAJOR} -gt 1 -o \( #{$TMUX_VERSION_MAJOR} -eq 1 -a #{$TMUX_VERSION_MINOR} -ge 8 \)" 'unbind v; bind v split-window -h -c "#{pane_current_path}"'
if-shell "#{$TMUX_VERSION_MAJOR} -gt 1 -o \( #{$TMUX_VERSION_MAJOR} -eq 1 -a #{$TMUX_VERSION_MINOR} -ge 8 \)" 'unbind %; bind % split-window -h -c "#{pane_current_path}"'
tony commented 8 years ago

@ThiefMaster Do you still get that behavior in the issue you mentioned? I am able to load that yaml and /private/tmp/test1 shows in the first pane.

fpietka commented 8 years ago

I'm currently trying to mimic tmuxinator behavior on this.

If I may suggest another approach (and I didn't dig enough yet to see what it would imply in terms of code in tmuxp), the root start_directory can become default if the server is started, then if we attach the session with the -c option:

tmux attach-session -t project -c ~/my/working/directory/

Let me know what you think about that.

godlike64 commented 8 years ago

Affected by this too. Getting the exact same behaviour as @fpietka described: my config file's _startdirectory (on the root of the yml file) is effectively ignored when creating a new window after attaching with the 'tmux' command.

I have been driven nuts, since this appears to be related to the tmux-1.9 change in eliminating default-path and related stuff. I don't want to open new windows where I am currently standing in a pane: I want to have a 'root' folder for my tmux session where all new windows will be opened in.

tony commented 8 years ago

@godlike64 Can you give me an example of the config you're using, as well as tmux -V, echo $SHELL and bash/zsh/etc. version?

I have been driven nuts, since this appears to be related to the tmux-1.9 change in eliminating default-path and related stuff.

Yes, you would have to edit .tmux.conf.

I do miss this old behavior.

I don't want to open new windows where I am currently standing in a pane: I want to have a 'root' folder for my tmux session where all new windows will be opened in.

That is behavior that happens while running tmux. It may be best to file an issue there for this and see what they think.

I miss default-path a lot.

Kidlike commented 7 years ago

This is still present in 1.2.0. I'm guessing it hasn't been fixed yet. Anyone working on this ?

fpietka commented 7 years ago

I started to try something about it at the time, but didn't had much time to pursue.

The thing is tmuxinator (last time I checked) worked with the same tmux version. My guess is they are mimicking old tmux behavior.

Since then I got lazy (and had work) so I took the habbit of changing my working folder before launching tmuxp.

Nonetheless I still think we should try to work on that. If I find some time I'll try again see were it gets me, but can't promise anything. Maybe useful to share where we eventually get stuck on this.

Kidlike commented 7 years ago

Changing the directory before launching tmux isn't always gonna work.

For instance this is a session I use with a workaround of issuing a cd for the first pane of each window:

session_name: sp22-dev
windows:
  - window_name: sp22-commons
    focus: true
    panes:
      - focus: true
        shell_command:
            - cd ~/sp22/sp0022-parent
      - start_directory: ~/sp22/commons
  - window_name: sp22-tdi-gateway
    layout: main-vertical
    panes:
      - focus: true
        shell_command:
            - cd ~/sp22/tdi-gateway/services
      - start_directory: ~/sp22/tdi-gateway/package
      - start_directory: ~/sp22/tdi-gateway/uat
  - window_name: sp22-wingspan
    start_directory: ~/sp22/wingspan-integration/service
    layout: main-vertical
    panes:
      - focus: true
        shell_command:
            - cd ~/sp22/wingspan-integration/service
      - start_directory: ~/sp22/wingspan-integration/package
      - start_directory: ~/sp22/wingspan-integration/uat
stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This bot is used to handle issues where the issue hasn't been discussed or has gone out of date. If an issue isn't resolved and handled in a certain period of time, it may be closed. If you would like your issue re-opened, please create a fresh issue with the latest, up to date information and mention this issue in it.

ArtemKomisarenkoZultys commented 7 months ago

I still have the issue, and I did workaround it with an additional pane like:

    panes:
      - shell_command:
        # kill-pane instead of simple exit because it works better with the remain-on-exit option
        - tmux kill-pane -t session:window.0
      - start_directory: <somewhere>

It's a bit cleaner than using explicit cd.