Package: gowerline
gowerlineBecause Python is hard and I've always wanted to write my segments in Go.What is this ?This is a deamon that generates and returns Powerline segments asdescribed in the docs.
This project has 2 parts:The daemon that runs your go code and exposes an HTTP APIThe powerline compatible code that glues it with thepowerline-daemonQuick installYou can grab the latest version of gowerline by running the following (needs curl, jq, tar and wget)curl -sSfL https://raw.githubusercontent.com/thomas-maurice/gowerline/master/install.sh | bashThen install the latest version of the python extension by runningpip install -U gowerlineHow does it work ?This is a pluggable segment generating system. Essentially a very simple powerline "segment" in the sense
of the python class, will call a Go server that will be in charge of generating the actual segments. It allows you
to generate data that would be too long to generate if it had to be called every time you pop a shell,
for instance do API calls to your favourite stock ticker or for example check the validity of an auth token
every other minute.Available pluginsEvery plugin has aREADME.mdfile at the root of their directory detailing what they do and how they workPlugin namePlugin descriptionBashRenders segments that are the result of bash commands ran on a scheduleFinnhubDisplays financial infos about a stock ticker (or many!) that you are interested inVaultGives you information about your current Hashicorp Vault token (display name, validity TTL & co)ColourenvRenders environment variables in your terminal with different colourschemes depending on values (useful to not wreck production by mistake)NetworkDisplays information about how your network connexion is doingHow does it work (on my system) ?You have two parts to it:The powerline extension, that bridges between poweline and the Go serverThe Go server that will bridge between the python extension and the plugins.Essentially, everytime you open a prompt, Powerline will call the various extensions of the server to
fetch segments to render, it's as simple as this.How do I install it ?$makeinstall# Will install the python extension and the go binary$makeinstall-systemd# Will install the userland systemd service to start the server$makeinstall-full# will do both# this will remove it$makeuninstallYou might also need topip install -r requirements.txtHow do I use it ?Add the segment to powerlineThis will use thetimeplugin. In your powerline theme, add the following:{"function":"gowerline.gowerline.gwl","priority":10,"args":{"function":"time"}}Every plugin exposes one or morefunctionthat you have to reference in your powerline config. This will effectively
be passed down to the Go code, as long as every other variable you add in this JSON.The Gowerline config itself lives in~/.gowerline/server.yamldebug:falselisten:# use port to listen over HTTP, this is# not the recommended, use the socket instead# port: 6666unix:~/.gowerline/server.sockplugins:-name:timeconfig:# no config needed-name:networkconfig:ipService:https://checkip.amazonaws.com/-name:finnhub# toggle to true to actually load the plugindisabled:trueconfig:token:YOUR_FINHUB_TOKENtickers:-CFLT-AAPL-FB-name:vaultconfig:# no config needed-name:colourenvconfig:variables:ENV:-regex:staghighlightGroup:"information:priority"-regex:develhighlightGroup:"information:regular"-regex:prodhighlightGroup:"warning:regular"-name:bashconfig:commands:date:cmd:"date"interval:30highlightGroup:"information:regular"kubeContext:cmd:"kubectlconfigget-contexts--no-headers|grep'*'|awk'{print$3}'"interval:5highlightGroup:"gwl:kube_context"The command lineThegowerlinebinary is also a commandline tool that allows you to interract with the server.
You need to add the binary to your path like so:exportPATH=${PATH}:${HOME}/.gowerline/binYou can list plugins and get help about a specific plugin like so:$ gowerline plugin list
+-----------+--------------------------------+--------------------------------+---------+
|   NAME    |          DESCRIPTION           |             AUTHOR             | VERSION |
+-----------+--------------------------------+--------------------------------+---------+
| bash      | Executes bash commands on      | Thomas Maurice                 | 0.0.1   |
|           | a schedule and returns the     | <thomas@maurice.fr>            |         |
|           | result                         |                                |         |
| colourenv | Displays the content of env    | Thomas Maurice                 | 0.0.1   |
|           | vars with colours depending on | <thomas@maurice.fr>            |         |
|           | matched regexes                |                                |         |
| finnhub   | Returns information about the  | Thomas Maurice                 | 0.0.1   |
|           | stock price of certain tickers | <thomas@maurice.fr>            |         |
| network   | Gather information about your  | Thomas Maurice                 | devel   |
|           | network connectivity           | <thomas@maurice.fr>            |         |
| time      | Shows time, it is a debug      | Thomas Maurice                 | 0.0.1   |
|           | segment                        | <thomas@maurice.fr>            |         |
| vault     | Gathers information about      | Thomas Maurice                 | 0.0.1   |
|           | the current Vault token and    | <thomas@maurice.fr>            |         |
|           | formats the result             |                                |         |
+-----------+--------------------------------+--------------------------------+---------+You can also get help about a specific plugin, it will tell you what functions ship with a plugin and the arguments to include in your powerline json config:./bin/gowerline-v0.0.3-15-2d4a3be-dirty-thomas_linux_amd64 plugin functions bash
+---------------+--------------------------------+----------+----------------------------+
| FUNCTION NAME |          DESCRIPTION           | ARGUMENT |       ARGUMENT HELP        |
+---------------+--------------------------------+----------+----------------------------+
| bash          | Runs bash functions at regular |          |                            |
|               | intervals and displays the     |          |                            |
|               | output                         |          |                            |
|               |                                | cmd      | Name of the command to run |
+---------------+--------------------------------+----------+----------------------------+You can also test what is going to be returned, instead of messing with a cURL command:./bin/gowerline-v0.0.3-15-2d4a3be-dirty-thomas_linux_amd64 plugin run-function bash -a cmd=kubeContext -o json 
[
  {
    "contents": "kubernetes",
    "highlight_groups": [
      "gwl:kube_context",
      "information:regular"
    ]
  }
]How do I extend it ?Go have a look at theexample plugin. It should
be easy to understand. Feel free to copy it in theplugins/directory and fill in the blanks.TheMakefileis designed so that if you runmake pluginsyour new source will be picked up and compiled tobin/plugins/<plugin>The plugins are complied as Go plugins (essentialy.solibraries) that are loaded by the main daemon.