feat: added tmux plugin compatability layer#24
Open
LUIDevo wants to merge 1 commit into
Open
Conversation
Sourcing a `.tmux` file now executes it as a shell script with a `tmux` shim placed on PATH that proxies commands back to the running rmux server over its socket. This lets tmux plugins (e.g. TPM-style `.tmux` entry scripts) drive rmux directly, instead of being parsed as config. The shim and script execution are Unix-only; the executable-bit setup is gated behind cfg(unix) so the crate still builds on Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
Tmux plugin scripts are shell scripts that run tmux internally. rmux tried to parse .tmux files but failed silently, so tmux plugins were not compatible with rmux.
Solution:
We create a temporary directory using the tempfile crate, inside of it contains a fake tmux shim. When we run the tmux script, it calls this executable using a PATH override, which turns it into an rmux command.
There are other ways to implement this change, such as reading through the script and swapping every 'tmux' with 'rmux' but this implementation is cleaner and is less prone to breakages.
All code changes were implemented in rmux-server, as the implementation was minimal enough to not warrant another "rmux-shim" crate. Later, if needed, it can be extracted into its own crate.
The "extract_plugin_paths" function takes in commands and returns a list of strings of source files ending with .tmux.
"run_plugin_scripts" contains the shim logic and is called from a slightly modified handle_source_file function.