Socket
Book a DemoInstallSign in
Socket

zsh-module

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zsh-module

0.3.0
Cargo
Version published
Maintainers
1
Created
Source

Zsh Module   Latest Version

This 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:

  • Define custom builtin commands
    • Define and query used flags
  • 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 for a quick guide.

Example module

Making a module is very easy, here's an excerpt from our example module greeter

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<Module, Box<dyn std::error::Error>> {
    let module = ModuleBuilder::new(Greeter)
        .builtin(Greeter::greet_cmd, Builtin::new("greet"))
        .build();
    Ok(module)
}

FAQs

Package last updated on 01 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.