Giter VIP home page Giter VIP logo

dish's Introduction

Dish

A Delightful Interactive Shell

License

Note: This project is still under development.If you encounter any bug,
feel free to submit an Issue or PR.

Feature

  • Automatic completion and hint
  • UTF8 support
  • Extending with Lua
  • Command line highlight

Config.lua

  • Dish will run config.lua for initialization, such as styles, alias, environments ...

Style

This is the color definitions for command line highlight.

dish.style = {
    cmd = dish.effects.fg_blue,
    arg = dish.effects.fg_cyan,
    string = dish.effects.fg_yellow,
    env = dish.effects.fg_green,
    error = dish.effects.fg_red,
    hint = dish.effects.faint,
    info = dish.effects.fg_magenta
}
  -- Dish Currently supports:
  -- bold = 1, faint, italic, underline, slow_blink, rapid_blink, color_reverse,
  -- fg_black = 30, fg_red, fg_green, fg_yellow, fg_blue, fg_magenta, fg_cyan, fg_white,
  -- bg_black = 40, bg_red, bg_green, bg_yellow, bg_blue, bg_magenta, bg_cyan, bg_white

Alias

dish.alias = {
    ls ="ls --color=tty",
    grep ="grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}"
}

Extending With Lua

Custom Prompt

dish.prompt
  • Returns a string
function prompt() 
    return ">> "
end
dish.prompt = my_prompt

Embedded Lua Function

One thing worth noting is that every argument passed to Lua is string.

function hello(str)
    return string.format("hello, %s", str);    
end
dish.func["hello"] = hello;
$ hello dish
hello, dish

Completion/Hint

dish.complete = complete;
dish.enable_hint = true;
dish.hint = hint;

Two arguments will be passed to dish.complete/dish.hint

  1. The string before the last word of the command line
  2. The last word of the command line
  • Return nil or not return for no completion/hint
  • Use dish.enable_hint = false to disable hint.
dish.complete

  • Return table{ table {string1, string2}}} or table{ table {string1, string2, string3}}}
  • string1 is the raw string to be put on the command line
  • string2 is the information you want to show when selecting completions
  • string3 is the string you want to show when selecting completions (default = string1)
    Selecting completions could be something like this:
$ git string1
add                (Add file contents to the index)
string3                                   (string2)
lines: 2/26
dish.hint

  • Return a string
    Hint will be added after the pattern(the 2nd argument) on command line with a different color(defined int the config.lua)

Dish Interface

dish.environment
  • Stores all environment variables in string
dish_get_tilde_path()
  • Return the current path with $HOME replaced by ~
dish_get_shrunk_path()

Return the current path:

  • All the parent path will be replaced by its first character
  • $HOME is replaced by ~
dish_add_history(timestamp, cmd)
  • Add a history

Note

Dish currently does not support scripting.

Bundled

Reference

Lua

Shell

Contact

  • If you have any questions or suggestions, please submit an issue or email me.
  • Email: cao2013zh at 163 dot com

Contribution

  • Any contributions are welcomed, just send a PR.

License

dish's People

Contributors

caozhanhao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.