Skip to content
Jean-Philippe Roemer edited this page Mar 2, 2016 · 6 revisions

##### :construction: This page is deprecated with the release of Fishline v2.0.0 and need to be updated :construction:

Please consider reading the [Naming Convetion](Naming Convention) before making a new segment or a new theme. It's here to make everything more readable and clear for everyone.

Segment Creation

The creation of a segment is easy: it consist in a file placed in segments/ that is named segment_name.fish.

In this file you have to create a function called FLSEG_SEGMENT_NAME with the segment name in UPPERCASE. Note that the FLSEG_ prefix is mandatory to make you segment called by fishline.

This function will be the core of you segment, do what you want here, you might want to call FLINT_CLOSE BG FG to close the previous segment and open your with the right color.

To load you new segment inside your prompt, reload fishline by calling FLINT_RELOAD in your terminal and add you segment name to your prompt as follow:

> FLINT_RELOAD
> set FLINE_PROMPT $FLINE_PROMPT SEGMENT_NAME

You might want to add your own glyph variable or own color variables to it, please add a default color to themes/default.fish when using a FCLR_* value.

See the [Naming Convention](Naming Convention) for more information about segment glyphs/colors/variables.

To debug your segment more easily, you will just need to call FLINT_RELOAD each time you make a change. (Fishline load your segment function during its initialisation, that's why you have to reload it)

Theme Creation

Theme creation is easy, it the next step to customize your prompt. A theme is a file placed wherever you want that is sourced after fishline initalisation.

You can create yours by creating a file and settings the colors you want to the FLCLR_ variables of your segment. It must be a valid fish setcolor value.

You don't have to set all the colors for all the segment, the default theme is here for that.

Example:

# File: lama.sh
set FLCLR_GIT_BG_DIRTY 800
set FLCLR_GIT_FG_DIRTY orange
...

Feel free to create a pull request with your theme, in this case put it inside the themes/ folders before sending it.

Fishline Events

Events are a special part of Fishline, and not something used a lot. It consist in some event based function that set internals to optimize your segment.

In the example of the FLEVENT_GIT it is defined to watch change on the PWD variable and check if you are currently inside a git repository every time PWD is modified. It will then set FLINT_GIT accordingly. It optimize the GIT segment in a way that it will prevent computing when you are outside a git repository.

You can add you own event by creating a file inside the events/ folder and declare it as follow:

function FLEVENT_NAME --on-event ARG
	...
end

# You can call your event in the same file if it need to be done at fishline startup
FLEVENT_NAME

Fishline Internals

  • FLSYM_*: represent all the Powerline glyphs/special characters used by the segments. (Fell free to add more if needed)
  • FLINE_PATH: set by the user, it represent the path of the fishline instalation
  • FLINE_PROMPT: represent all the segment present inside the user prompt
  • FLINT_CLOSE BG FG: close the previous segment and open a new one with the color passed as argument
  • FLINT_BCOLOR: used by FLINT_CLOSE to know the foreground color of the closing glyph of the segment
  • FLINT_STATUS: last user called command return value
  • FLINT_RELOAD: functions that reload fishlne entirely
  • FLINT_GIT: return value of a git ls-files command (this variable is check upon PWD change)
  • FLCLR_*: represent the color set by the theme or the user (during segment creation you might want to add colors for your segment inside themes/default.fish, this file is always loaded during fishline initialisation)