elvish/README.md

157 lines
4.8 KiB
Markdown
Raw Normal View History

2016-01-27 07:11:55 +08:00
# A novel Unix shell
2013-06-16 16:45:22 +08:00
[![GoDoc](http://godoc.org/github.com/elves/elvish?status.svg)](http://godoc.org/github.com/elves/elvish)
[![Build Status on Travis](https://travis-ci.org/elves/elvish.svg?branch=master)](https://travis-ci.org/elves/elvish)
2014-01-31 21:02:49 +08:00
2016-01-27 07:11:55 +08:00
This project aims to explore the potentials of the Unix shell. It is a work in
progress; things will change without warning.
2016-02-17 03:01:34 +08:00
The [wiki](https://github.com/elves/elvish/wiki) has a random list of things you might want to know. The [issues list](https://github.com/elves/elvish/issues) contains many things I'm working on.
2016-01-27 07:11:55 +08:00
## The Interface
2014-01-08 19:07:34 +08:00
Syntax highlighting (also showcasing right-hand-side prompt):
2016-02-17 03:01:34 +08:00
![syntax highlighting](https://raw.githubusercontent.com/elves/images/master/syntax.png)
2014-01-08 19:07:34 +08:00
Tab completion for files:
2014-01-08 19:07:34 +08:00
2016-01-29 09:22:29 +08:00
![tab completion](https://raw.githubusercontent.com/elves/images/master/completion.png)
2014-01-08 19:07:34 +08:00
2016-02-17 03:01:34 +08:00
Navigation mode (triggered with ^N, inspired by [ranger](http://ranger.nongnu.org/)):
2016-01-29 09:22:29 +08:00
![navigation mode](https://raw.githubusercontent.com/elves/images/master/navigation.png)
2013-12-29 15:04:37 +08:00
2016-01-27 07:11:55 +08:00
Planned features:
2013-12-29 15:04:37 +08:00
2016-01-27 07:11:55 +08:00
* Auto-suggestion (like fish)
2013-12-29 15:04:37 +08:00
* Programmable line editor
2016-01-27 07:11:55 +08:00
* Directory jumping (#27)
2013-12-29 15:04:37 +08:00
* A vi keybinding that makes sense
2016-01-27 07:11:55 +08:00
* History listing (like
[ptpython](https://github.com/jonathanslenders/ptpython))
* Intuitive multiline editing
2013-12-29 15:04:37 +08:00
## The Language
2013-12-29 15:04:37 +08:00
2016-01-27 07:11:55 +08:00
Some things that the language is already capable of:
2013-12-29 15:20:49 +08:00
2016-01-27 07:19:48 +08:00
* External programs and pipelines: (`~>` is the prompt):
2013-12-29 15:12:01 +08:00
```
2015-01-27 03:56:07 +08:00
~> vim README.md
2013-12-29 15:20:49 +08:00
...
2015-01-27 03:56:07 +08:00
~> cat -v /dev/random
2013-12-29 15:20:49 +08:00
...
2016-01-27 07:19:48 +08:00
~> dmesg | grep -i acpi
2013-12-29 15:20:49 +08:00
...
2013-12-29 15:12:01 +08:00
```
2016-01-27 07:19:48 +08:00
* Arithmetics using the prefix notation:
2013-12-29 15:07:29 +08:00
```
2015-01-27 03:56:07 +08:00
~> + 1 2
▶ 3
2016-02-07 21:12:19 +08:00
~> mul (+ 1 2) 3
▶ 9
2013-12-29 15:07:29 +08:00
```
2013-12-29 15:04:37 +08:00
2016-01-27 07:19:48 +08:00
* Quoting:
2013-12-29 15:07:29 +08:00
```
~> echo "| C'est pas une pipe."
| C'est pas une pipe.
2013-12-29 15:07:29 +08:00
```
2013-12-29 15:04:37 +08:00
2016-01-27 07:19:48 +08:00
* Lists and maps:
2013-12-29 15:07:29 +08:00
```
~> println list: [a list] map: [&key=value]
list: [a list] map: [&key=value]
~> println [a b c][0]
2013-12-29 15:07:29 +08:00
a
~> println [&key=value][key]
2013-12-29 15:07:29 +08:00
value
```
2013-12-29 15:04:37 +08:00
2016-01-27 07:19:48 +08:00
* Variables:
2013-12-29 15:07:29 +08:00
```
~> v=[&foo=bar]; put $v[foo]
▶ bar
2013-12-29 15:07:29 +08:00
```
2013-12-29 15:04:37 +08:00
2016-01-27 07:11:55 +08:00
* Defining functions:
2013-12-29 15:07:29 +08:00
```
2016-02-07 10:56:25 +08:00
~> fn map [f xs]{ put [(put $@xs | each $f)] }
2013-12-29 15:07:29 +08:00
```
2013-12-29 15:04:37 +08:00
2016-01-27 07:11:55 +08:00
* Lisp-like functional programming:
2013-12-29 15:07:29 +08:00
```
2016-01-27 07:11:55 +08:00
~> map [x]{+ 10 $x} [1 2 3]
[11 12 13]
2016-02-07 21:12:19 +08:00
~> map [x]{div $x 2} (map [x]{+ 10 $x} [1 2 3])
2016-01-27 07:11:55 +08:00
[5.5 6 6.5]
2013-12-29 15:07:29 +08:00
```
2013-12-29 15:04:37 +08:00
2016-01-27 07:11:55 +08:00
* More natural concatenative style:
```
2016-02-07 21:12:19 +08:00
~> put 1 2 3 | each [x]{+ 10 $x} | each [x]{div $x 2}
2016-01-27 07:11:55 +08:00
▶ 5.5
▶ 6
▶ 6.5
```
2016-01-27 07:19:48 +08:00
* A separate `env:` namespace for environmental variables:
2013-12-29 15:07:29 +08:00
```
2015-01-27 03:56:07 +08:00
~> put $env:HOME
2015-01-25 07:12:40 +08:00
▶ /home/xiaq
~> env:PATH=$env:PATH":/bin"
2013-12-29 15:07:29 +08:00
```
2013-12-29 15:04:37 +08:00
2016-01-27 07:11:55 +08:00
## Getting elvish
2016-01-27 07:11:55 +08:00
### Prebuilt binaries
2016-01-27 07:11:55 +08:00
Prebuilt binaries are available for 64-bit [Linux](https://dl.elvish.io/elvish-linux.tar.xz) and [Mac OS X](https://dl.elvish.io/elvish-osx.tar.xz). They are always built using the latest commit that builds. Download the archive and use `sudo tar xfJ elvish-*.tar.xz -C /usr/bin` to install.
2016-01-27 07:11:55 +08:00
### Building It Yourself
2016-01-27 07:11:55 +08:00
Go >= 1.5 is required. This repository is a go-getable package.
2016-01-27 07:11:55 +08:00
2016-02-17 03:01:34 +08:00
Linux is fully supported. It is likely to work on BSDs and Mac OS X. Windows is **not** supported yet.
2013-09-22 18:49:07 +08:00
2016-02-17 03:01:34 +08:00
In case you are new to Go, you are advised to read [How To Write Go Code](http://golang.org/doc/code.html), but here is a quick snippet:
2013-09-22 18:49:07 +08:00
2016-01-27 07:11:55 +08:00
```
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
go get github.com/elves/elvish{,/elvish-stub}
2016-01-27 07:11:55 +08:00
elvish
```
2013-09-22 18:49:07 +08:00
2016-01-27 07:11:55 +08:00
To update and rebuild:
2016-01-27 07:11:55 +08:00
```
go get -u github.com/elves/elvish{,/elvish-stub}
2016-01-27 07:11:55 +08:00
```
2016-02-17 03:01:34 +08:00
Remember to put the two `export`s above into your `bashrc` or `zshrc` (or whatever).
2016-01-27 07:11:55 +08:00
## Name
2016-02-17 03:01:34 +08:00
In [roguelikes](https://en.wikipedia.org/wiki/Roguelike), items made by the elves have a reputation of high quality. These are usually called **elven** items, but I chose **elvish** for an obvious reason.
The adjective for elvish is also "elvish", not "elvishy" and definitely not "elvishish".
2016-02-17 03:01:34 +08:00
## Test coverages:
2016-02-17 03:01:34 +08:00
|Package|Coverage|
|-------|--------|
2016-02-17 07:30:11 +08:00
|edit|[![edit](https://gocover.io/_badge/github.com/elves/elvish/edit/)](https://gocover.io/github.com/elves/elvish/edit/)|
|eval|[![eval](https://gocover.io/_badge/github.com/elves/elvish/eval/)](https://gocover.io/github.com/elves/elvish/eval/)|
|glob|[![glob](https://gocover.io/_badge/github.com/elves/elvish/glob/)](https://gocover.io/github.com/elves/elvish/glob/)|
|parse|[![parse](https://gocover.io/_badge/github.com/elves/elvish/parse/)](https://gocover.io/github.com/elves/elvish/parse/)|
|run|[![run](https://gocover.io/_badge/github.com/elves/elvish/run/)](https://gocover.io/github.com/elves/elvish/run/)|
2016-02-17 07:30:11 +08:00
|store|[![store](https://gocover.io/_badge/github.com/elves/elvish/store/)](https://gocover.io/github.com/elves/elvish/store/)|
2016-02-21 22:31:40 +08:00
|stub|[![stub](https://gocover.io/_badge/github.com/elves/elvish/stub/)](https://gocover.io/github.com/elves/elvish/stub/)|
2016-02-17 07:30:11 +08:00
|sys|[![sys](https://gocover.io/_badge/github.com/elves/elvish/sys/)](https://gocover.io/github.com/elves/elvish/sys/)|
|util|[![util](https://gocover.io/_badge/github.com/elves/elvish/util/)](https://gocover.io/github.com/elves/elvish/util/)|