jrmoulton / tmux-sessionizer

Tmux Sessionizer: A tool for opening git repositories as tmux sessions
MIT License
381 stars 30 forks source link

Feature request: default working directory of new tmux splits to worktree repo #116

Open mattgallagher92 opened 1 month ago

mattgallagher92 commented 1 month ago

When working with a bare Git repo and worktrees, tms opens a new window for each worktree. The working directory for the pane in each of those windows is the worktree directory. When splitting the window, the working directory for the new pane is the directory containing the bare repo (usually the parent of the worktree directory), not the worktree directory itself.

It'd be great if tms configured the tmux window so that a new pane's working directory is the worktree directory.

P.S. I'm a tmux noob, so not sure whether that's even possible 😅 P.P.S. Thanks for tms, it's great!

junglerobba commented 1 month ago

tmux's split-window command has the -c option with which you can define the starting directory of the new split. If you use for example (copied from my config, mind the different keys)

bind -r v split-window -h -c "#{pane_current_path}"
bind -r s split-window -v -c "#{pane_current_path}"

you can make all splits inside a window open in the same directory.

mattgallagher92 commented 1 month ago

Thanks @junglerobba, that works great!

I'll leave this issue open for now in case it seems like sensible default behaviour, but I'm happy for a maintainer to close it if not.

OscarCreator commented 4 days ago

I have the same problem/feature request. I usually have bare repos with many different worktrees and would like to be able to choose the worktree in the search list directly. If you don't want this as default behaviour this could be an --show-worktrees option or something. For example:

/home/user/projects/a/worktree_1 /home/user/projects/a/worktree_2 /home/user/projects/b

Then you would directly open the specific worktree and have the root folder for the tmux session be to the worktree you decided to work on.