Skip to content

201: embeddable scripts#202

Merged
ck3mp3r merged 8 commits intomainfrom
201-embeddable-scripts
Apr 20, 2025
Merged

201: embeddable scripts#202
ck3mp3r merged 8 commits intomainfrom
201-embeddable-scripts

Conversation

@ck3mp3r
Copy link
Owner

@ck3mp3r ck3mp3r commented Apr 19, 2025

No description provided.

@ck3mp3r ck3mp3r linked an issue Apr 19, 2025 that may be closed by this pull request
@ck3mp3r ck3mp3r force-pushed the 201-embeddable-scripts branch from 791928e to b54b11e Compare April 19, 2025 19:57
ck3mp3r added 4 commits April 20, 2025 11:32
- Adds `startup_script` and `shutdown_script` fields to the `Session` model.
- Introduces `script` field to `Pane` model.
- Modifies `Session` and `Pane` models to serialize/deserialize script config.
- Adds fields `startup_script` and `shutdown_script` for sessions in `tmux` parser.
- Adds fields `startup_script` and `shutdown_script` for sessions in `zellij` model.
- Updates `Pane` model to include an optional script field.
This commit refactors the script execution logic across multiple muxers (zellij, tmux, and zellij) to simplify and standardize how startup and shutdown scripts are handled. The key changes include:

- **Unified Script Handling:**  Startup and shutdown scripts are now combined with other commands into a single list and executed together. This eliminates the separate `run_script` calls.
- **Command Combination:** The logic to include a script as a single command if it exists is now consistent across muxers.
- **Removed `run_script`:** The `run_script` method is removed as its functionality is now integrated into the `run_commands` method.
- Modifies script path construction by utilizing `std::env::temp_dir()` to create the script path.
- This change removes the hardcoded `/tmp` directory and dynamically uses the system's temporary directory.
- Updates test assertions across tmux and zellij tests to reflect the change in path construction by using `contains()` instead of strict equality.
- Improves portability and flexibility by avoiding a fixed temporary directory.
 - Adds `startup_script` to the configuration for custom startup commands.
 - Adds `shutdown_script` to the configuration for custom shutdown commands.
 - Adds `shell` config option for specifying a custom shell.
 - Adds `env` configuration section to optionally set environment variables.
 - Introduces a `script` option to pane definitions to run a custom script.
 - Improves example configuration snippets in both README.md and docs/content/docs/getting-started/basics.md to reflect new config options
@ck3mp3r ck3mp3r force-pushed the 201-embeddable-scripts branch from 9c759d9 to e9ca252 Compare April 20, 2025 10:35
ck3mp3r added 4 commits April 20, 2025 11:45
 - Changes file creation permissions from 0o755 to 0o700.
 - Ensures that the generated script file is only accessible to the owner.
 - Prevents potential security risks due to overly permissive file permissions.
- Extracts the `default_path` function into a new `common` module.
- Moves the implementation of `default_path` to `src/common/config/model/common.rs`.
- Updates the usage of the `default_path` function in `src/common/config/model/pane.rs` and `src/common/config/model/session.rs` to import from the new `common` module.
- Removes the unused `default_path` function from `src/common/config/util.rs`.
- Removes unnecessary `then` calls in `TmuxClient::stop_session` and `ZellijClient::stop_session`.
- Simplifies session stopping in `Tmux`, `Zellij` to improve readability.
- Updates `Tmux` and `Zellij` to use the new, refactored method.
- Consistently removes unnecessary references in shell command execution.
 - Removes the `env` block from the `.laito.yaml` file.
 - Removes the `startup_script` block from the `.laito.yaml` file.
 - Simplifies the configuration file structure by removing unnecessary values.
@ck3mp3r ck3mp3r merged commit 632faa3 into main Apr 20, 2025
@ck3mp3r ck3mp3r deleted the 201-embeddable-scripts branch April 20, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embeddable Scripts

1 participant