Skip to content

Instantly share code, notes, and snippets.

@agriffis
Last active April 18, 2018 17:59
Show Gist options
  • Save agriffis/a7d395b423b19ac2049b57850f110730 to your computer and use it in GitHub Desktop.
Save agriffis/a7d395b423b19ac2049b57850f110730 to your computer and use it in GitHub Desktop.

Out of the box, the new prompt depends on Nerd Fonts. Personally I'm using "DejaVuSansMono Nerd Font Complete." There are a couple ways around this if you'd rather: use fontconfig to merge Nerd symbols with your preferred font, see here and here; or you can override the various PS1_CHAR_* variables after loading .bashrc.prompt to use symbols already present in your font.

Behind the scenes, the code uses the same essential architecture: there's a scaffolding (ps1_update) and some utility functions (ps1_quote, ps1_color, ps1_segment). The actual content of the prompt is produced by modules such as ps1_mod_cwd and ps1_mod_git. These modules register with the scaffolding by calling ps1_add.

You can add your own micro status modules by calling ps1_micro (rather than calling ps1_segment which appends to the end of the prompt):

ps1_mod_smile() {
  ps1_micro "$(ps1_color bright magenta):-)"
}
ps1_add smile

Modules can be registered to run/appear before/after other modules, instead of needing to register them in the specific order you want them to appear:

ps1_add git before cwd
ps1_add user first

New caching functions: ps1_cache_set and ps1_cache_get rather than setting PS1_CACHE_FOO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment