Add wish_append and wish_remaining_chars to Plugins.md

Ceda EI 2020-01-19 16:04:52 +05:30
parent 64bea8743f
commit 5c618b7b17
1 changed files with 24 additions and 1 deletions

@ -15,7 +15,7 @@
+ [Username](plugins/username)
+ [vcs](plugins/vcs)
# How to create new plugin
# How to create a new plugin
> Note: Replace `pluginname` with actual plugin name
@ -26,4 +26,27 @@ Plugins need to be defined in a file named `pluginname.sh`. Plugins are sourced
+ `wish_pluginname_end` - This function should return 0 or 1 if it allows/disallows powerline before it respectively.
+ `wish_pluginname_main` - This function is called every time a prompt is generated. Ensure to run `wish_append bg_color fg_color text` within this function. Although the plugin can override the theme while running `wish_append`, it is not recommended.
Plugins have two functions available:
+ `wish_append`: Appends text to prompt. Plugins need to call this to add text
to prompt in their `main` function. They can call it multiple times (or never)
too.
+ `wish_remaining_chars`: Returns remaining characters in current line.
## `wish_append`
+ Usage: `wish_append bg fg text`
+ Parameters:
- `fg`, `bg`: -1 to reset, 0-255 for terminal color codes. 6 digit hexadecimal
value for true color.
- `text`: Text of the plugin
+ Return value: `None`
## `wish_remaining_chars`
+ Usage: `wish_remaining_chars`
+ Parameters: `None`
+ Return Value: Capture stdout to get the remaining characters available in the
line.
Check [dummy plugin](https://gitlab.com/ceda_ei/wish/blob/master/plugins/dummy.sh).