A Delightful Interactive Shell
Note: This project is still under development.If you encounter any bug,
feel free to submit an Issue or PR.
- Automatic completion and hint
- UTF8 support
- Extending with Lua
- Command line highlight
- Dish will run
config.lua
for initialization, such as styles, alias, environments ...
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
dish.alias = {
ls ="ls --color=tty",
grep ="grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}"
}
- Returns a string
function prompt()
return ">> "
end
dish.prompt = my_prompt
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
dish.complete = complete;
dish.enable_hint = true;
dish.hint = hint;
Two arguments will be passed to dish.complete
/dish.hint
- The string before the last word of the command line
- The last word of the command line
- Return nil or not return for no completion/hint
- Use
dish.enable_hint = false
to disable hint.
- Return
table{ table {string1, string2}}}
ortable{ table {string1, string2, string3}}}
string1
is the raw string to be put on the command linestring2
is the information you want to show when selecting completionsstring3
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
- 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)
- Stores all environment variables in string
- Return the current path with
$HOME
replaced by~
Return the current path:
- All the parent path will be replaced by its first character
$HOME
is replaced by~
- Add a history
Dish currently does not support scripting.
- Implementing a Job Control Shell
- build-your-own-shell
- Writing Your Own Shell
- Tutorial - Write a Shell in C
- fish-shell
- If you have any questions or suggestions, please submit an issue or email me.
- Email: cao2013zh at 163 dot com
- Any contributions are welcomed, just send a PR.
- Dish is licensed under the Apache-2.0 license