• Stars
    star
    1,604
  • Rank 28,030 (Top 0.6 %)
  • Language
    Clojure
  • License
    Eclipse Public Li...
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Bash-like shell based on Clojure

closh

closh - Bash-like shell based on Clojure

Chat about Closh at Zulip Join the chat at https://gitter.im/closh/Lobby Build status on CircleCI GitHub release

Status update 2022: Closh is now on hiatus.
Although the initial proof of concept turned out promising, it would take much more work to make it a robust tool that could be relied upon by a wider audience.
For now I recommend using fish as an interactive shell and babashka for scripts.

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

Community and Contribution

If you have feedback about a specific feature or found a bug please open an issue.
Use reddit for general discussion and to share scripts and workflows. Chat room is on zulip or gitter.

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.

Install

Windows proper is currently NOT supported, but it should run under WSL 2. If you know your way around with Windows, we need your help (see #54).

Try closh online in the browser without installing anything.

Clojure/JVM version

Download the jar file from the releases page and run it with:

java -jar closh-zero.jar

The jar file also contains a special header, so once you make it executable you can run it directly:

chmod +x closh-zero.jar
./closh-zero.jar

It can also run with clojure CLI:

clojure -Sdeps '{:deps {closh {:git/url "https://github.com/dundalek/closh.git" :tag "v0.5.0" :sha "6a7c0aa293616e2d28f7f735e915a301e44d2121"}}}' -m closh.zero.frontend.rebel

ClojureScript/Lumo version

Install closh (requires Node.js version 9.x, support for version 10 is in progress, see #113):

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

Quick Start

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)

If you like closh you can set it as your default shell.

Be careful and first test closh from other shell to make sure it works on your machine so you don't get locked out of shell (after chsh you need to log out and log back in for changes to take effect):

which closh | sudo tee -a /etc/shells
chsh -s $(which closh)

For the JVM version you can make it the default shell similarly like:

closh=/path/to/closh-zero.jar
chmod +x $closh
echo $closh | sudo tee -a /etc/shells
chsh -s $closh

Documentation

Roadmap

Terminal UI improvements and exploration

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.

  • Try to integrate Liquid as the editor interface, which would enable us:
    • Better and more flexible readline experience
    • Customizable key bindings
  • Try to explore Trikl for building interactive command-line interfaces
  • Data helpers that automatically parse command output into data structures
  • Automatic abbreviation suggestion
  • Explore launcher functionality similar to Alfred, Lacona and others

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.

  • Implement a low-level native pipeline library to improve performance
  • Make it more robust and better error handling
  • Job control

Limitations

JVM version (CLJ)

Lumo version (CLJS)

  • No script mode
  • No syntax highlighting
  • Prompt quirks
  • Synchronous execution hacks (via deasync library)

Development

Clone the repo and install dependencies

git clone [email protected]:dundalek/closh.git
cd closh
npm install

Run the cljs app

npm start

Run the clj app

clojure -m closh.zero.frontend.rebel

Run tests once

npm run test

Re-run tests on change

npm run test-auto

Manual Java builds

Run npm run pkg-java. The resulting binary will be in target/closh-zero.jar.

Sponsors

Thank you for the support:

Mentions

Copyright & License

Copyright (c) Jakub Dundalek and contributors

Distributed under the Eclipse Public License 1.0 (same as Clojure).

Logo created by @batarian71 under CC BY 4.0.

More Repositories

1

markmap

Visualize markdown documents as mindmaps
JavaScript
1,604
star
2

awesome-lisp-languages

A list of Lisp-flavored programming languages
673
star
3

liz

Lisp-flavored general-purpose programming language (based on Zig)
Clojure
248
star
4

GrammKit

Generate diagrams for parser grammars
JavaScript
232
star
5

lazy-lsp.nvim

Neovim plugin to auto install LSP servers
Lua
171
star
6

latinize

Simple library to convert accents (diacritics) from strings to latin characters.
JavaScript
148
star
7

atom-markdown-mindmap

Visualize markdown files as mindmaps in Atom editor
CoffeeScript
118
star
8

warehouse

Warehouse.js is a data storage layer for node.js and browser providing unified API for many supported storage engines (MongoDB, MySQL, SQLite, in-memory and others).
JavaScript
104
star
9

clojurescript-guide

My notes on ClojureScript
69
star
10

react-blessed-contrib

A wrapper for blessed-contrib widgets to be rendered with react-blessed.
JavaScript
60
star
11

notcurses-zig-example

Demo showing how to use Notcurses library for building terminal UIs with Zig
Zig
56
star
12

kmdoc

KMDoc is a software for an intelligent representation of knowledge useful for quick learning and browsing.
JavaScript
42
star
13

casio-f91w-fsm

Interactive model of the Casio F-91W watch using statecharts
Clojure
29
star
14

osquery-rest-adapter

Visualize information about your OS (REST adapter for osquery compatible with Vega)
JavaScript
26
star
15

dinodoc

Docusaurus-powered documentation system for Clojure and other languages
Clojure
23
star
16

parpar.nvim

Plugin for Neovim that seamlessly integrates Parinfer and Paredit for editing lisp code
Lua
22
star
17

longdown

Convert longform markdown files to outline format used by Logseq
Clojure
20
star
18

notcurses-clojure-example

Demo showing how to use Notcurses library for building terminal UIs with Clojure
C
14
star
19

bindem

A light-weight library providing Knockout-like two-way declarative data binding for Backbone.
JavaScript
13
star
20

humble-outliner

Clojure
12
star
21

knowledge-base

Notes on various subjects represented using KMDoc knowledge format
HTML
8
star
22

dotfiles

Shell
7
star
23

archieml-peg

Alternative parser for ArchieML in JavaScript using PEG (Parsing Expression Grammar)
JavaScript
7
star
24

git-sheet

Interactive page which presents most used git commands as a cheat sheet.
JavaScript
6
star
25

czech-stemmer

This is a port of stemmer for Czech language to Javascript, for both node.js and browser.
JavaScript
6
star
26

jquery-tagin

Simple jQuery Tag Input plugin with advanced features
JavaScript
5
star
27

userstyles

CSS
5
star
28

solid-cljs

Clojure
5
star
29

intools

Clojure
4
star
30

github-comparison

Show comparison of github repos in a table with this simple javascript component.
JavaScript
4
star
31

recline-warehouse

code for integration of Recline.js with Warehouse.js and other various additions to Recline
JavaScript
4
star
32

testing-without-mocks-clojure

Clojure
4
star
33

MEB-Genetic-Algorithm

Genetic Algorithm implementation in javaScript solving Minimum Energy Broadcast Problem
JavaScript
2
star
34

whitescape.js

Library for escaping whitespace characters
JavaScript
2
star
35

QueryHammer

QueryHammer is a visual tool that helps you create queries interactively
JavaScript
2
star
36

adventofcode

Clojure
2
star
37

rama-clj-playground

Clojure
2
star
38

humble-graal

Compile HumbleUI apps with GraalVM
Clojure
2
star
39

lumo-unpack-binding

Unpack binary node bindings for apps bundled with pkg-lumo
JavaScript
1
star
40

vmp

1
star
41

calculator-exercise

Clojure
1
star
42

cljs-stickies

Sticky notes demo app with Drag n Drop written in ClojureScript
Clojure
1
star
43

notemx

NoteMX is a note taking app for Android with Dropbox sync using React Native
JavaScript
1
star
44

livereloader

[Deprecated] Simple HTTP server with livereload functionality. No setup, other apps or browser extensions required.
JavaScript
1
star
45

x11-playground

JavaScript
1
star
46

pickfile

JavaScript file picker component supporting drag and drop, file chooser and remote URL
JavaScript
1
star
47

cljs-kanban

Kanban board with drag and drop written in ClojureScript
Clojure
1
star
48

commandray

CommandRay is a graphical command-line tool to discover and execute commands more efficiently
JavaScript
1
star
49

cljs-date-format-tool

A simple tool that helps creating date format strings
Clojure
1
star