• Stars
    star
    133
  • Rank 272,600 (Top 6 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Write shell completion scripts in pure Rust

shell_completion Build Status crates.io badge

Shell completions, which provide auto-complete for CLI applications, are typically written in Bash. This crate provides low level primitives for writing shell completion scripts in Rust.

Usage

Shell completion scripts are written as normal Rust binaries. A minimal example is below:

use shell_completion::{BashCompletionInput, CompletionInput, CompletionSet};

fn main() {
    let input = BashCompletionInput::from_env()
        .expect("Missing expected environment variables");

    let completions = input.complete_subcommand(vec!["add", "commit"]);

    completions.suggest();
}

A more advanced example is available in the cargo_completion crate within this workspace. To try it out, run cargo install --force --path cargo_completion/ && complete -C _cargo_completion cargo, then type cargo run --<TAB> in the same shell.

The complete command registered our shell completion script for cargo. Note that complete commands do not persist (they are only active in the shell where you run complete), so if you want to use a completion long term you'll want to add the complete command to your ~/.bash_profile.

See this blog post for more details.

Users

This crate is not quite ready for production use, but if you are an early adopter, feel free to make a PR adding yourself to the list below.

  • N/A

License

Licensed under either of

at your option.

Contribution

All forms of contribution are valued. I've created issues for many high level topics of exploration, and any feedback there will be very helpful in moving this crate in the right direction. Of course, code contributions are appreciated as well.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

More Repositories

1

bubble-shell

A simple shell
Rust
130
star
2

timetrack

Automatically track how you are spending your time by watching the file system
Rust
97
star
3

arr_macro

Initialize arrays with ease!
Rust
83
star
4

multi_try

Safely combine results
Rust
81
star
5

backlight

A dynamic binary tracing tool
Rust
66
star
6

estream

Vim plugin to take back the quickfix window
Rust
53
star
7

libps1

An experimental shell prompt library for developers
Rust
45
star
8

betafpv-f3

Board Support Crate for the BetaFPV F3 Drone Flight Controller
Rust
44
star
9

belay

Run your CI checks locally to `git push` with confidence
Rust
41
star
10

monkey

An interpreter for the Monkey programming language
Rust
38
star
11

traffic

Simple traffic reporting for your Github repositories
Rust
35
star
12

cargo-run-script

Bringing `npm run-script` to Rust
Rust
35
star
13

amethyst-2d-platformer-demo

Demo game using the Amethyst engine
Rust
31
star
14

exit

Custom exit status codes with ? in main
Rust
29
star
15

ignition-web-scripts

Scripts to create a REST API using Inductive Automation Ignition and the Web Dev Module
Python
24
star
16

waysay

Native wayland desktop notifications - a drop-in replacement for swaynag written in rust
Rust
20
star
17

nerve

Rust
17
star
18

todo_macro

Never forget your in-code Todos
Rust
14
star
19

dashr

A unix-style utility for responding programmatically to new ethernet devices joining a network
Rust
14
star
20

ignition-web-example

Demo React application using ignition-web-scripts and ignition-web-hoc
JavaScript
10
star
21

maze

Rust
9
star
22

ignition-web-hoc

React HOC to be used with ignition-web-scripts REST API
JavaScript
9
star
23

opc-gateway

Expose data from an OPC-UA server via HTTP and WebSocket APIs
JavaScript
8
star
24

tsl256x

Platform agnostic driver for TSL256x series light intensity sensors built using the embedded-hal
Rust
6
star
25

imu

Rust port of the Madgwick IMU sensor fusion algorithm
Rust
5
star
26

shift-register-driver

Platform agnostic driver for shift register's built using the embedded-hal
Rust
5
star
27

infra

Python
5
star
28

rraw

Rust Reddit API Wrapper
Rust
4
star
29

license-bot

Reddit bot that suggests adding a license file to Github repos that are submitted to Reddit without a license
Rust
4
star
30

cascade

Shell
4
star
31

mesozoic

PineTime smartwatch firmware
Rust
4
star
32

mars

An alternative build tool for the Servo browser engine
Rust
3
star
33

hue-cli

a minimal command line interface for Phillips Hue lights
Rust
3
star
34

infra-tools

Rust
2
star
35

ffi-c-calling-rust

A minimal example
Makefile
1
star
36

sift

Text UI unix-style filter
Rust
1
star
37

hacker-news

No-boilerplate workflow for web API interactions with React & Redux
JavaScript
1
star
38

auto-import

Rust proc-macro example
Rust
1
star
39

cost-of-indirection

Testing the performance costs of indirection in Rust
Rust
1
star
40

dotfiles

Emacs Lisp
1
star
41

PPC_Sim

A solar power plant controller simulation and testing tool
Java
1
star
42

stm32f3discovery-quickstart

Rust project generator for the STM32F3DISCOVERY development board
Rust
1
star
43

aoc-2018

Advent of Code 2018 - Solutions in Rust
Rust
1
star
44

JBrailler

A digital perkins brailler (braille typewriter)
Java
1
star
45

cryptopals

Rust implementation of the cryptopals crypto challenges
Rust
1
star
46

joshmcguigan.github.io

www.joshmcguigan.com
HTML
1
star
47

fizzbuzz-rs

Test bed for the blog post 'A FizzBuzzy Tour of Traits in Rust'
Rust
1
star
48

bit-bang-serial

Platform agnostic bit banging serial communication implementation built using the embedded-hal
Rust
1
star
49

gdb-devtools

Rust
1
star
50

aoc-2020

Advent of Code 2020
Rust
1
star
51

scout

An exploration of using Rust in the development of flight control software
Rust
1
star