closh - Bash-like shell based on Clojure
Closh combines the best of traditional unix shells with the power of Clojure. It aims to be a modern alternative to bash.
Demo showing how to execute commands and using Clojure to manipulate outputs in shell:
Why try to reinvent bash?
- Bash has obscure syntax for non-trivial operations and lots of WTF moments.
- It treats everything as text while we mostly need to manipulate structured information.
- It is a large codebase which makes it difficult to hack on it and try innovative ideas. Which is one of the reasons why the shell did not improve much in recent decades.
- Traditional shells are limited in terms of presentation and discoverability, what if we could bring back richer environment as imagined by lisp machines?
Why shell based on Clojure(Script)?
- Clojure's has a simple syntax and well-thought design which makes it pleasurable to work with.
- Its extensive collection of powerful functions for data manipulation is suitable to provide solutions for daily tasks.
- Write shell scripts in a language you use daily for development so you don't have to google arcane shell constructs every time you need to do anything but simplest tasks.
- Less amount and more composable code allows to experiment with new features and ideas.
Warning: Closh is still in a early stage and under a heavy development, has many rough edges and is subject to change a lot. Closh is tested on Linux, should run on macOS too. Windows who knows.
Community and Contribution
If you would like to contribute take look at open issues. Leave a comment if you find anything interesting and we can improve the project together.
Windows is currently NOT supported! If you know your way around with Windows, we need your help (see #54).
Install closh (requires node.js version 9.x):
npm install -g closh
If you get a permission error then try:
npm install -g closh --unsafe-perm
To install development version from master branch:
npm i -g dundalek/closh
Start the shell:
Run simple commands like you are used to:
$ echo hi $ git status $ ls -l *.json
Commands starting with a parenthesis are evaluated as Clojure code:
$ (+ 1 2) ; => 3
The power comes from combining shell commands and Clojure:
$ echo hi | (clojure.string/upper-case) ; => HI $ ls *.json |> (reverse) ; Count number of files grouped by first letter sorted by highest count first $ ls |> (group-by first) | (map #(update % 1 count)) | (sort-by second) | (reverse)
If you like closh you can set it as your default shell (afterwards you need to log out and log back in):
which closh | sudo tee -a /etc/shells chsh -s $(which closh)
- Guide and Reference - Introduction to closh and basic configuration
- Cookbook - Recipes for integration of other tools like NVM, Autojump, etc.
- Design Principles - Learn about the philosophy and what guides design decisions
- Tech notes - Read about internals and architecture
- Notes on Existing Shells
Upcoming release v0.3
- Add JVM support
- Integrate rebel-readline
- Distribute closh and lumo as a single binary
- Explore possibility to compile JVM version with Graal and distribute as a single binary
Terminal UI improvements and ideas
Explore innovate UI ideas, explore what a shell could become and all possibilities within an ASCII terminal. The goal is to reimagine what people think a command line interface is without having to lose its core power.
- Readline improvements
- Interactive command-line interfaces
- Key bindings
- Syntax highlighting
- Explore launcher functionality similar to Alfred and others
- Automatic abbreviation suggestion
- Data helpers that automatically parse command output into data structures
More UI exploration
Explore if we could take shell power and functionality and lift it from the boundaries set by ASCII terminals.
Stabilization and performance
I hope that new UI ideas above will get people excited and interested. After that we should work on stabilization and adding all the remaining features people are used to from traditional shells.
- Script mode
- Implement a low-level native pipeline library to improve performance
- Make it more robust and better error handling
- Job control
Clone the repo and install dependencies
git clone firstname.lastname@example.org:dundalek/closh.git cd closh npm install
Run the app
Run in dev mode reloading on changes
npm run dev
Run tests once
Re-run tests on change
Copyright & License
Copyright (c) Jakub Dundalek and contributors
Distributed under the Eclipse Public License 1.0 (same as Clojure).