mirror of https://gitlab.com/ceda_ei/wish
Page:
Plugins
4
Plugins
Ceda EI edited this page 2020-01-19 16:04:52 +05:30
Table of Contents
List of plugins
- Battery
- Background Jobs
- Custom Text
- Date
- Exit Code
- Exit Code Smiley
- Hostname
- Newline
- Path
- Python Virtualenv
- Space
- Tmux
- Username
- vcs
How to create a new plugin
Note: Replace
pluginname
with actual plugin name
Plugins need to be defined in a file named pluginname.sh
. Plugins are sourced from $XDG_CONFIG_HOME/wish/plugins
, /usr/share/wish/plugins
and $HOME/.config/wish/plugins
. All keys from config are set as environment variables of the form WISH_PLUGINNAME_KEY
. The following functions need to be defined in pluginname.sh
.
wish_pluginname_set_colors
- This function is called after the theme. This allows the plugin to override the theme or set defaults if the theme has not themed some elements of the plugin. Although plugins are allowed to override themes, it is not recommended.wish_pluginname_start
- This function should return 0 or 1 if it allows/disallows powerline before it respectively.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 runwish_append bg_color fg_color text
within this function. Although the plugin can override the theme while runningwish_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 theirmain
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.