diff options
| author | a-kenji <aks.kenji@protonmail.com> | 2021-06-30 23:25:50 +0200 |
|---|---|---|
| committer | a-kenji <aks.kenji@protonmail.com> | 2021-07-02 13:39:02 +0200 |
| commit | 0bf78100ddbae4fa3f199b4c0f4a4b05ac83c5ee (patch) | |
| tree | c9a3a2b23fb4ef07fccdd82620eadfb99b11fcd0 /zellij-server/src | |
| parent | Merge pull request #593 from a-kenji/modularize-spawn-terminal (diff) | |
| download | sl0ppij-0bf78100ddbae4fa3f199b4c0f4a4b05ac83c5ee.tar.gz sl0ppij-0bf78100ddbae4fa3f199b4c0f4a4b05ac83c5ee.tar.xz sl0ppij-0bf78100ddbae4fa3f199b4c0f4a4b05ac83c5ee.zip | |
Add running commands to an action
Add the ability to bind running commands to
an action.
Eg:
```
- action: [Run: {command: "htop",},]
key: [F: 6,]
``
Optionally the direction and arguments can be
specified:
```
- action: [Run: {command: "htop", args: ["-C",]},]
key: [F: 7,]
```
The directional splits are analogous to the `[NewPane]` splits.
```
- action: [Run: {command: "htop", args: ["-C",], direction: "Up"},]
key: [F: 8,]
```
Diffstat (limited to 'zellij-server/src')
| -rw-r--r-- | zellij-server/src/route.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs index 285f333c..1a559d08 100644 --- a/zellij-server/src/route.rs +++ b/zellij-server/src/route.rs @@ -10,6 +10,7 @@ use zellij_utils::{ channels::SenderWithContext, input::{ actions::{Action, Direction}, + command::TerminalAction, get_mode_info, }, ipc::{ClientToServerMsg, ExitReason, ServerToClientMsg}, @@ -143,6 +144,18 @@ fn route_action( }; session.senders.send_to_pty(pty_instr).unwrap(); } + Action::Run(command) => { + let run_cmd = Some(TerminalAction::RunCommand(command.clone().into())); + let pty_instr = match command.direction { + Some(Direction::Left) => PtyInstruction::SpawnTerminalVertically(run_cmd), + Some(Direction::Right) => PtyInstruction::SpawnTerminalVertically(run_cmd), + Some(Direction::Up) => PtyInstruction::SpawnTerminalHorizontally(run_cmd), + Some(Direction::Down) => PtyInstruction::SpawnTerminalHorizontally(run_cmd), + // No direction specified - try to put it in the biggest available spot + None => PtyInstruction::SpawnTerminal(run_cmd), + }; + session.senders.send_to_pty(pty_instr).unwrap(); + } Action::CloseFocus => { session .senders |
