whame / tmux-modal

Execute complex tmux commands in just a few keystrokes with a modal mode that is designed to be efficient, easy to remember and comfortable
MIT License
172 stars 4 forks source link

Allow for Options to be passed to split-window #10

Closed bradfordwagner closed 1 year ago

bradfordwagner commented 1 year ago

I like to have splits open in the current working directory. split-window -h -c "#{pane_current_path}"

Not everyone might like that so I made it an option @modal-split-opts , and made the configuration copy and paste for others in case they like it. Also this keeps the configuration backwards compatible with no breaking changes.

whame commented 1 year ago

Thank you for the pull the request!

I can see that people might want to configure the commands executed by tmux-modal. As you mention, everyone has their own preference and therefore we should maybe generalize this idea?

We could have a file "commands.conf" that will have a 1-1 mapping to the keybindings in "keybindings.conf". In "commands.conf" users could override the commands to their liking. In your case, it might look something like this:

CMD_WIN_SPLIT_RIGHT='split-window -h -c "#{pane_current_path}"' CMD_WIN_SPLIT='split-window -c "#{pane_current_path}"'

This is more scalable and customizable. I can start working on that this weekend (shouldn't be that hard to implement). What do you think?

bradfordwagner commented 1 year ago

I like your idea 100xs better than what I came up with! By the way I just started using this plugin today. It is really fantastic, ty for all your hard work!

whame commented 1 year ago

This has been implemented on master now (see https://github.com/whame/tmux-modal#custom-commands). Please update and try it out!

For your case, make a copy of commands.conf. Make the following change to your newly copied configuration command file:

--- commands.conf       2023-01-01 19:11:34.195419427 +0100
+++ bradfordwagner-cmd.conf       2023-01-01 19:06:58.098918423 +0100
@@ -114,10 +114,10 @@
 ## Split command prefix.

 ### Split window pane right.
-CMD_WIN_SPLIT_RIGHT='split-window -h'
+CMD_WIN_SPLIT_RIGHT='split-window -h -c "#{pane_current_path}"'

 ### Split window pane down.
-CMD_WIN_SPLIT_DOWN='split-window'
+CMD_WIN_SPLIT_DOWN='split-window -c "#{pane_current_path}"'

 ## Move command prefix.

Finally, tell tmux-modal to load it. Thus, in your .tmux.conf:

set -g @modal-commands-conf /path/to/bradfordwagner-cmd.conf

Thanks for the idea! I actually use the custom split command myself now :)