elvish

command module
v0.0.0-...-d1114cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2017 License: BSD-2-Clause Imports: 19 Imported by: 0

README

A friendly and expressive Unix shell

GoDoc Build Status on Travis Coverage Status Go Report Card License Twitter

General discussions: Gitter Telegram Group

Development discussions: Gitter Telegram Group

Elvish is a cross-platform shell suitable for both interactive use and scripting. It features a full-fledged, non-POSIX-shell programming language with advanced features like namespacing and anonymous functions, and a powerful, fully programmable user interface that works well out of the box.

... which is not 100% true yet. Elvish is already suitable for most daily interactive use, but it is not yet complete. Contributions are more than welcome!

Oh and here is a logo, which happens to be how Elvish looks like when you type elvish into it:

logo

This README documents the development aspect of Elvish. Other information is to be found on the website.

Building Elvish

To build Elvish, you need

  • A Go toolchain >= 1.6.

  • Linux (with x86, x64 or amd64 CPU) or macOS (with reasonably new hardware).

    It's quite likely that Elvish works on BSDs and other POSIX operating systems, or other CPU architectures; this is not guaranteed due to the lack of good CI support and developers who use such OSes. Pull requests are welcome.

    Windows is not supported yet.

The Correct Way

Elvish is a go-gettable package. To build Elvish, first set up your Go workspace according to How To Write Go Code, and then run

go get github.com/jumpscale/elvish
The Lazy Way

Here is something you can copy-paste into your terminal:

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
mkdir -p $GOPATH

go get github.com/jumpscale/elvish

for f in ~/.bashrc ~/.zshrc; do
    printf 'export %s=%s\n' GOPATH '$HOME/go' PATH '$PATH:$GOPATH/bin' >> $f
done

The scripts sets up the Go workspace and runs go get for you. It assumes that you have a working Go installation and currently use bash or zsh.

The Homebrew Way

Users of macOS can build Elvish using Homebrew:

brew install --HEAD elvish
Extending Elvish

There are two ways for extending Elvish

  • Using .elv scripts:

    • Add any .elv script file in eval directory
    • Regenerate embeddedModules using gen-embedded-modules elvish script
    elvish -c "cd <YOUR_GOPATH>/src/github.com/jumpscale/elvish/eval;./gen-embedded-modules"
    
    • Rebuild Elvish, you will find all of your variables and methods exist using namespaces
  • Using Golang methods

    • Create new go package in eval directory (i.e jumpscale)
    • in jumpscale package add you new methods and register their namespaces
    package jumpscale
    
    import (
        "github.com/jumpscale/elvish/eval"
    )
    
    func Namespace() eval.Namespace {
        ns := eval.Namespace{}
        eval.AddBuiltinFns(ns, fns...)
        return ns
    }
    
    var fns = []*eval.BuiltinFn{
        {"myfunc", myFunc},
    }
    
    // Simple method to print each argument in newline on the console
    func myFunc(ec *eval.EvalCtx, args []eval.Value, opts map[string]eval.Value) {
        out := ec.OutputChan()
        for _, arg := range args {
            out <- eval.String(arg.Repr(0))
        }
    }
    
    • import your new package in the main.go file
    import ("github.com/arahmanhamdy/elvish/eval/jumpscale")
    
    • in main.go file modify extraModule variable to include your module
    extraModules := map[string]eval.Namespace{
      		.....
      		"jumpscale": jumpscale.Namespace(),
      		....
    }
    
    • Rebuild Elvish, you will be able to call your myfunc method using jumpscale namespace (i.e jumpscale:myfunc)

Note that you can still extend elvish without editing the source code by importing modules

Name

In roguelikes, items made by the elves have a reputation of high quality. These are usually called elven items, but I chose "elvish" because it ends with "sh", a long tradition of Unix shells. It also rhymes with fish, one of shells that influenced the philosophy of Elvish.

The word "Elvish" should be capitalized like a proper noun. However, when referring to the elvish command, use it in lower case with fixed-width font.

Whoever practices the Elvish way by either contributing to it or simply using it is called an Elf. (You might have guessed this from the name of the GitHub organization.) The official adjective for Elvish (as in "Pythonic" for Python, "Rubyesque" for Ruby) is Elven.

Documentation

Overview

Elvish is an experimental Unix shell. It tries to incorporate a powerful programming language with an extensible, friendly user interface.

Directories

Path Synopsis
Package exec provides the entry point of the daemon sub-program and helpers to spawn a daemon process.
Package exec provides the entry point of the daemon sub-program and helpers to spawn a daemon process.
api
Package API provides the API to the daemon RPC service.
Package API provides the API to the daemon RPC service.
service
Package service implements the daemon service for mediating access to the storage backend.
Package service implements the daemon service for mediating access to the storage backend.
Package edit implements a command line editor.
Package edit implements a command line editor.
history
Package history provides utilities for the command history.
Package history provides utilities for the command history.
tty
ui
Package ui contains types that may be used by different editor frontends.
Package ui contains types that may be used by different editor frontends.
Package eval handles evaluation of nodes and consists the runtime of the shell.
Package eval handles evaluation of nodes and consists the runtime of the shell.
re
getopt is a command-line argument parser.
getopt is a command-line argument parser.
Package glob implements globbing for elvish.
Package glob implements globbing for elvish.
Package parse implements the elvish parser.
Package parse implements the elvish parser.
Package shell is the entry point for the terminal interface of Elvish.
Package shell is the entry point for the terminal interface of Elvish.
Package store abstracts the persistent storage used by elvish.
Package store abstracts the persistent storage used by elvish.
storedefs
Package storedefs contains definitions used by the store package.
Package storedefs contains definitions used by the store package.
Package sys provide convenient wrappers around syscalls.
Package sys provide convenient wrappers around syscalls.
Package util contains utility functions.
Package util contains utility functions.
Package web is the entry point for the backend of the web interface of Elvish.
Package web is the entry point for the backend of the web interface of Elvish.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL