From 5c618b7b17048cd1fa632dc3cbc720de33066175 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Sun, 19 Jan 2020 16:04:52 +0530 Subject: [PATCH] Add wish_append and wish_remaining_chars to Plugins.md --- Plugins.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Plugins.md b/Plugins.md index 525ea7c..3e8ebf9 100644 --- a/Plugins.md +++ b/Plugins.md @@ -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).