A bash-like Unix shell written in Rust

Overview

Cicada Unix Shell

Travis Build Status Latest Version

Cicada is a simple Unix shell written in Rust.

Documents

Try out cicada with Docker

$ docker pull mitnk/cicada
$ docker run --rm -it mitnk/cicada
(in-cicada) $ cinfo

Features

Run programs and pipelines

$ ls | head -n3
Desktop
Documents
Downloads

$ echo foo,bar | awk -F "," '{print $2, $1}'
bar foo

With redirections

$ ls file-not-exist 2>&1 | wc > e.txt
$ cat e.txt
       1       7      46

Command substitution

$ ls -l `which sh`
-r-xr-xr-x  1 root  wheel  618512 Oct 26  2017 /bin/sh

$ echo "Time is $(date)."
Time is Sun Sep  2 12:04:13 CST 2018.

Run multiple commands (with logical)

$ echo foo; echo bar
foo
bar

$ echo foo && echo bar
foo
bar

$ echo foo || echo bar
foo

Math arithmetic directly in the shell!

$ 1 + 2 * 3 - 4
3
$ (1 + 2) * (3 - 4) / 8.0
-0.375
$ 2 ^ 31
2147483648

Cicada is also a library (BETA)

Read APIs here: https://docs.rs/cicada/.

FAQs

Comments
  • Use as a library

    Use as a library

    It would be useful to provide functions to

    1. Parse input and return if it's complete and chunk it into individual command units (so e.g. a single command execution on its own line or an if statement are both individual command units)
    2. Execute code and capture output

    The idea is that we can then use it e.g. to power a Jupyter kernel or other alternative interfaces

    opened by flying-sheep 9
  • Cicada not quitting on SIGINT

    Cicada not quitting on SIGINT

    First, thanks! Looks like a really cool project.

    Cicada does not quit correctly when sent a SIGINT signal. If sent externally, simply nothing is happening. If sent through typing Ctrl-C directly in the shell, my terminal closes output, but cicada keeps running. The terminal is then spammed with readline error: Error { repr: Os { code: 5, message: "Input/output error" } }, due to the closed stdout. At this point cicada consumes 100% of the CPU.

    You should handle external signals and correctly quit the application. (I also expected to be able to quit the shell using Ctrl-D aka sending EOF, but this does nothing

    opened by badboy 8
  • Better Lib APIs

    Better Lib APIs

    via #3

    We need to rename line_to_tokens to cmd_to_tokens.

    it would be also cool to have it indicate if the command is complete e.g. the return value of line_to_tokens("foo |") should make clear that this isn’t a runnable command.

    opened by mitnk 7
  • Is BUILD_DATE stale without a prior `make clean`, for successive `make` calls?

    Is BUILD_DATE stale without a prior `make clean`, for successive `make` calls?

    How do you ensure that the BUILD_DATE env var from here: https://github.com/mitnk/cicada/blob/340e8136465863c07832c9a19261c0b75b4034a5/src/build.rs#L15 is being updated upon each successful compilation, without having to manually make clean before make ?

    If my understanding is correct(and I tested this a lil bit on my test project), cargo caches the output of build.rs and if you just touch src/main.rs for example, but not also touch build.rs, it will use the cached output and thus BUILD_DATE(and GIT_HASH for that matter) will be the stale one.

    opened by ghost 4
  • cicada fails to recognize stopped jobs

    cicada fails to recognize stopped jobs

    Type:

    vim &
    ps f
    jobs
    

    it outputs:

    $ vim &
    [1] 17305
    $ ps f
      PID TTY      STAT   TIME COMMAND
    ...
    16964 pts/7    S      0:02  \_ target/debug/cicada
    17305 pts/7    T      0:00      \_ vim
    17307 pts/7    R+     0:00      \_ ps f
    $ jobs
    [1] 17305  Running    vim &
    $ 
    

    even though vim is stopped (T) cicada reports it as running.

    opened by godmar 3
  • shell fails to reap child processes in a timely manner

    shell fails to reap child processes in a timely manner

    If you run

    sleep 5 &
    sleep 200
    

    The first command should be reaped after 5 seconds, not after 200.

    Similarly, if you run

    sleep 1 &
    

    this job isn't reaped until the user hits Enter again.

    opened by godmar 3
  • kind: InvalidData

    kind: InvalidData

    cicada echo $HOSTNAME cicada: read_to_string error: Custom { kind: InvalidData, error: StringError("stream did not contain valid UTF-8") }

    DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS" NAME="Ubuntu" VERSION="18.04.2 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.2 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic

    uname -a Linux think 4.18.0-24-generic #25~18.04.1-Ubuntu SMP Thu Jun 20 11:13:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

    opened by denisgolius 3
  • implement 'source' builtin command

    implement 'source' builtin command

    Hey,

    I noticed your shell does not have the source command as one of its builtins, which lets you source rc files during a session. It works like this: make a change to ~/.cicadarc, run source ~/.cicadarc, and any changes you made to your RC file will then be loaded. I was a pretty simple implementation, I just had to call the load_file function in the rcfile module. I hope you will incorporate this into your project.

    opened by ngklingler 3
  • exit: entity not found

    exit: entity not found

    Not expected:

    $ echo 'echo 1;exit;echo 2'|./target/debug/cicada
    1
    exit: entity not found
    2
    

    Expected (in bash):

    $ echo 'echo 1;exit;echo 2'|bash
    1
    

    This does work as expected though:

    $ echo -e 'echo 1;exit;echo2' >a && chmod u+x a && ./target/debug/cicada ./a
    1
    
    opened by ghost 3
  • support for multiple config files

    support for multiple config files

    I usually like to have my aliases, exports, etc. separated into separate files so its easier to read. And then inside .bashrc or .bash_profile I would import them in. Currently, cicada does not work with multiple files I think, or am I doing this wrong?

    Thanks!

    My bash script for importing files:

    SHELL=cicada
    
    INCLUDE_FILES=( \
    	"$HOME/.config/$SHELL/dirs.sh" \
    	"$HOME/.config/$SHELL/alias.sh" \
    	"$HOME/.config/$SHELL/exports.sh" \
    )
    
    for FILE in ${INCLUDE_FILES[@]}; do
    	if [ -f "$FILE" ]; then
    		source "$FILE"
    	fi
    done
    
    opened by kamiyaa 2
  • Optionally import Bash history into sqlite database on first run

    Optionally import Bash history into sqlite database on first run

    It would be nice if, upon first run (i.e., the cicada history database does not yet exist), the user could be prompted to import their Bash history into the database. If no date exists for an entry then it would use the current timestamp, otherwise it would use the provided timestamp from the .bash_history file:

    Example .bash_history with timestamps

    #1603194812
    startx
    #1603195328
    vim .inputrc
    
    opened by rypervenche 2
  • Support accessing subprocess stdin/out as file

    Support accessing subprocess stdin/out as file

    Bash supports getting the FD of an opened pipe directly in the form /dev/fd/X which then can be used as file path by the spawned process.

    Expected:

    $ head <(echo a) <(echo b)
    ==> /dev/fd/63 <==
    a
    
    ==> /dev/fd/62 <==
    b
    

    Got:

    $ head <(echo a) <(echo b)
    head: <echo: No such file or directory
    head: a: No such file or directory
    head: <echo: No such file or directory
    head: b: No such file or directory
    

    Same for >(CMD) which will use stdin instead of stdout.

    opened by pothos 3
Releases(v0.9.34)
like ~~grep~~ UBER, but for binaries

bingrep Greps through binaries from various OSs and architectures, and colors them. Current backends: ELF 32/64, arm, x86, openrisc - all others will

null 1.6k Jan 1, 2023
Provides assert_eq! like macros with colorized diff output

similar-asserts similar-asserts is a crate that enhances the default assertion experience by using similar for diffing. It supports comparing either D

Armin Ronacher 74 Nov 29, 2022
A modern replacement for ps written in Rust

procs procs is a replacement for ps written in Rust. Documentation quick links Features Platform Installation Usage Configuration Features Output by t

null 3.6k Jan 5, 2023
Blazing 💥 fast terminal-ui for git written in rust 🦀

Blazing fast terminal client for git written in Rust Features Fast and intuitive keyboard only control Context based help (no need to memorize tons of

Stephan Dilly 11.8k Jan 5, 2023
A simple and fast download accelerator, written in Rust

zou A simple and fast download accelerator, written in Rust Zou is a Snatch fork by @k0pernicus. Snatch is a fast and interruptable download accelerat

Antonin Carette 173 Dec 4, 2022
Performs distributed command execution, written in Rust w/ Tokio

Concurr: Distributed and Concurrent Command Execution, in Rust This project is dual licensed under MIT and Apache 2.0. Originally inspired by the GNU

Michael Murphy 93 Dec 18, 2022
A TUI system monitor written in Rust

NO LONGER MAINTAINED. For a similar program, check out https://github.com/ClementTsang/bottom. ytop Another TUI based system monitor, this time in Rus

Caleb Bassi 2.1k Jan 3, 2023
A non-root version of traceroute written in Rust

tracepath-rs A non-root version of traceroute written in Rust for Linux.

Peter Malmgren 9 Dec 30, 2022
Dancing Links (“dlx”) solver for the exact cover problem, written in Rust. Can be used to create a sudoku solver.

Dancing Links “dlx” Dancing Links solver for “algorithm X” by Knuth This solver solves the exact cover problem using “algorithm X”, implemented using

bluss 4 Nov 19, 2022
A system handler to get information and interact with processes written in Rust

A system handler to get information and interact with processes written in Rust

Guillaume Gomez 1.1k Jan 3, 2023
LeftHK - A hotkey daemon written in Rust

LeftHK LeftHK - A hotkey daemon written in Rust THIS IS BETA SOFTWARE The configuration file should be created in ~/.config/lefthk/ and called config.

null 15 Oct 12, 2022
minimalistic command launcher in rust

rrun Note: Apart from the occasional fix, this project is not actively developed anymore. rrun works fine and should run/compile for the time being on

null 105 Nov 18, 2022
Yet another fancy watcher. (Rust)

funzzy Yet another fancy watcher. (Inspired by antr / entr) Configure execution of different commands using semantic yaml. # .watch.yaml # list here a

Cristian Oliveira 188 Dec 12, 2022
A more intuitive version of du in rust

Dust du + rust = dust. Like du but more intuitive. Why Because I want an easy way to see where my disk is being used. Demo Install Cargo cargo install

andy.boot 5.5k Jan 8, 2023
Fuzzy Finder in rust!

Life is short, skim! Half of our life is spent on navigation: files, lines, commands… You need skim! It is a general fuzzy finder that saves you time.

Jinzhou Zhang 3.7k Jan 4, 2023
A library to listen to global hotkeys in Rust

Rust Hotkey A library to listen to global hotkeys in Rust How to use See the examples folder for how to use this library. OS Support This lib aims to

James Birtles 44 Dec 12, 2022
🔮 Futuristic take on hexdump, made in Rust.

hex (hx) Futuristic take on hexdump. hx accepts a file path as input and outputs a hexadecimal colorized view to stdout. $ hx tests/files/alphanumeric

Julian Sitkevich 387 Dec 27, 2022
Cross-platform Rust rewrite of the GNU coreutils

uutils coreutils uutils is an attempt at writing universal (as in cross-platform) CLI utilities in Rust. This repository is intended to aggregate GNU

null 13k Dec 30, 2022
A rust layered configuration loader with zero-boilerplate configuration management.

salak A layered configuration loader with zero-boilerplate configuration management. About Features Placeholder Key Convension Cargo Features Default

Daniel YU 28 Sep 20, 2022