dundalek / closh
- четверг, 2 ноября 2017 г. в 03:14:10
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?
Why shell based on Clojure(Script)?
Warning: Closh is still in a early stage and under a heavy development. It is not ready for daily use yet since it is quite easy to get it to crash. At this moment I am most interested in gathering feedback and use cases to help make the best possible design trade-offs. Closh is tested on Linux, should run on macOS too. Windows who knows.
Feedback is greatly appreciated. If you have feedback about a specific feature feel free to open an issue. For general discussion you can use gitter.
Install closh (requires node.js):
npm install -g lumo-cljs closh
Start the shell:
closh
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)
Read the guide to learn more.
Initial proof-of-concept, try out if the combination of shell and Clojure could work. [COMPLETED]
Implement essential functionality needed for daily use by early adopters. [IN PROGRESS]
~/.closhrc
on startupAdd additional features users expect from a shell. Then fix bugs and stabilize through continuous daily use.
At this point we can start to experiment with innovative ideas and paradigms. For example:
Closh runs ClojureSript on node.js via lumo REPL. In order to be somewhat bashward compatible there is a command mode which transforms top-level forms in a macro-like way.
Thanks to Clojure's syntax for symbols supporting almost all characters we don't need to roll out a custom parser to support convenient unquoted notation for filenames and switches. Only customization done to a built-in reader is the support multiple slashes in a symbol, which is required for nested directories.
Clone the repo and install dependencies
git clone git@github.com:dundalek/closh.git
cd closh
npm install
Run the app
npm start
Run in dev mode reloading on changes
npm run dev
Run tests once
lein test
Re-run tests on change
lein test-auto
Generate API documentation into doc/api
lein doc
Copyright (c) Jakub Dundalek
Distributed under the Eclipse Public License 1.0.