Skip to content

Commit

Permalink
Merge pull request #38 from ethagnawl/feature/add-tmux_options-to-config
Browse files Browse the repository at this point in the history
Add tmux_options entry to config to support pass-through tmux CLI args
  • Loading branch information
ethagnawl authored Apr 12, 2024
2 parents 8768644 + 67b54c1 commit 053a35a
Show file tree
Hide file tree
Showing 8 changed files with 374 additions and 106 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
**/*.rs.bk
.cargo/config
*.log
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords = ["tmux", "productivity"]

[dependencies]
clap = "2.33"
derivative = "2.2.0"
mockall = "0.10"
regex = "1.10"
serde = { version = "1.0", features = ["derive"] }
Expand Down
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ layout = "main-horizontal"
name = "example"
pane_name_user_option = "custom_pane_title"
start_directory = "/home/peter/projects/vim"
tmux_options = "-f /tmp/tmux.work.conf -L work-socket"
[[hooks]]
command = "run-shell \"tmux display-message 'Hi from pane-focus-in hook!'\""
Expand Down Expand Up @@ -89,11 +90,12 @@ Optional attributes will be noted below.
- `windows` (array; see dedicated entry)

###### Optional
- attached (bool; defaults to `true`; whether or not to attach to newly created tmux session)
- `attached` (bool; defaults to `true`; whether or not to attach to newly created tmux session)
- `hooks` (array; see dedicated entry)
- `layout` (string; preset tmux layouts: "even-horizontal", "even-vertical", "main-horizontal", "main-vertical", "tiled")
- `pane_name_user_option` (string; must have matching entry in .tmux.conf (e.g. `set -g pane-border-format "#{@custom_pane_title}"`)
- `start_directory` (string)
- `tmux_options` (string; CLI flags to pass through to tmux)

##### Hooks
- `command` (string; must use tmux's `run_shell`; see tmux docs)
Expand Down Expand Up @@ -172,6 +174,18 @@ let rmuxinator_config = rmuxinator::Config {
rmuxinator::run_start(rmuxinator_config).map_err(|error| format!("Rmuxinator error: {}", error))
```

## Known Issues and Workarounds
### Custom Tmux Config
If you provide a custom tmux config file via tmux_options, you may need to
restart your tmux server (`tmux kill-server`) before some/all of its changes
will take effect. For example, changes to `base-index` and `pane-base-index`
are known to require a restart in order to be detected and used as expected.

It might be possible to work around this issue but it needs more thought. The
heavy handed option would be to have this library explicitly kill and restart
the tmux server but that could have unintended consequences if other tmux
sessions are in use.

## Status
This project is currently a proof of concept and I'll be duplicating tmuxinator
features and adding additional improvements as I can find time. Right now, it's
Expand All @@ -190,6 +204,7 @@ pane-border-format config option)
- running pane commands
- wiring up optional tmux event hooks/callbacks
- detecting/using tmux server base-index and pane-base-index values
- accepting custom tmux CLI options via the tmux_options config field

## Still TODO:
- Consider building up and executing a single script (a la tmuxinator) instead
Expand All @@ -215,8 +230,7 @@ require writing a custom Serde deserializer for the Config type.
config (I'm not convinced this is necessary)
- Other CLI commands? (stop session, create/edit/delete project)
- Use named args in calls to format! where possible
- Implement default for Config struct
- Accept optional tmux config file (i.e. `tmux -f ./foo.conf ...`)
- (Fully) implement default/derivative for Config struct

## Platforms
Here are the platforms rmuxinator is known to work on:
Expand Down
13 changes: 13 additions & 0 deletions samples/CustomTmuxOptions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = "custom-tmux-options"
tmux_options = "-f /tmp/tmux.override.conf -f /tmp/tmux.override-2.conf -v -2 -L NICE"

[[windows]]
name = "one"
[[windows.panes]]
commands = ["echo window-one-pane-one"]

[[windows]]
name = "two"
[[windows.panes]]
commands = ["echo window-two-pane-one"]

3 changes: 1 addition & 2 deletions samples/Minimal.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = "debug"
name = "minimal"

[[windows]]
name = "one"
[[windows]]
name = "two"

Loading

0 comments on commit 053a35a

Please sign in to comment.