-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: improve ui/use `quit_zellij` command improved UI: 1. centered text 2. added help text for the 2 available key actions plugin command: since only the current session may be killed let's use `quit_zellij` which doesn't require listening to session updates. * chore: add preCommit script/cargo lock update * Update README.md
- Loading branch information
1 parent
c98e074
commit a8ffead
Showing
4 changed files
with
64 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
## About | ||
# zj-quit | ||
|
||
This is an example [Zellij][zellij] plugin in Rust. It can be used as a template to start developing your own plugins. | ||
A [zellij](https://zellij.dev/) plugin that prompts for confirmation before killing the current session. | ||
|
||
More about Zellij plugins: [Zellij Documentation][docs] | ||
![image](https://github.com/cristiand391/zj-quit/assets/6853656/0b2537c4-6872-402b-aa5d-f0713c46c32b) | ||
|
||
[zellij]: https://github.com/zellij-org/zellij | ||
[docs]: https://zellij.dev/documentation/plugins.html | ||
This has been requested multiple times by users: | ||
* https://github.com/zellij-org/zellij/issues/467 | ||
* https://github.com/zellij-org/zellij/issues/1229 | ||
* https://github.com/zellij-org/zellij/issues/3147 | ||
|
||
## Development | ||
so I decided go the *zellij way* ™️ and made a plugin for this :) | ||
|
||
*Note*: you will need to have `wasm32-wasi` added to rust as a target to build the plugin. This can be done with `rustup target add wasm32-wasi`. | ||
## Usage | ||
|
||
## Inside Zellij | ||
![img-2023-06-14-143355](https://github.com/zellij-org/rust-plugin-example/assets/795598/d9e563dc-5d71-4e10-af5b-190365bdca3b) | ||
|
||
You can load the `./plugin-dev-workspace.kdl` file as a Zellij layout to get a terminal development environment: | ||
|
||
Either when starting Zellij: | ||
``` | ||
zellij --layout ./plugin-dev-workspace.kdl | ||
Download the last release available at https://github.com/cristiand391/zj-quit/releases/ and set up an alias for it: | ||
```kdl | ||
plugins { | ||
zj-quit location="file:/path/to/zj-quit.wasm" | ||
} | ||
``` | ||
*Note that in this case there's a small bug where the plugin is opened twice, it can be remedied by closing the oldest instance or loading with the new-tab action as secified below - this will be addressed in the near future* | ||
|
||
Or from a running Zellij session: | ||
```bash | ||
zellij action new-tab --layout ./plugin-dev-workspace.kdl | ||
``` | ||
https://zellij.dev/documentation/plugin-aliases | ||
|
||
## Otherwise | ||
then set a keybind to launch it in a floating window: | ||
|
||
1. Build the project: `cargo build` | ||
2. Load it inside a running Zellij session: `zellij action start-or-reload-plugin file:target/wasm32-wasi/debug/rust-plugin-example.wasm` | ||
3. Repeat on changes (perhaps with a `watchexec` or similar command to run on fs changes). | ||
```kdl | ||
keybinds clear-defaults=true { | ||
shared_except "locked" { | ||
bind "Ctrl q" { | ||
LaunchOrFocusPlugin "zj-quit" { | ||
floating true | ||
} | ||
} | ||
} | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const util = require('node:util'); | ||
const exec = util.promisify(require('node:child_process').exec); | ||
|
||
exports.preCommit = async () => { | ||
await exec('cargo check') | ||
}; |
This file contains 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