diff --git a/docs/advanced-config/README.md b/docs/advanced-config/README.md index 061a3233b..52c176eef 100644 --- a/docs/advanced-config/README.md +++ b/docs/advanced-config/README.md @@ -28,7 +28,7 @@ function blastoff(){ starship_precmd_user_func="blastoff" ``` -- To run a custom function right before a command runs, you can use the +- To run a custom function right before a command runs, you can use the [`DEBUG` trap mechanism](https://jichu4n.com/posts/debug-trap-and-prompt_command-in-bash/). However, you **must** trap the DEBUG signal *before* initializing Starship! Starship can preserve the value of the DEBUG trap, but if the trap is overwritten @@ -44,7 +44,7 @@ eval $(starship init bash) ## Change Window Title -Some shell prompts will automatically change the window title for you (e.g. to +Some shell prompts will automatically change the window title for you (e.g. to reflect your working directory). Fish even does it by default. Starship does not do this, but it's fairly straightforward to add this functionality to `bash` or `zsh`. @@ -72,7 +72,7 @@ In `zsh`, add this to the `precmd_functions` array: precmd_functions+=(set_win_title) ``` -If you like the result, add these lines to your shell configuration file +If you like the result, add these lines to your shell configuration file (`~/.bashrc` or `~/.zshrc`) to make it permanent. For example, if you want to display your current directory in your terminal tab title, @@ -92,14 +92,15 @@ Style strings are a list of words, separated by whitespace. The words are not ca - `bold` - `underline` - `dimmed` + - `inverted` - `bg:` - `fg:` - `` - `none` -where `` is a color specifier (discussed below). `fg:` and `` currently do the same thing , though this may change in the future. The order of words in the string does not matter. +where `` is a color specifier (discussed below). `fg:` and `` currently do the same thing, though this may change in the future. `inverted` swaps the background and foreground colors. The order of words in the string does not matter. -The `none` token overrides all other tokens in a string if it is not part of a `bg:` specifier, so that e.g. `fg:red none fg:blue` will still create a string with no styling. `bg:none` sets the background to the default color so `fg:red bg:none` is equivalent to `red` or `fg:red` and `bg:green fg:red bg:none` is also equivalent to `fg:red` or `red`. It may become an error to use `none` in conjunction with other tokens in the future. +The `none` token overrides all other tokens in a string if it is not part of a `bg:` specifier, so that e.g. `fg:red none fg:blue` will still create a string with no styling. `bg:none` sets the background to the default color so `fg:red bg:none` is equivalent to `red` or `fg:red` and `bg:green fg:red bg:none` is also equivalent to `fg:red` or `red`. It may become an error to use `none` in conjunction with other tokens in the future. A color specifier can be one of the following: diff --git a/src/config.rs b/src/config.rs index 2a5163b6e..b76eb22ff 100644 --- a/src/config.rs +++ b/src/config.rs @@ -359,7 +359,8 @@ impl StarshipConfig { - 'underline' - 'bold' - 'italic' - - '' (see the parse_color_string doc for valid color strings) + - 'inverted' + - '' (see the parse_color_string doc for valid color strings) */ pub fn parse_style_string(style_string: &str) -> Option { style_string @@ -383,6 +384,7 @@ pub fn parse_style_string(style_string: &str) -> Option { "bold" => Some(style.bold()), "italic" => Some(style.italic()), "dimmed" => Some(style.dimmed()), + "inverted" => Some(style.reverse()), // When the string is supposed to be a color: // Decide if we yield none, reset background or set color. color_string => { @@ -675,7 +677,7 @@ mod tests { } #[test] - fn table_get_styles_bold_italic_underline_green_dimmy_silly_caps() { + fn table_get_styles_bold_italic_underline_green_dimmed_silly_caps() { let config = Value::from("bOlD ItAlIc uNdErLiNe GrEeN diMMeD"); let mystyle =