A thin, classy theme composed of a chain of information.
Install with Oh My Fish:
$ omf install chain
- Customizable prompt elements.
- Default prompt elements such as current Git branch and dirty state.
- If the last command fails, the exit code is displayed.
- An abbreviated path.
Your prompt in chain consists of a series of links, with each link displaying a single piece of information. Not all links are always visible and only show up when you need them.
Links are entirely customizable, and it is easy to create and customize your own links.
Chain comes with six default links (in order from left to right):
- Superuser privileges (
⚡
) - Number of running background jobs
- The current working directory
- The current Git branch (
⎇
) - Git working directory dirty (
±
) - Exit status of the last command
Making your own links is as simple as writing a small function. A link is rendered using a link function, which is just a Fish function that outputs two lines: the first line is the color of the link; the second line is the link text. For example, if we wanted a yellow link that showed the current time, we could write a function like this:
function time_link
echo yellow
date '+%H:%M:%S'
end
Now we can add it to the end of our prompt:
chain.push time_link
Your links are saved automatically, so it is not necessary to add chain.push
commands to your configuration. Running the command once is enough.
Chain offers several commands you can use to customize and manipulate your prompt. Here is some brief documentation on what these functions do:
To improve performance, the prompt function is actually generated from the configuration dynamically, or "compiled". Normally this function is called for you when needed.
Resets the prompt to the default set of links.
A neat-looking debug tool that prints out your chain-related configuration, gives a preview of all your enabled links, and dumps the compiled prompt function.
Toggle multi-line prompt display on and off. A multi-line prompt can make more room for typing if you have a lot of links in your prompt chain.
Remove the last link in the prompt chain.
Add a link function to the end of the prompt chain.
Remove the first link in the prompt chain.
Add a link function to the beginning of the prompt chain.
Chain uses several global variables to customize the prompt appearance. The most important one is $chain_links
: a list of function names that print out a single link in the prompt.
The glyphs used in the default links can be customized using global variables. Here is a list of glyph-related variables:
$chain_prompt_glyph
: The arrow character at the end of the chain, right before the text input.$chain_git_branch_glyph
: Glyph to indicate the Git branch.$chain_git_dirty_glyph
: Glyph to indicate that the working branch has uncommitted changes.$chain_su_glyph
: Glyph to indicate that you have superuser privileges.$chain_link_open_glyph
: Glyph before each individual chain link (default<
).$chain_link_close_glyph
: Glyph after each individual chain link (default>
).
MIT © coderstephen et al