Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diegovsky/zsh-module-rs
A high level Rust crate for creating zsh modules
https://github.com/diegovsky/zsh-module-rs
rust zsh
Last synced: about 2 months ago
JSON representation
A high level Rust crate for creating zsh modules
- Host: GitHub
- URL: https://github.com/diegovsky/zsh-module-rs
- Owner: Diegovsky
- Created: 2023-01-16T05:48:33.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-09T00:14:02.000Z (11 months ago)
- Last Synced: 2024-02-09T14:30:51.063Z (11 months ago)
- Topics: rust, zsh
- Language: C
- Homepage:
- Size: 187 KB
- Stars: 26
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Zsh Module [![Latest Version]][crates.io]
[Latest Version]: https://img.shields.io/crates/v/zsh-module
[crates.io]: https://crates.io/crates/zsh-moduleThis is a high level crate that allows you to define your own zsh module. It is in a very early state but it can be used to define commands.
In the future, most zsh module functionality will be added. Feel free to send a PR if you would like to add more functionality :)
Features:
- [x] Define custom builtin commands
- [x] Define and query used flags
- [x] Call into `zsh`
- [ ] Query environment variables
- As a workaround: can be done using the `std::os` APIs.
- [ ] Use zsh's current `stdin` fd.
- You can use `std::io::stdin`, but it can break in specific ocasions.
- [ ] Define custom builtin math functions
- [ ] Define custom global variables
- [ ] More to come!## Getting started
Take a look at our online [documentation](https://docs.rs/zsh-module/latest/zsh-module) for a quick guide.## Example module
Making a module is very easy, here's an excerpt from our example module [`greeter`]```rust
use zsh_module::{Builtin, MaybeError, Module, ModuleBuilder, Opts};// Notice how this module gets installed as `rgreeter`
zsh_module::export_module!(rgreeter, setup);struct Greeter;
impl Greeter {
fn greet_cmd(&mut self, _name: &str, _args: &[&str], _opts: Opts) -> MaybeError {
println!("Hello, world!");
Ok(())
}
}fn setup() -> Result> {
let module = ModuleBuilder::new(Greeter)
.builtin(Greeter::greet_cmd, Builtin::new("greet"))
.build();
Ok(module)
}
```[`greeter`]: https://github.com/Diegovsky/zsh-module-rs/tree/master/greeter