Giter Club home page Giter Club logo

closh's Introduction

closh - Bash-like shell based on Clojure

Join the chat at https://gitter.im/closh/Lobby

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:

closh demo screencast

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.

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. 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.

Get in touch

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.

Quick Start

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.

Roadmap

Stage 1

Initial proof-of-concept, try out if the combination of shell and Clojure could work. [COMPLETED]

  • Command execution
  • Pipes
  • IO Redirects
  • Interactive mode REPL

Stage 2

Implement essential functionality needed for daily use by early adopters. [IN PROGRESS]

  • Dynamic prompt
  • Persistent history
  • Autocomplete
  • Configuration
    • Loads ~/.closhrc on startup
    • Aliases
    • Key bindings
    • Life-cycle hooks

Stage 3

Add additional features users expect from a shell. Then fix bugs and stabilize through continuous daily use.

  • Handle common errors
  • Signal control
  • Job control
  • Environment variable integration
  • Builtin utility functions
  • Testing and stability

Stage 4

At this point we can start to experiment with innovative ideas and paradigms. For example:

Tech details

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.

Development

Clone the repo and install dependencies

git clone [email protected]: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 & License

Copyright (c) Jakub Dundalek

Distributed under the Eclipse Public License 1.0.

closh's People

Contributors

dundalek avatar gdeer81 avatar gitter-badger avatar

Watchers

Kris Rott avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.