diff --git a/Makefile b/Makefile index fdac496..f5acd64 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ LP ?= /home/nojhan/code/liquidprompt HEIGHT := 450 -THEME := dotmatrix dotmatrix.theme +THEME := jolly jolly.theme ALL := $(addprefix screenshots/,variant-chevron.png variant-round.png variant-slant.png variant-text.png variant-chevron_colors-cyan-magenta.png variant-chevron_colors-green-red.png variant-chevron_colors-high-contrast.png) diff --git a/README.md b/README.md index c03c422..447d6f2 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,22 @@ -DotMatrix — A Liquid Prompt Theme +Jolly — A Liquid Prompt Theme ================================= -DotMatrix is a theme for [Liquid Prompt](https://github.com/nojhan/liquidprompt). +Jolly is a theme for [Liquid Prompt](https://github.com/nojhan/liquidprompt). It is an original prompt design, very carefully designed, that will completely changes the way you imagine the prompt. It is focused on *improving the user experience*, -by vastly improving the ability of the user to immediatly spot +by vastly improving the ability of the user to immediately spot what she should do following her system's state changes. Has such, you may find it a little bit disconcerting at first. But we believe that the advantages of this design makes it worth the effort. +![A ship with black sails, three of which are printed with the symbols "~", "$", and ">"; going out of a circling boat wheel with sun rays in her back; and navigating a blue wave with froth going over a banner that reads "Liquid Prompt". A large black flag is attached to the front shroud, showing a skull and two crossed bones, on top of a legend reading "jolly roger".](docs/jolly_emblem.svg) + + Preview ------- @@ -21,7 +24,7 @@ Using the (recommended) "chevron" preset: ![](screenshots/variant-chevron.png) -The DotMatrix theme also comes as several variants, changing the shape of the segments separators, +The Jolly theme also comes as several variants, changing the shape of the segments separators, like the "slant" variant: ![](screenshots/variant-slant.png) @@ -32,7 +35,7 @@ Design ### Rationale -The DotMatrix theme use a couple of design principles: +The Jolly theme use a couple of design principles: * It is accessible to colorblind people, hence it uses: * only four colors: dark grey, white, blue and yellow (different color pairs are available as presets for people having blue-yellow colorblindess). @@ -60,7 +63,7 @@ The prompt itself is designed in three lines: ### Example For instance, in the following prompt, you can see that the user is in a Git repository and has some action waiting to be done: -- the rightmost blue "≠" indicates that there are some modifications waiting to be commited (hence the directional hint, from a diff to the branch). +- the rightmost blue "≠" indicates that there are some modifications waiting to be committed (hence the directional hint, from a diff to the branch). - the leftmost blue segment indicates that there are some commits that may be pushed to the remote (hence the directional hint, from the branch to the VCS symbol). ![](screenshots/variant-chevron.png) @@ -73,18 +76,18 @@ for the default login user ("", a figure), on localhost ("", an island), i ### Full description -The following diagram shows almost all the possible states of a DotMatrix Liquid Prompt +The following diagram shows almost all the possible states of a Jolly Liquid Prompt -![](liquidprompt_dotmatrix_design.png) +![](liquidprompt_jolly_design.png) -The diagram is available [in a vector format](liquidprompt_dotmatrix_design.svg) (note: you need a browser/viewer configured to use a [nerd-font](https://www.nerdfonts.com) to see it correctly). +The diagram is available [in a vector format](liquidprompt_jolly_design.svg) (note: you need a browser/viewer configured to use a [nerd-font](https://www.nerdfonts.com) to see it correctly). Setup ----- -To actually use the DotMatrix theme, you need to add a few configuration commands to the script that loads Liquid Prompt. +To actually use the Jolly theme, you need to add a few configuration commands to the script that loads Liquid Prompt. For example: ```sh @@ -92,14 +95,14 @@ For example: # Load Liquid Prompt. source ~/liquidprompt/liquidprompt # Configure the desired variant (or colors, etc.). - source ~/lp-dotmatrix/presets/variant-chevron.conf + source ~/lp-jolly/presets/variant-chevron.conf # Load the theme. - source ~/lp-dotmatrix/dotmatrix.theme && lp_theme dotmatrix + source ~/lp-jolly/jolly.theme && lp_theme jolly ``` -NOTE: The recommended segment markers (the "chevron" variant) uses characters in the private section of unicode +NOTE: The recommended segment markers (the "chevron" variant) uses characters in the private section of Unicode that are defined by the "Nerd-fonts" project. -You will either need a compatible font, or use a variant that does not need them, like "text" and "dotmatrix". +You will either need a compatible font, or use a variant that does not need them, like "text" and "jolly". See the [Nerd-fonts Fonts installation docs](https://www.nerdfonts.com) for help on installing this kind of fonts. @@ -129,7 +132,7 @@ Variants needing a Nerd-fonts font: Variants available with a regular font: -- "dotmatrix" (the default): +- "jolly" (the default): ![](screenshots/variant-dots.png) @@ -143,14 +146,12 @@ Configuration ### Liquid Prompt Configuration -The DotMatrix theme honors Liquid Prompt configuration options, +The Jolly theme honors Liquid Prompt configuration options, except for the ones defining colors, specific marks and disabling some features. The following options are honored: - [`LP_ENABLE_PERM`](https://liquidprompt.readthedocs.io/en/stable/config.html#LP_ENABLE_PERM), -- [`LP_ENABLE_VCS_DIFFSTATS`](https://liquidprompt.readthedocs.io/en/stable/config.html#LP_ENABLE_VCS_DIFFSTATS), -- [`LP_ENABLE_UNCOMMITED`](https://liquidprompt.readthedocs.io/en/stable/config.html#LP_ENABLE_UNCOMMITED), - [`LP_MARK_BATTERY`](https://liquidprompt.readthedocs.io/en/stable/config.html#LP_MARK_BATTERY), - [`LP_MARK_LOAD`](https://liquidprompt.readthedocs.io/en/stable/config.html#LP_MARK_LOAD), - [`LP_MARK_TEMP`](https://liquidprompt.readthedocs.io/en/stable/config.html#LP_MARK_TEMP), @@ -173,13 +174,13 @@ Note: the order in which you load the presets may be important. When changing the colors of the first line, presets needs to be loaded from your shell configuration and not just sourced in the prompt. -A first set is are called "variants" and mainly change the segment joints, +A first set is called "variants" and mainly change the segment joints, but can also impact the icons on some variants: -- `source presets/variant-chevron.conf" (the *recommended*, need a Nerd-fonts font), -- `source presets/variant-slant.conf" (need a Nerd-fonts font), -- `source presets/variant-round.conf" (need a Nerd-fonts font), -- `source presets/variant-text.conf" (the one that works anywhere). +- `source presets/variant-chevron.conf` (the *recommended*, need a Nerd-fonts font), +- `source presets/variant-slant.conf` (need a Nerd-fonts font), +- `source presets/variant-round.conf` (need a Nerd-fonts font), +- `source presets/variant-text.conf` (the one that works anywhere). A second set changes the colors: @@ -190,7 +191,7 @@ A second set changes the colors: #### High-level -**DOTMATRIX_SPACED** *boolean = 1* +**JOLLY_SPACED** *boolean = 1* If set to false, this flag will configure a compact prompt, showing segments without extra spaces around their joints. @@ -198,85 +199,85 @@ showing segments without extra spaces around their joints. #### Specific features -**DOTMATRIX_VCS_AHEAD_THRESHOLD** *integer = 5* +**JOLLY_VCS_AHEAD_THRESHOLD** *integer = 5* Number of unpushed local commits above which the prompt should use the warning color to display the "push" section. -**DOTMATRIX_VCS_BEHIND_THRESHOLD** *integer = 5* +**JOLLY_VCS_BEHIND_THRESHOLD** *integer = 5* Number of unpulled remote commits above which the prompt should use the warning color to display the "pull" section. -**DOTMATRIX_VCS_DIFF_THRESHOLD** *integer = 300* +**JOLLY_VCS_DIFF_THRESHOLD** *integer = 300* Number of modified lines above which the prompt should use the warning color to display the "commit" section. -**DOTMATRIX_VCS_REMOTE_ORIGIN** *string* = "🖈" +**JOLLY_VCS_REMOTE_ORIGIN** *string* = "🖈" String used as a shorten VCS remote name, if it is "origin". -**DOTMATRIX_DETACHED_THRESHOLD** *integer = 3* +**JOLLY_DETACHED_THRESHOLD** *integer = 3* Number of detached jobs above which the prompt should use the warning color. -**DOTMATRIX_RUNNING_THRESHOLD** *integer = 3* +**JOLLY_RUNNING_THRESHOLD** *integer = 3* Number of running jobs above which the prompt should use the warning color. -**DOTMATRIX_STOPPED_THRESHOLD** *integer = 3* +**JOLLY_STOPPED_THRESHOLD** *integer = 3* Number of stopped jobs above which the prompt should use the warning color. -**DOTMATRIX_BATTERY_THRESHOLD** *integer = $((LP_BATTERY_THRESHOLD/2))* +**JOLLY_BATTERY_THRESHOLD** *integer = $((LP_BATTERY_THRESHOLD/2))* Percentage below which the prompt should use the warning color. -**DOTMATRIX_TEMP_THRESHOLD** *integer = $((LP_TEMP_THRESHOLD*2))* +**JOLLY_TEMP_THRESHOLD** *integer = $((LP_TEMP_THRESHOLD*2))* Temperature above which the prompt should use the warning color. -**DOTMATRIX_LOAD_THRESHOLD** *integer = $((_LP_LOAD_THRESHOLD+(_LP_LOAD_CAP-_LP_LOAD_THRESHOLD)/2))* +**JOLLY_LOAD_THRESHOLD** *integer = $((_LP_LOAD_THRESHOLD+(_LP_LOAD_CAP-_LP_LOAD_THRESHOLD)/2))* Load percentage above which the prompt should use the warning color. -**DOTMATRIX_ENABLE_HISTORY** *boolean = 1* +**JOLLY_ENABLE_HISTORY** *boolean = 1* Enable the history sections displayed on the right side of the middle line. -**DOTMATRIX_HISTORY_MOST_BACK** *integer = 100* +**JOLLY_HISTORY_MOST_BACK** *integer = 100* Number of the last history events to take into account when looking for the most used command. -**DOTMATRIX_HISTORY_LAST_LEN** *integer = $((COLUMNS/4))* +**JOLLY_HISTORY_LAST_LEN** *integer = $((COLUMNS/4))* -Maximum length of the *last* command used (counting the `DOTMATRIX_HISTORY_LAST_LEN_MARK` length). +Maximum length of the *last* command used (counting the `JOLLY_HISTORY_LAST_LEN_MARK` length). -**DOTMATRIX_HISTORY_LAST_LEN_MARK** *integer = "[…]"* +**JOLLY_HISTORY_LAST_LEN_MARK** *integer = "[…]"* Mark to display when the last command string is shortened. -**DOTMATRIX_ENABLE_SHELL** *boolean = 0* +**JOLLY_ENABLE_SHELL** *boolean = 0* Display the current shell in the top-right section. -**DOTMATRIX_SHELL_ZSH** *string = "z"* +**JOLLY_SHELL_ZSH** *string = "z"* The mark indicating a *zsh* shell. -**DOTMATRIX_SHELL_BASH** *string = "b"* +**JOLLY_SHELL_BASH** *string = "b"* The mark indicating a *bash* shell. @@ -285,72 +286,72 @@ The mark indicating a *bash* shell. The following options configure some marks that will be used across all variants of the theme. -**DOTMATRIX_DISPLAY_TEXT** *string = "T"* +**JOLLY_DISPLAY_TEXT** *string = "T"* The marker used to indicates that the shell is in text mode, i.e. that does not have a graphical display (more rigorously: there is no X11 `DISPLAY` environment variable). -**DOTMATRIX_DISPLAY_X11** *string = "X"* +**JOLLY_DISPLAY_X11** *string = "X"* The marker used to indicates that the shell does have access to a graphical server (more rigorously: there is a X11 `DISPLAY` environment variable). -**DOTMATRIX_HOST_LOCAL** *string = "⌂"* +**JOLLY_HOST_LOCAL** *string = "⌂"* The marker used to indicate that the hostname is `localhost`. -**DOTMATRIX_USER_LOCAL** *string = "♟"* +**JOLLY_USER_LOCAL** *string = "♟"* The marker used to indicate that the user is the same than the login one. -**DOTMATRIX_MARK_STASH** *string = "✝"* +**JOLLY_MARK_STASH** *string = "✝"* The marker used to indicate that the VCS stash is not empty. -**DOTMATRIX_MARK_UNTRACKED** *string = "?"* +**JOLLY_MARK_UNTRACKED** *string = "?"* The marker used to indicate that there are some files that are untracked by the VCS in the current repository. -**DOTMATRIX_DIFF** *string = "≠"* +**JOLLY_DIFF** *string = "≠"* The marker used to indicate that there is some change in the VCS state (either changes needed to be committed, or commits needed to be pushed). -**DOTMATRIX_VCS** *string = "╟┘"* +**JOLLY_VCS** *string = "╟┘"* The marker used to indicate that there is a VCS involved in the current directory. -**DOTMATRIX_MARK** *string = "⯀"* +**JOLLY_MARK** *string = "⯀"* The actual prompt marker, right where the user type text. -**DOTMATRIX_MARK_SUDO** *string = "⋮"* +**JOLLY_MARK_SUDO** *string = "⋮"* An additional character displayed before the last prompt mark when the user has sudo rights. -**DOTMATRIX_ENABLE_GRADIENT_LINE** *boolean = 0* +**JOLLY_ENABLE_GRADIENT_LINE** *boolean = 0* If set to 0 (the default), will draw the line of the middle section -as a sequence of `DOTMATRIX_LINE` characters, -using the `DOTMATRIX_COLOR_LINE` color. +as a sequence of `JOLLY_LINE` characters, +using the `JOLLY_COLOR_LINE` color. If set to 1, will draw the same line with a gradient of color -interpolated from `DOTMATRIX_COLOR_LINE_START` -to `DOTMATRIX_COLOR_LINE_END`. +interpolated from `JOLLY_COLOR_LINE_START` +to `JOLLY_COLOR_LINE_END`. -**DOTMATRIX_MARK_ERROR** *string = " "* +**JOLLY_MARK_ERROR** *string = " "* Icon displayed in front of the last exit error code. @@ -360,48 +361,48 @@ Icon displayed in front of the last exit error code. These options are the one used to actually define the theme variants. You may overcome them with your own configuration. -**DOTMATRIX_LINE** *string = "━"* +**JOLLY_LINE** *string = "━"* The character used to draw the middle line. -**DOTMATRIX_PLUG** *string = "▛"* +**JOLLY_PLUG** *string = "▛"* The character for joined segments limits. -**DOTMATRIX_SOFT** *string = "╱"* +**JOLLY_SOFT** *string = "╱"* The character for "soft" separation (e.g. path elements, branch details, jobs, etc.) -**DOTMATRIX_MEAN** *string = "▞"* +**JOLLY_MEAN** *string = "▞"* The character for "mean" separation (used when two segments of the same color are joint). -**DOTMATRIX_LINK** *array = ("▙" " " "▜")* +**JOLLY_LINK** *array = ("▙" " " "▜")* Characters used for showing a small gap. -**DOTMATRIX_OPEN** *array = ("▙" " ▚ " "▜")* +**JOLLY_OPEN** *array = ("▙" " ▚ " "▜")* Characters used for showing a large gap. -**DOTMATRIX_DANG** *array = ("▙" " □ " "▜")* +**JOLLY_DANG** *array = ("▙" " □ " "▜")* Characters used for showing a very lareg gap (i.e. a dangerous state). -**DOTMATRIX_ENDS** *array = ("▛▞▗ ▝" "▖ ▘▞▟")* +**JOLLY_ENDS** *array = ("▛▞▗ ▝" "▖ ▘▞▟")* Characters marking the ends of the right and left parts of the first line. -**DOTMATRIX_ITEMS** *array = ("┫" "┃" "┣")* +**JOLLY_ITEMS** *array = ("┫" "┃" "┣")* Characters used to separate keywords in the middle line. The middle character separates keywords of the same type (e.g. every Software Collection). @@ -411,27 +412,27 @@ The middle character separates keywords of the same type (e.g. every Software Co You may overcome the spacing details with these options. -**DOTMATRIX_SPACE_VOID** *string = " "* +**JOLLY_SPACE_VOID** *string = " "* Spacing character around segments joints marker. -**DOTMATRIX_SPACE_PATH** *string = " "* +**JOLLY_SPACE_PATH** *string = " "* Spacing character specifically for the "current path" section. -**DOTMATRIX_SPACE_FIELD** *string = ""* +**JOLLY_SPACE_FIELD** *string = ""* Spacing character around the content of the segments themselves. -**DOTMATRIX_SPACE_LINE** *string = " "* +**JOLLY_SPACE_LINE** *string = " "* Spacing character around the keywords of the middle line. -**DOTMATRIX_SPACE_FILL** *string = "█"* +**JOLLY_SPACE_FILL** *string = "█"* Spacing character for filled sections. You probably don't want to touch this. @@ -440,91 +441,94 @@ You probably don't want to touch this. #### Colors -**DOTMATRIX_COLOR_DARK** *array = (252 239 0 0 15 0)* +**JOLLY_COLOR_DARK** *array = (252 239 0 0 15 0)* The color of dark segments. -**DOTMATRIX_COLOR_LITE** *array = (239 252 0 0 0 15)* +**JOLLY_COLOR_LITE** *array = (239 252 0 0 0 15)* The color of light segments. -**DOTMATRIX_COLOR_GLOW** *array = ( 0 252 1 0 0 15)* +**JOLLY_COLOR_GLOW** *array = ( 0 252 1 0 0 15)* The color for bright elements. -**DOTMATRIX_COLOR_NOTE** *array = ( 15 33 0 0 15 12)* +**JOLLY_COLOR_NOTE** *array = ( 15 33 0 0 15 12)* The color for notable elements. -**DOTMATRIX_COLOR_WARN** *array = (196 220 1 0 0 11)* +**JOLLY_COLOR_WARN** *array = (196 220 1 0 0 11)* The color for elements related to a warning. -**DOTMATRIX_COLOR_FAIR** *array = ( 0 244 0 0 0 8)* +**JOLLY_COLOR_FAIR** *array = ( 0 244 0 0 0 8)* The color for elements that are not very important. -**DOTMATRIX_COLOR_PATH_SHORT** *array = (252 239 0 0 0 15)* +**JOLLY_COLOR_PATH_SHORT** *array = (252 239 0 0 0 15)* The color of the shorten path marker. -**DOTMATRIX_COLOR_PATH_VCS** *array = (252 239 0 1 0 15)* +**JOLLY_COLOR_PATH_VCS** *array = (252 239 0 1 0 15)* The color of the VCS repository in the path. -**DOTMATRIX_COLOR_PATH_LAST** *array = (15 239 1 0 0 15)* +**JOLLY_COLOR_PATH_LAST** *array = (15 239 1 0 0 15)* The color of the current directory. -**DOTMATRIX_COLOR_LINE** *array = (244 -1 0 0 15 -1)* +**JOLLY_COLOR_LINE** *array = (244 -1 0 0 15 -1)* The color of the middle line. -**DOTMATRIX_COLOR_MARK** *array = (15 -1 0 0 15 -1)* +**JOLLY_COLOR_MARK** *array = (15 -1 0 0 15 -1)* The color of the actual prompt mark. -**DOTMATRIX_COLOR_SEP_DARK** *array = ( 0 -2 0 0 0 -2)* +**JOLLY_COLOR_SEP_DARK** *array = ( 0 -2 0 0 0 -2)* The color for dark separators. -**DOTMATRIX_COLOR_SEP_FAIR** *array = (244 -2 0 0 0 -2)* +**JOLLY_COLOR_SEP_FAIR** *array = (244 -2 0 0 0 -2)* The color for fair separators. -**DOTMATRIX_COLOR_SEP_LITE** *array = ( 15 -2 0 0 15 -2)* +**JOLLY_COLOR_SEP_LITE** *array = ( 15 -2 0 0 15 -2)* The color for light separators. -**DOTMATRIX_COLOR_LINE_START** *array = (255 -1 1 0 15 -1)* +**JOLLY_COLOR_LINE_START** *array = (255 -1 1 0 15 -1)* The color starting the gradient of the line of the middle section. Default is white. -Valus being linearly interpolated up to `DOTMATRIX_COLOR_LINE_END`, +Valus being linearly interpolated up to `JOLLY_COLOR_LINE_END`, + it is recommended to stick to aligned ANSI values (i.e. greys) -**DOTMATRIX_COLOR_LINE_END** *array = (232 -1 1 0 15 -1)* +**JOLLY_COLOR_LINE_END** *array = (232 -1 1 0 15 -1)* The color ending the gradient of the line of the middle section. Default is black. -Valus being linearly interpolated from `DOTMATRIX_COLOR_LINE_START`, + +Valus being linearly interpolated from `JOLLY_COLOR_LINE_START`, + it is recommended to stick to aligned ANSI values (i.e. greys). diff --git a/docs/README.md b/docs/README.md index dc85a68..65b50e3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,8 +1,6 @@ # Introduction - - This article is made of two main sections: generic design principles, and Jolly's design principles. @@ -15,8 +13,8 @@ The Jolly's design principles are more or less specific to the Jolly theme. ## What is a Prompt? -There are two kind of computer scientists: those who use the command line, -and those who are retired. Even developers who embrace highly integrated development interfaces have some kind of terminal available in some panel of their IDE. +There are two kind of computer scientists: those who use the command line, and those who are retired. +Even developers who embrace highly integrated development interfaces have some kind of terminal available in some panel of their IDE. Like it or not, the shell is a core part of everyday life for most of the people expecting their computer to work for them. Now the shell actually has access to a lot of information about the computer. @@ -29,7 +27,7 @@ The prompt is this string of characters displayed right in front of the line whe In the most common default configuration, it displays only three pieces of information: the user, the hostname, and the path —`user@hostname:path $ `. -But it can display more! And this is the objective of prompt systems. +But it can display more! And this is the objective of *prompt systems*. Those "prompts" (to be short) actually add a lot of information to this area of the command line. For example, the most common feature is to display the state of the Git repository the user is in. @@ -89,7 +87,7 @@ be obvious to the user, depending on their location on the screen and/or their s Section styling should not overflow on neighbor sections. For instance, given that the terminal is organized as a grid of characters, -the background of two close character will blend. +the background of two close (horizontally or vertically) characters will blend. Therefore, one should maintain a certain degree of contrast between sections that are touching each other but have a different semantics. @@ -125,9 +123,6 @@ always be considered important, as they may drastically alter the workflow of th > while the others are in background-colored sections. -## Seamless - - ## Scoped States that are measured and not directly changed by the user should be hidden by default. @@ -135,6 +130,7 @@ Counters that can fall down to zero should be hidden by default. > In Jolly, *sensors* are hidden by default, while *situation* and *location* > information are always shown, even if set to the default state. +> However, the default states are represented in the smallest possible way, like a single icon. ## Measured @@ -150,23 +146,116 @@ States that rarely change or evolve slowly are less important. ## Configurable -Each aspect of theming should have a related configurable variable. +Each aspect of theming should have a related configuration variable. + + +## More details + +If you want to know more, check our +[opinionated prompt systems comparison](https://github.com/liquidprompt/liquidprompt/wiki/Why) +that goes into more details and give examples across various other prompt systems. # Jolly's Design Principles ## Stability -## Proximity +Essential information should ideally be located at the same location on screen, +whatever the displayed states. +New information being shown after a predictable state change should not +change too much the location of information previously displayed. + +> Using four sections allows Jolly to drastically improve the stability of the prompt, +> as opposed to a prompt on a single line. +> The less stable section is the VCS one, which often changes after each command when the user is working on their repository. +> Sections are thus organized from left to right, in decreasing order of stability. +> Jolly always displays important segments, even in their default state, so that they are always located where the user expect them to be. + +![](../screenshots/variant-chevron.png) + ## Sectioning -## Accessibility +The prompts having issued the previous commands should be easy to find while the user is scrolling up the terminal. + +> Jolly uses both background-colored sections that are always displayed and a line traversing the whole terminal to separate all command outputs in sections. +> The graphical design of the prompt itself is quite rare in classical commands outputs, making it easy to spot. +> Finding the command that issued the output is as easy as finding the horizontal line. + + +## Proximity + +The more important and/or the more frequently updated information should be displayed the closer to where the user is looking: the prompt cursor. +Related information should be displayed close to each other, especially if there is some semantic meaning linking them. + +If the information is to be displayed far away, a small segment may be used to recall the user that they should look elswhere. + +> In Jolly, the path (one of the —if not *the*— most important information) usually appears on top of the prompt's cursor location. +> Admin privileges is shown on the prompt's mark, right next to the prompt's cursor. +> VCS information is also next to the input area. +> +> The location at the end of the path can display some right-pointing arrows, recalling the user to look at the sensors section, if there are many information displayed there. + + +## Segments + +To implement the *accentuated* principle, Jolly uses background-colored segments of information. +To ease the visual browsing of those segments, it uses the visual separators introduced by the *Powerline* project. + +> While Jolly can theoretically use many of the "powerline" characters as separators, it recommends using the "arrow" one, which fits better the *semantic sequence* principle. + +![](../screenshots/variant-round.png) -## Semantic Spaces ## Semantic Sequences +Segments are ordered in sequences that have a meaning. +For instance from the more generic to the more specific, from a natural order of action, or from an architecture hierarchy. + +> The first line of Jolly display the classical how-who-where sequence. +> The VCS section displays elements from the more remote to the more local. +> Spaced reverse arrows in the VCS sections actually show the direction of the expected action +> (e.g. "to be pushed" = local-to-remote = right-to-left). + +![](../screenshots/git_commits.png) + + +## Semantic Spaces + +Jolly makes use of negative spaces between segments to convey information. +This allows for a compact display, and avoid cluttering the screen with icons. + +When displaying something with a space, the direction of the segments are reversed, making them more easy to spot, at no cost. + +It is possible to insert a separator character within a space, to emphasize its importance. + +Spaces are generally used to mean some kind of "disconnected" state. + +> Jolly spaces comes in three levels: simple space (no inserted character), light space (light arrow inserted in the space) and strong space (heavy, colored arrow). +> Jolly uses spaces to indicate the type of network connection (there is no "direct" connection), the fact that the user does not have writing rights (they are "disconnected" from the directory), or the fact that a state has diverged between local and remote. + + +## Semantic Accessibile Colors + +To avoid colorblindness issues, Jolly relies on as few colors as possible, and tries to maximize the contrast between segments. + +The basic display is built of alternating black and white segments, which should be readable on both dark and light terminal backgrounds. + +Important information may be displayed using two other colors: one for information that should be noticed, and one for warnings and errors. + +> Jolly allows the user to select whatever pair of colors fits their colorblindness issues, and comes with several presets. +> Its default is set to blue/yellow, following the most classical recommendation to bypass the most common colorblindness issues. +> The basic segments use tones of dark and light greys with AAA contrast between them, appearing as black and white on many classical terminal backgrounds. + +![](../screenshots/variant-chevron_colors-cyan-magenta.png) + + ## Semantic Thresholds +Qantitative measurements (number of something, sensors, etc.) may be displayed in three states, each of which is associated with a semantic color: +1. below lower threshold: black or white, +2. between lower and higher threshold: *note* color (blue, by default), +3. above higher threshold: *warning* color (yellow, by default). + +> For instance, the number of commits to be pushed, or the number of modified lines in the VCS section are all displayed with this semantics. diff --git a/docs/jolly_emblem.svg b/docs/jolly_emblem.svg new file mode 100644 index 0000000..3ecd7ff --- /dev/null +++ b/docs/jolly_emblem.svg @@ -0,0 +1,2761 @@ + + + +Liquid Prompt — Jolly Roger Emblem + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + nojhan, dolmen, Rycieos & co~ https://github.com/ liquidprompt/liquidprompt + + + Liquid Prompt — Jolly Roger Emblem2024-04-01nojhanLiquid PromptBashZshAGPL~$>Jolly Rogeren_USA ship with black sails, three of which are printed with the symbols "~", "$", and ">"; going out of a circling boat wheel with sun rays in her back; and navigating a blue wave with froth going over a banner that reads "Liquid Prompt". A large black flag is attached to the front shroud, showing a skull and two crossed bones, on top of a legend reading "jolly roger".Mariana Ruiz "LadyofHats " Villarreal diff --git a/liquidprompt_dotmatrix_design.odt b/docs/liquidprompt_jolly_design.odt similarity index 100% rename from liquidprompt_dotmatrix_design.odt rename to docs/liquidprompt_jolly_design.odt diff --git a/liquidprompt_dotmatrix_design.svg b/docs/liquidprompt_jolly_design.svg similarity index 99% rename from liquidprompt_dotmatrix_design.svg rename to docs/liquidprompt_jolly_design.svg index 5afd105..58190f3 100644 --- a/liquidprompt_dotmatrix_design.svg +++ b/docs/liquidprompt_jolly_design.svg @@ -8,9 +8,9 @@ width="793.66663" height="725.40625" viewBox="0 0 793.66663 725.40628" - sodipodi:docname="liquidprompt_dotmatrix_design.svg" + sodipodi:docname="liquidprompt_jolly_design.svg" inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)" - inkscape:export-filename="/home/nojhan/code/lp-dotmatrix/liquidprompt_dotmatrix_design.png" + inkscape:export-filename="liquidprompt_jolly_design.png" inkscape:export-xdpi="123.86" inkscape:export-ydpi="123.86" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" @@ -41,7 +41,7 @@ inkscape:current-layer="g12" />dotmatrix jolly dotmatrix jolly dotmatrixjolly= 2.2.0, but you have version $lp_join, some features will not work and the prompt may crash.\n" - fi - - LP_ENABLE_VCS_DIFFSTATS=${LP_ENABLE_VCS_DIFFSTATS:-1} - _LP_LOAD_THRESHOLD=${_LP_LOAD_THRESHOLD:-80} - _LP_LOAD_CAP=${_LP_LOAD_CAP:-100} - - DOTMATRIX_DISPLAY_TEXT=${DOTMATRIX_DISPLAY_TEXT:-"T"} - DOTMATRIX_DISPLAY_X11=${DOTMATRIX_DISPLAY_X11:-"X"} - DOTMATRIX_HOST_LOCAL=${DOTMATRIX_HOST_LOCAL:-"⌂"} - DOTMATRIX_MARK_STASH=${DOTMATRIX_MARK_STASH:-"✝"} - DOTMATRIX_MARK_UNTRACKED=${DOTMATRIX_MARK_UNTRACKED:-"?"} # ⛶ - DOTMATRIX_DIFF=${DOTMATRIX_DIFF:-"≠"} - - DOTMATRIX_ENABLE_GRADIENT_LINE=${DOTMATRIX_ENABLE_GRADIENT_LINE:-0} - DOTMATRIX_ENABLE_SHELL=${DOTMATRIX_ENABLE_SHELL:-0} - - DOTMATRIX_SHELL_ZSH=${DOTMATRIX_SHELL_ZSH:-"z"} - DOTMATRIX_SHELL_BASH=${DOTMATRIX_SHELL_BASH:-"b"} - - DOTMATRIX_VCS_REMOTE_ORIGIN=${DOTMATRIX_VCS_REMOTE_ORIGIN:-"🖈"} - - DOTMATRIX_ENABLE_HISTORY=${DOTMATRIX_ENABLE_HISTORY:-0} - DOTMATRIX_HISTORY_LAST_LEN=${DOTMATRIX_HISTORY_LAST_LEN:-$((COLUMNS/4))} - DOTMATRIX_HISTORY_LAST_LEN_MARK=${DOTMATRIX_HISTORY_LAST_LEN_MARK:-"[…]"} - DOTMATRIX_HISTORY_MOST_BACK=${DOTMATRIX_HISTORY_MOST_BACK:-100} - - # Thresholds based on 75th quantile for: - # nb of commits in PR on Github and added+removed lines. - # See: https://promyze.com/observations-on-10000-pull-requests-on-github/ - DOTMATRIX_VCS_AHEAD_THRESHOLD=${DOTMATRIX_VCS_AHEAD_THRESHOLD:-5} - DOTMATRIX_VCS_BEHIND_THRESHOLD=${DOTMATRIX_VCS_BEHIND_THRESHOLD:-5} - DOTMATRIX_VCS_DIFF_THRESHOLD=${DOTMATRIX_VCS_DIFF_THRESHOLD:-300} - - DOTMATRIX_DETACHED_THRESHOLD=${DOTMATRIX_DETACHED_THRESHOLD:-3} - DOTMATRIX_RUNNING_THRESHOLD=${DOTMATRIX_RUNNING_THRESHOLD:-3} - DOTMATRIX_STOPPED_THRESHOLD=${DOTMATRIX_STOPPED_THRESHOLD:-3} - - DOTMATRIX_BATTERY_THRESHOLD=${DOTMATRIX_BATTERY_THRESHOLD:-$((LP_BATTERY_THRESHOLD/2))} - DOTMATRIX_RAM_THRESHOLD=${DOTMATRIX_RAM_THRESHOLD:-$((LP_RAM_THRESHOLD/2))} - DOTMATRIX_DISK_THRESHOLD=${DOTMATRIX_DISK_THRESHOLD:-$((LP_DISK_THRESHOLD/2))} - DOTMATRIX_TEMP_THRESHOLD=${DOTMATRIX_TEMP_THRESHOLD:-$((LP_TEMP_THRESHOLD*2))} - # Use prefixed _LP_* variables, which are integers. - DOTMATRIX_LOAD_THRESHOLD=${DOTMATRIX_LOAD_THRESHOLD:-$((_LP_LOAD_THRESHOLD+(_LP_LOAD_CAP-_LP_LOAD_THRESHOLD)/2))} - - DOTMATRIX_MARK_ERROR=${DOTMATRIX_MARK_ERROR:-""} - - # Sets of characters - # Dotmatrix theme - DOTMATRIX_HOST_LOCAL=${DOTMATRIX_HOST_LOCAL:-"⌂"} - DOTMATRIX_USER_LOCAL=${DOTMATRIX_USER_LOCAL:-"♟"} - DOTMATRIX_VCS=${DOTMATRIX_VCS:-"╟┘"} - DOTMATRIX_MARK=${DOTMATRIX_MARK:-"⯀"} - DOTMATRIX_MARK_SUDO=${DOTMATRIX_MARK_SUDO:-"⋮"} - DOTMATRIX_LINE=${DOTMATRIX_LINE:-"━"} - DOTMATRIX_PLUG=${DOTMATRIX_PLUG:-"▛"} - DOTMATRIX_SOFT=${DOTMATRIX_SOFT:-"╱"} - DOTMATRIX_MEAN=${DOTMATRIX_MEAN:-"▞"} - # Separator arrays (left center right) - DOTMATRIX_LINK=( ${DOTMATRIX_LINK[@]+"${DOTMATRIX_LINK[@]}"} ) - [[ ${#DOTMATRIX_LINK[@]} == 0 ]] && DOTMATRIX_LINK=("▙" " " "▜") - DOTMATRIX_LINK_R=( ${DOTMATRIX_LINK_R[@]+"${DOTMATRIX_LINK_R[@]}"} ) - [[ ${#DOTMATRIX_LINK_R[@]} == 0 ]] && DOTMATRIX_LINK_R=("▛" " " "▟") - DOTMATRIX_OPEN=( ${DOTMATRIX_OPEN[@]+"${DOTMATRIX_OPEN[@]}"} ) - [[ ${#DOTMATRIX_OPEN[@]} == 0 ]] && DOTMATRIX_OPEN=("▙" " ▚ " "▜") - DOTMATRIX_DANG=( ${DOTMATRIX_DANG[@]+"${DOTMATRIX_DANG[@]}"} ) - [[ ${#DOTMATRIX_DANG[@]} == 0 ]] && DOTMATRIX_DANG=("▙" " □ " "▜") - DOTMATRIX_ENDS=( ${DOTMATRIX_ENDS[@]+"${DOTMATRIX_ENDS[@]}"} ) - [[ ${#DOTMATRIX_ENDS[@]} == 0 ]] && DOTMATRIX_ENDS=("▛" "▞▗ ▝" "▖ ▘▞▟") - DOTMATRIX_ITEMS=( ${DOTMATRIX_ITEMS[@]+"${DOTMATRIX_ITEMS[@]}"} ) - [[ ${#DOTMATRIX_ITEMS[@]} == 0 ]] && DOTMATRIX_ITEMS=("┫" "┃" "┣") - - DOTMATRIX_SPACED=${DOTMATRIX_SPACED:-1} - - # Number of spaces to add - if [[ ${DOTMATRIX_SPACED} == 0 ]] ; then - DOTMATRIX_SPACE_VOID="" - DOTMATRIX_SPACE_FILL="" - DOTMATRIX_SPACE_PATH=${DOTMATRIX_SPACE_PATH:-""} - DOTMATRIX_SPACE_FIELD=${DOTMATRIX_SPACE_FIELD:-""} - DOTMATRIX_SPACE_LINE=${DOTMATRIX_SPACE_LINE:-""} - - elif [[ ${DOTMATRIX_SPACED} == 1 ]] ; then - DOTMATRIX_SPACE_VOID=" " - DOTMATRIX_SPACE_FILL="█" - DOTMATRIX_SPACE_PATH=${DOTMATRIX_SPACE_PATH:-" "} - DOTMATRIX_SPACE_FIELD=${DOTMATRIX_SPACE_FIELD:-""} - DOTMATRIX_SPACE_LINE=${DOTMATRIX_SPACE_LINE:-" "} - else - local n="${DOTMATRIX_SPACED:-1}" - [[ $n -lt 0 ]] && n=1 - local i - DOTMATRIX_SPACE_VOID="" - DOTMATRIX_SPACE_FILL="" - for ((i=0; i < n; i++)); do - DOTMATRIX_SPACE_VOID+=" " # Regular space - DOTMATRIX_SPACE_FILL+="█" # Inverted space - done - - DOTMATRIX_SPACE_PATH=${DOTMATRIX_SPACE_PATH:-"${DOTMATRIX_SPACE_VOID}"} - DOTMATRIX_SPACE_FIELD=${DOTMATRIX_SPACE_FIELD:-""} - DOTMATRIX_SPACE_LINE=${DOTMATRIX_SPACE_LINE:-""} - fi - - - # Color arrays defaults fg bg b u ffg fbg - DOTMATRIX_COLOR_DARK=( ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} ) - [[ ${#DOTMATRIX_COLOR_DARK[@]} == 0 ]] && DOTMATRIX_COLOR_DARK=(252 239 0 0 15 0) - - DOTMATRIX_COLOR_LITE=( ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} ) - [[ ${#DOTMATRIX_COLOR_LITE[@]} == 0 ]] && DOTMATRIX_COLOR_LITE=(239 252 0 0 0 15) - - DOTMATRIX_COLOR_GLOW=( ${DOTMATRIX_COLOR_GLOW[@]+"${DOTMATRIX_COLOR_GLOW[@]}"} ) - [[ ${#DOTMATRIX_COLOR_GLOW[@]} == 0 ]] && DOTMATRIX_COLOR_GLOW=( 255 239 1 0 0 15) - - DOTMATRIX_COLOR_NOTE=( ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} ) - [[ ${#DOTMATRIX_COLOR_NOTE[@]} == 0 ]] && DOTMATRIX_COLOR_NOTE=( 15 33 0 0 15 12) - - DOTMATRIX_COLOR_WARN=( ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} ) - [[ ${#DOTMATRIX_COLOR_WARN[@]} == 0 ]] && DOTMATRIX_COLOR_WARN=(196 220 1 0 0 11) - - DOTMATRIX_COLOR_FAIR=( ${DOTMATRIX_COLOR_FAIR[@]+"${DOTMATRIX_COLOR_FAIR[@]}"} ) - [[ ${#DOTMATRIX_COLOR_FAIR[@]} == 0 ]] && DOTMATRIX_COLOR_FAIR=( 0 239 1 0 0 8) - - - DOTMATRIX_COLOR_PATH_SHORT=( ${DOTMATRIX_COLOR_PATH_SHORT[@]+"${DOTMATRIX_COLOR_PATH_SHORT[@]}"} ) - [[ ${#DOTMATRIX_COLOR_PATH_SHORT[@]} == 0 ]] && DOTMATRIX_COLOR_PATH_SHORT=(252 239 0 0 0 15) - - DOTMATRIX_COLOR_PATH_VCS=( ${DOTMATRIX_COLOR_PATH_VCS[@]+"${DOTMATRIX_COLOR_PATH_VCS[@]}"} ) - [[ ${#DOTMATRIX_COLOR_PATH_VCS[@]} == 0 ]] && DOTMATRIX_COLOR_PATH_VCS=(252 239 0 1 0 15) - - DOTMATRIX_COLOR_PATH_LAST=( ${DOTMATRIX_COLOR_PATH_LAST[@]+"${DOTMATRIX_COLOR_PATH_LAST[@]}"} ) - [[ ${#DOTMATRIX_COLOR_PATH_LAST[@]} == 0 ]] && DOTMATRIX_COLOR_PATH_LAST=(15 239 1 0 0 15) - - - DOTMATRIX_COLOR_LINE=( ${DOTMATRIX_COLOR_LINE[@]+"${DOTMATRIX_COLOR_LINE[@]}"} ) - [[ ${#DOTMATRIX_COLOR_LINE[@]} == 0 ]] && DOTMATRIX_COLOR_LINE=(244 -1 0 0 15 -1) - - DOTMATRIX_COLOR_LINE_START=( ${DOTMATRIX_COLOR_LINE_START[@]+"${DOTMATRIX_COLOR_LINE_START[@]}"} ) - [[ ${#DOTMATRIX_COLOR_LINE_START[@]} == 0 ]] && DOTMATRIX_COLOR_LINE_START=(255 -1 1 0 15 -1) - - DOTMATRIX_COLOR_LINE_END=( ${DOTMATRIX_COLOR_LINE_END[@]+"${DOTMATRIX_COLOR_LINE_END[@]}"} ) - [[ ${#DOTMATRIX_COLOR_LINE_END[@]} == 0 ]] && DOTMATRIX_COLOR_LINE_END=(232 -1 1 0 15 -1) - - - DOTMATRIX_COLOR_MARK=( ${DOTMATRIX_COLOR_MARK[@]+"${DOTMATRIX_COLOR_MARK[@]}"} ) - [[ ${#DOTMATRIX_COLOR_MARK[@]} == 0 ]] && DOTMATRIX_COLOR_MARK=(15 -1 0 0 15 -1) - - DOTMATRIX_COLOR_SEP_DARK=( ${DOTMATRIX_COLOR_SEP_DARK[@]+"${DOTMATRIX_COLOR_SEP_DARK[@]}"} ) - [[ ${#DOTMATRIX_COLOR_SEP_DARK[@]} == 0 ]] && DOTMATRIX_COLOR_SEP_DARK=( 0 -2 0 0 0 -2) - - DOTMATRIX_COLOR_SEP_FAIR=( ${DOTMATRIX_COLOR_SEP_FAIR[@]+"${DOTMATRIX_COLOR_SEP_FAIR[@]}"} ) - [[ ${#DOTMATRIX_COLOR_SEP_FAIR[@]} == 0 ]] && DOTMATRIX_COLOR_SEP_FAIR=(244 -2 0 0 0 -2) - - DOTMATRIX_COLOR_SEP_LITE=( ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} ) - [[ ${#DOTMATRIX_COLOR_SEP_LITE[@]} == 0 ]] && DOTMATRIX_COLOR_SEP_LITE=( 15 -2 0 0 15 -2) - - # Default line color for unset variables. - LP_COLOR_ENV_VARS_UNSET=${LP_COLOR_ENV_VARS_UNSET:-""} - # Use the background of notes as a foreground for set variables. - lp_terminal_format "${DOTMATRIX_COLOR_NOTE[1]}" - LP_COLOR_ENV_VARS_SET=${LP_COLOR_ENV_VARS_SET:-"$lp_terminal_format"} - - # LP_COLORMAP=( ${LP_COLORMAP[@]+"${LP_COLORMAP[@]}"} ) - # if [[ ${#LP_COLORMAP[@]} == 0 ]]; then - local lp_terminal_format - lp_terminal_format ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - local l1="$lp_terminal_format" - lp_terminal_format ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} - local l2="$lp_terminal_format" - lp_terminal_format ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - local l3="$lp_terminal_format" - LP_COLORMAP=( - "" # l0 - "$l1" - "$l2" - "$l3" - ) - # fi - - __dotmatrix_activate_display - # __dotmatrix_activate_shell - __dotmatrix_activate_connection - __dotmatrix_activate_user - __dotmatrix_activate_multiplexer - __dotmatrix_activate_hostname -} - - -_lp_dotmatrix_theme_directory() { - lp_terminal_format ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - __dotmatrix_directory_FS - __dotmatrix_directory_path -} - - -_lp_dotmatrix_make_header() { - - # Arguments: fg, bg, bold, underline, fallback_fg, fallback_bg - # Color codes can be any integer in 256 XTerm's system colors in [0–255]. - # Special color codes: - # -1 : no color - # -2 : previously set color - # -3 : swap fg and bg - local lp_terminal_format - - #################################################################### - # HEADER (LEFT) - #################################################################### - - _lp_dotmatrix_make_header="" - _lp_dotmatrix_make_header+="${_DOTMATRIX_DISPLAY}" - _lp_dotmatrix_make_header+="${_DOTMATRIX_CONNECTION}" - _lp_dotmatrix_make_header+="${_DOTMATRIX_USER}" - _lp_dotmatrix_make_header+="${_DOTMATRIX_MULTIPLEXER}" - _lp_dotmatrix_make_header+="${_DOTMATRIX_HOSTNAME}" - _lp_dotmatrix_make_header+="${_DOTMATRIX_FS}" - _lp_dotmatrix_make_header+="${_DOTMATRIX_PATH} " - - if _lp_dirstack; then - # Pseudo-recall the path section format. - lp_terminal_format ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _lp_dotmatrix_make_header+="${dotmatrix_sep}" - __dotmatrix_make_field "$lp_dirstack" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _lp_dotmatrix_make_header+="${dotmatrix_field}" - fi -} - -_lp_dotmatrix_make_side() { - - #################################################################### - # HEADER SIDE (RIGHT) - #################################################################### - - local _lp_dotmatrix_has_notes=0 - local _lp_dotmatrix_has_warns=0 - - # DOTMATRIX_COLOR_SEP_FAIR - __dotmatrix_make_sep_side "" - _lp_dotmatrix_make_side="${dotmatrix_sep}" - - # battery / load / temperature - local battery= - if _lp_battery_color ; then - if [[ $lp_battery -le "$DOTMATRIX_BATTERY_THRESHOLD" ]]; then - __dotmatrix_make_field "$lp_battery$_LP_PERCENT" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - battery="${dotmatrix_field}${LP_MARK_BATTERY}" - _lp_dotmatrix_has_warns=$((_lp_dotmatrix_has_warns+1)) - else - __dotmatrix_make_field "$lp_battery$_LP_PERCENT" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - battery="${dotmatrix_field}${LP_MARK_BATTERY}" - _lp_dotmatrix_has_notes=$((_lp_dotmatrix_has_notes+1)) - fi - fi - - local load= - if _lp_load_color ; then - if [[ $lp_load_adjusted -ge "$DOTMATRIX_LOAD_THRESHOLD" ]]; then - __dotmatrix_make_field "$lp_load" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - load="${dotmatrix_field}${LP_MARK_LOAD}" - _lp_dotmatrix_has_warns=$((_lp_dotmatrix_has_warns+1)) - else - __dotmatrix_make_field "$lp_load" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - load="${dotmatrix_field}${LP_MARK_LOAD}" - _lp_dotmatrix_has_notes=$((_lp_dotmatrix_has_notes+1)) - fi - fi - - local ram= - if _lp_ram_color ; then - if [[ $lp_ram_perc -le "$DOTMATRIX_RAM_THRESHOLD" ]]; then - __dotmatrix_make_field "$lp_ram_perc$_LP_PERCENT" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - ram="${dotmatrix_field}${LP_MARK_RAM}" - _lp_dotmatrix_has_warns=$((_lp_dotmatrix_has_warns+1)) - else - __dotmatrix_make_field "$lp_ram_perc$_LP_PERCENT" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - ram="${dotmatrix_field}${LP_MARK_RAM}" - _lp_dotmatrix_has_notes=$((_lp_dotmatrix_has_notes+1)) - fi - fi - - local disk= - if _lp_disk_color ; then - if [[ $lp_disk_perc -le "$DOTMATRIX_DISK_THRESHOLD" ]]; then - __dotmatrix_make_field "$lp_disk_perc$_LP_PERCENT" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - disk="${dotmatrix_field}${LP_MARK_DISK}" - _lp_dotmatrix_has_warns=$((_lp_dotmatrix_has_warns+1)) - else - __dotmatrix_make_field "$lp_disk_perc$_LP_PERCENT" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - disk="${dotmatrix_field}${LP_MARK_DISK}" - _lp_dotmatrix_has_notes=$((_lp_dotmatrix_has_notes+1)) - fi - fi - - local temperature= - if _lp_temperature_color ; then - if [[ $lp_temperature -ge "$DOTMATRIX_TEMP_THRESHOLD" ]]; then - __dotmatrix_make_field "$lp_temperature" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - temperature="${dotmatrix_field}${LP_MARK_TEMP}" - _lp_dotmatrix_has_warns=$((_lp_dotmatrix_has_warns+1)) - else - __dotmatrix_make_field "$lp_temperature" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - temperature="${dotmatrix_field}${LP_MARK_TEMP}" - _lp_dotmatrix_has_notes=$((_lp_dotmatrix_has_notes+1)) - fi - fi - - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_DARK[@]+"${DOTMATRIX_COLOR_SEP_DARK[@]}"} - declare -a blt=($battery $load $ram $disk $temperature) # Unquoted on purpose. - if [[ ${#blt[@]} -gt 0 ]] ; then - _lp_join "$dotmatrix_sep" ${blt[@]} - if [[ -n "$lp_join" ]] ; then - - # Match the side sep - local fg="${DOTMATRIX_COLOR_SEP_FAIR[0]}" - local ffg="${DOTMATRIX_COLOR_SEP_FAIR[4]}" - lp_terminal_format "$fg" -2 0 0 "$ffg" -2 - # No space before sep. - _lp_dotmatrix_make_side+="${lp_terminal_format}${DOTMATRIX_SPACE_VOID}${lp_join}" - - fi - else - lp_terminal_format ${DOTMATRIX_COLOR_FAIR[@]+"${DOTMATRIX_COLOR_FAIR[@]}"} - _lp_dotmatrix_make_side+="${lp_terminal_format}" - fi - - # jobs: detached / running / stopped - - local detached_sessions= - if _lp_detached_sessions ; then - if [[ -n "${lp_detached_sessions}" && "${lp_detached_sessions}" -gt 0 ]] ; then - if [[ "${lp_detached_sessions}" -ge "${DOTMATRIX_DETACHED_THRESHOLD}" ]]; then - __dotmatrix_make_field "${lp_detached_sessions}d" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - detached_sessions="${dotmatrix_field}" - _lp_dotmatrix_has_warns=$((_lp_dotmatrix_has_warns+1)) - else - __dotmatrix_make_field "${lp_detached_sessions}d" ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} - detached_sessions="${dotmatrix_field}" - _lp_dotmatrix_has_notes=$((_lp_dotmatrix_has_notes+1)) - fi - fi - fi - - local running_jobs= - local stopped_jobs= - if _lp_jobcount ; then - if [[ -n "${lp_running_jobs}" && "${lp_running_jobs}" -gt 0 ]] ; then - if [[ "${lp_running_jobs}" -ge "${DOTMATRIX_RUNNING_THRESHOLD}" ]]; then - __dotmatrix_make_field "${lp_running_jobs}&" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - running_jobs="${dotmatrix_field}" - _lp_dotmatrix_has_warns=$((_lp_dotmatrix_has_warns+1)) - else - __dotmatrix_make_field "${lp_running_jobs}&" ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} - running_jobs="${dotmatrix_field}" - _lp_dotmatrix_has_notes=$((_lp_dotmatrix_has_notes+1)) - fi - fi - - if [[ -n "${lp_stopped_jobs}" && "${lp_stopped_jobs}" -gt 0 ]] ; then - if [[ "${lp_stopped_jobs}" -ge "${DOTMATRIX_STOPPED_THRESHOLD}" ]]; then - __dotmatrix_make_field "${lp_stopped_jobs}z" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - stopped_jobs="${dotmatrix_field}" - _lp_dotmatrix_has_warns=$((_lp_dotmatrix_has_warns+1)) - else - __dotmatrix_make_field "${lp_stopped_jobs}z" ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} - stopped_jobs="${dotmatrix_field}" - _lp_dotmatrix_has_notes=$((_lp_dotmatrix_has_notes+1)) - fi - fi - fi - - lp_terminal_format ${DOTMATRIX_COLOR_FAIR[@]+"${DOTMATRIX_COLOR_FAIR[@]}"} - if [[ $_lp_dotmatrix_has_warns -gt 0 ]]; then - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - else - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} - fi - local djc_plug="${dotmatrix_sep}" - - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} - declare -a drs=($detached_sessions $running_jobs $stopped_jobs) # Unquoted on purpose. - if [[ ${#drs[@]} -gt 0 ]] ; then - _lp_join "$dotmatrix_sep" "${drs[@]}" - if [[ -n "$lp_join" ]] ; then - _lp_dotmatrix_make_side+="${djc_plug}${lp_join}" - fi - else - lp_terminal_format ${DOTMATRIX_COLOR_FAIR[@]+"${DOTMATRIX_COLOR_FAIR[@]}"} - _lp_dotmatrix_make_side+="${lp_terminal_format}" - fi - - # Called here for an easy access to the configured color. - if __dotmatrix_activate_shell ; then - _lp_dotmatrix_make_side+="${_DOTMATRIX_SHELL}" - fi - - # clock - if _lp_time ; then - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - _lp_dotmatrix_make_side+="${dotmatrix_sep}" - if _lp_analog_time ; then - __dotmatrix_make_field "$lp_analog_time" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - _lp_dotmatrix_make_side+="$dotmatrix_field" - else - __dotmatrix_make_field "$lp_time" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - _lp_dotmatrix_make_side+="$dotmatrix_field" - fi - fi -} - -_lp_dotmatrix_make_env() { - #################################################################### - # IN LINE - #################################################################### - - local color_line_end="" - if (( LP_ENABLE_SSH_COLORS )); then - local lp_hostname_hash - __lp_hostname_hash - __lp_foreground_color "$(( 1 + lp_hostname_hash % 6 ))" - color_line_end="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}" - fi - lp_terminal_format ${DOTMATRIX_COLOR_LINE[@]+"${DOTMATRIX_COLOR_LINE[@]}"} - color_line_start="$lp_terminal_format" - _lp_dotmatrix_make_env_inline_left="${NO_COL}$LP_PS1_PREFIX${lp_terminal_format}${DOTMATRIX_LINE}" - - # Dev env section. - local ista="$_LP_FIRST_INDEX" - local imid=$((_LP_FIRST_INDEX+1)) - local iend=$((_LP_FIRST_INDEX+2)) - local d="${color_line_start}${DOTMATRIX_ITEMS[ista]}${DOTMATRIX_SPACE_LINE}" - local I="${color_line_start}${DOTMATRIX_SPACE_LINE}${DOTMATRIX_ITEMS[imid]}${DOTMATRIX_SPACE_LINE}" - local b="${color_line_start}${DOTMATRIX_SPACE_LINE}${DOTMATRIX_ITEMS[iend]}${color_line_end}" - if _lp_env_vars "${LP_COLOR_ENV_VARS_SET}" "${LP_COLOR_ENV_VARS_UNSET}"; then - local lp_join - _lp_join "$I" ${lp_env_vars[@]} - _lp_dotmatrix_make_env_inline_left+="$d${lp_join}$b" - fi - if _lp_software_collections ; then - _lp_dotmatrix_make_env_inline_left+="$d${lp_software_collections}$b" - fi - if _lp_python_env ; then - _lp_dotmatrix_make_env_inline_left+="$d${lp_python_env}$b" - fi - if _lp_node_env ; then - _lp_dotmatrix_make_env_inline_left+="$d${lp_node_env}$b" - fi - if _lp_ruby_env ; then - _lp_dotmatrix_make_env_inline_left+="$d${lp_ruby_env}$b" - fi - if _lp_container ; then - _lp_dotmatrix_make_env_inline_left+="$d${lp_container}$b" - fi - if _lp_kubernetes_context ; then - _lp_dotmatrix_make_env_inline_left+="$d${lp_kubernetes_context}$b" - fi - if _lp_terraform_env ; then - _lp_dotmatrix_make_env_inline_left+="$d${lp_terraform_env}$b" - fi - if _lp_aws_profile ; then - _lp_dotmatrix_make_env_inline_left+="$d${lp_aws_profile}$b" - fi - if _lp_cmake ; then - local lp_join - _lp_join "$I" ${lp_cmake_c_compiler} ${lp_cmake_cxx_compiler} ${lp_cmake_generator} ${lp_cmake_buildtype} - _lp_dotmatrix_make_env_inline_left+="$d${lp_join}$b" - fi - if _lp_container; then - _lp_dotmatrix_make_env_inline_left+="$d$lp_container$b" - fi - if _lp_modules; then - _lp_dotmatrix_make_env_inline_left+="$d" - _lp_join "$I" "${lp_modules[@]}" - _lp_dotmatrix_make_env_inline_left+="${lp_join}$b" - fi - - # History section. - local _lp_dotmatrix_make_env_inline_right= - if _lp_os; then - _lp_join "$I" ${lp_os_arch} ${lp_os_family} ${lp_os_kernel} ${lp_os_distrib} ${lp_os_version} - _lp_dotmatrix_make_env_inline_right+="$d${lp_join}$b" - fi - if ((DOTMATRIX_ENABLE_HISTORY)) ; then - local hist_max - hist_max=$((DOTMATRIX_HISTORY_LAST_LEN-${#DOTMATRIX_HISTORY_LAST_LEN_MARK})) - local hist_last - hist_last=$(history | tail -n 1 | cut -d" " -f5-) - if [[ ${#hist_last} -gt $hist_max ]] ; then - if (( _LP_SHELL_zsh )) ; then - hist_last="${hist_last[1,$hist_max]}${DOTMATRIX_HISTORY_LAST_LEN_MARK}" - else # bash - hist_last="${hist_last:0:$hist_max}${DOTMATRIX_HISTORY_LAST_LEN_MARK}" - fi - fi - local hist_most - hist_most=$(history | tail -n "${DOTMATRIX_HISTORY_MOST_BACK}" | awk '{print $4}' | sort | uniq --count | sort --numeric-sort --reverse | head -n 1 | awk '{print $2}') - __lp_escape "$hist_last" - local hlast="$ret" - __lp_escape "$hist_most" - local hmost="$ret" - _lp_dotmatrix_make_env_inline_right="$d${hlast}$I${hmost}$b" - fi -} - -_lp_dotmatrix_make_vcs() { - - _lp_dotmatrix_make_vcs="" - lp_terminal_format ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - - if (( LP_ENABLE_WIFI_STRENGTH )) ; then - if _lp_wifi_signal_strength ; then - lp_terminal_format ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - _lp_dotmatrix_make_vcs+="${lp_terminal_format}${LP_MARK_WIFI}" - else - _lp_dotmatrix_make_vcs+="${lp_terminal_format}${LP_MARK_WIFI}" - fi - else - _lp_dotmatrix_make_vcs+="${lp_terminal_format}·" - fi - - if _lp_http_proxy ; then - __dotmatrix_make_sep_link ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _lp_dotmatrix_make_vcs+="${dotmatrix_sep}" - else - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _lp_dotmatrix_make_vcs+="${dotmatrix_sep}" - fi - - if __dotmatrix_prompt_vcs; then - _lp_dotmatrix_make_vcs+="${_DOTMATRIX_VCS}" - fi -} - -_lp_dotmatrix_make_input() { - #################################################################### - # PROMPT LINE - #################################################################### - _lp_dotmatrix_make_input= - - if _lp_runtime_format ; then - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} - __dotmatrix_make_field "${lp_runtime_format}" ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} - _lp_dotmatrix_make_input+="${dotmatrix_sep}${dotmatrix_field}" - fi - - if _lp_error ; then - local error_msg= - if _lp_error_meaning; then - error_msg="${lp_error_meaning}" - else - error_msg="${lp_error}" - fi - __dotmatrix_make_sep_link ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - __dotmatrix_make_field "${DOTMATRIX_MARK_ERROR}${DOTMATRIX_SPACE_VOID}${error_msg}" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - _lp_dotmatrix_make_input+="${dotmatrix_sep}${dotmatrix_field}" - fi - - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_MARK[@]+"${DOTMATRIX_COLOR_MARK[@]}"} - _lp_dotmatrix_make_input+="${dotmatrix_sep}" - lp_terminal_format ${DOTMATRIX_COLOR_MARK[@]+"${DOTMATRIX_COLOR_MARK[@]}"} - local mark_color="$lp_terminal_format" - - # No need to check LP_ENABLE_SHLVL, _lp_shell_level does it. - if _lp_shell_level ; then - local i - for ((i=0; i < lp_shell_level-1; i++)); do - _lp_dotmatrix_make_input+="${mark_color}${DOTMATRIX_MARK}" - done - fi - - # Warning _lp_dotmatrix_make_input mark if either root or sudo. - _lp_user - user="$?" - # No need to check LP_ENABLE_SUDO, _lp_sudo_active does it. - _lp_sudo_active - sudo="$?" - if [[ "$sudo" == 0 || "$user" == 2 ]] ; then - local dcwfg="${DOTMATRIX_COLOR_WARN[_LP_FIRST_INDEX+1]}" - [[ -z $dcwfg ]] && dcwfg=-1 - lp_terminal_format $dcwfg - _lp_dotmatrix_make_input+="${lp_terminal_format}${DOTMATRIX_MARK_SUDO}${DOTMATRIX_MARK}" - else - _lp_dotmatrix_make_input+="${mark_color}${DOTMATRIX_MARK}" - fi - - _lp_dotmatrix_make_input+="${NO_COL}" -} - -_lp_dotmatrix_theme_prompt() { - - local header side inline dotmatrix_prompt - - _lp_dotmatrix_make_header - header+="$_lp_dotmatrix_make_header" - - _lp_dotmatrix_make_side - side="$_lp_dotmatrix_make_side" - - # header/side assembling - if _lp_dirstack; then - lp_terminal_format ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - else - # Recall a dark format to correctly reset sections history - # to match the path's section colors. - lp_terminal_format ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - fi - - __dotmatrix_make_sep_last "$_lp_dotmatrix_has_warns" "$_lp_dotmatrix_has_notes" - header+="$dotmatrix_sep" - - # Right-align the $side with spaces. - _lp_fill "$header$NO_COL" "$side" " " - header="$lp_fill${NO_COL}" - - _lp_dotmatrix_make_env - local inline_left="$_lp_dotmatrix_make_env_inline_left" - local inline_right="$_lp_dotmatrix_make_env_inline_right" - - _lp_dotmatrix_inline_right+="${DOTMATRIX_LINE}" - - inline= - # FIXME deprecated - # # FIXME use _lp_fill-like function to handle multi-character line? - # if ((DOTMATRIX_ENABLE_GRADIENT_LINE)); then - # # Fill up the center section with a line colored as a gradient. - # local ret - # __lp_strip_escapes "$_lp_dotmatrix_make_env_inline_left" - # local left_as_text="$ret" - # local line_width=$((${COLUMNS:-80}-${#left_as_text})) - - # local line="$_lp_dotmatrix_make_env" - # local i c f a b j - # for ((i=0; i < line_width; i++)); do # For each character in the line. - # local dash_colors=() - # for ((c=_LP_FIRST_INDEX; c < 6+_LP_FIRST_INDEX; c++)); do # For each color parameter. - # a="${DOTMATRIX_COLOR_LINE_START[c]}" - # b="${DOTMATRIX_COLOR_LINE_END[c]}" - # j=$((a+(b-a)*i/line_width)) - # dash_colors+=("$j") - # done - # lp_terminal_format "${dash_colors[@]}" - # line+="${lp_terminal_format}${DOTMATRIX_LINE}" - # # line+="${lp_terminal_format}${i}(${dash_colors[@]}) " - # done - - # _lp_dotmatrix_make_env="${line}${NO_COL}" - - # else - # Fill up the remaining space with a fixed-color line. - _lp_fill "$inline_left" "$inline_right" "$DOTMATRIX_LINE" - # Format here is DOTMATRIX_COLOR_LINE. - inline="${lp_terminal_format}${lp_fill}${NO_COL}" - # fi - - _lp_dotmatrix_make_vcs - dotmatrix_prompt="$_lp_dotmatrix_make_vcs" - - _lp_dotmatrix_make_input - dotmatrix_prompt+="$_lp_dotmatrix_make_input" - - # Assemble and setup - local n=$'\n' - PS1="${n}${header}${n}${inline}${n}${dotmatrix_prompt} " -} - - - -######################################################################## -# DotVector theme -######################################################################## - -_lp_dotvector_theme_activate() { - _lp_dotmatrix_theme_activate -} - -_lp_dotvector_theme_directory() { - _lp_dotmatrix_theme_directory -} - -_lp_dotvector_theme_prompt() { - local header side inline input vcs main - - _lp_dotmatrix_make_header - header+="$_lp_dotmatrix_make_header" - - _lp_dotmatrix_make_side - side="$_lp_dotmatrix_make_side" - - # header/side assembling - if _lp_dirstack; then - lp_terminal_format ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - else - # Recall a dark format to correctly reset sections history - # to match the path's section colors. - lp_terminal_format ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - fi - - __dotmatrix_make_sep_last "$_lp_dotmatrix_has_warns" "$_lp_dotmatrix_has_notes" - header+="$dotmatrix_sep" - - _lp_dotmatrix_make_vcs - - lp_terminal_format -3 -1 - local last_color="$lp_terminal_format" - - lp_terminal_format ${DOTMATRIX_COLOR_LINE[@]} - local line_color="$lp_terminal_format" - lp_terminal_format ${DOTMATRIX_COLOR_LITE[_LP_FIRST_INDEX+0]} -1 0 0 - local before="${line_color}${DOTMATRIX_LINE}${lp_terminal_format}${DOTMATRIX_LINK[_LP_FIRST_INDEX+2]}" - - local after="${DOTMATRIX_SPACE_VOID}${last_color}${DOTMATRIX_LINK_R[_LP_FIRST_INDEX+0]}" - - vcs="${before}${_lp_dotmatrix_make_vcs}${after}" - - # Right-align the $side with spaces. - # _lp_fill "$header$NO_COL" "$side" " " - # header="$lp_fill${NO_COL}" - - _lp_dotmatrix_make_env - local inline_left="$_lp_dotmatrix_make_env_inline_left" - local inline_right="$_lp_dotmatrix_make_env_inline_right" - - _lp_dotmatrix_inline_right+="${DOTMATRIX_LINE}" - - _lp_fill "${header}${vcs}${inline_left}" "${inline_right}${side}" "$DOTMATRIX_LINE" - main="${lp_terminal_format}${lp_fill}${NO_COL}" - - lp_terminal_format ${DOTMATRIX_COLOR_LITE[@]} - local start="${lp_terminal_format}" - - _lp_dotmatrix_make_input - input="$start$_lp_dotmatrix_make_input" - - # Assemble and setup - local n=$'\n' - PS1="${n}${main}${n}${input} " -} - - -######################################################################## -# Functions called at "activate" stage. -######################################################################## - -__dotmatrix_activate_display() { - if _lp_connected_display ; then - __dotmatrix_make_field "$DOTMATRIX_DISPLAY_X11" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_DISPLAY="$dotmatrix_field" - else - __dotmatrix_make_field "$DOTMATRIX_DISPLAY_TEXT" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - _DOTMATRIX_DISPLAY="$dotmatrix_field" - fi -} - -__dotmatrix_activate_shell() { - ((DOTMATRIX_ENABLE_SHELL)) || return 2 - - if ((_LP_SHELL_zsh)) ; then - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - __dotmatrix_make_field "$DOTMATRIX_SHELL_ZSH" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - _DOTMATRIX_SHELL="${dotmatrix_sep}${dotmatrix_field}" - else - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - __dotmatrix_make_field "$DOTMATRIX_SHELL_BASH" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_SHELL="${dotmatrix_sep}${dotmatrix_field}" - fi -} - - -__dotmatrix_activate_connection() { - _lp_user - user_type="$?" - local user_color - case "$user_type" in - 0) # logged-in user - user_color=(${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"}) - ;; - 1) # other user - user_color=(${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"}) - ;; - 2) # root - user_color=(${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"}) - ;; - esac - - - local connection - _lp_connection - case "$lp_connection" in - lcl) - __dotmatrix_make_sep_plug "${user_color[@]}" - connection="${dotmatrix_sep}" - ;; - su) - __dotmatrix_make_sep_link "${user_color[@]}" - connection="${dotmatrix_sep}" - ;; - ssh) - __dotmatrix_make_sep_open "${user_color[@]}" - connection="${dotmatrix_sep}" - ;; - tel) - __dotmatrix_make_sep_dang "${user_color[@]}" - connection="${dotmatrix_sep}" - ;; - *) - __dotmatrix_make_sep_plug "${user_color[@]}" - connection="${dotmatrix_sep}" - ;; - esac - - _DOTMATRIX_CONNECTION="${connection}" -} - - -__dotmatrix_activate_user() { - _lp_user - user_type="$?" - case "$user_type" in - 0) # logged-in user - if [[ -z $lp_username ]] ; then # Honors LP_USER_ALWAYS - __dotmatrix_make_field "$DOTMATRIX_USER_LOCAL" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - _DOTMATRIX_USER="$dotmatrix_field" - else - __dotmatrix_make_field "$lp_username" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - _DOTMATRIX_USER="$dotmatrix_field" - fi - ;; - 1) # other user - _lp_username_color - __dotmatrix_make_field "$lp_username_color" ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} - _DOTMATRIX_USER="$dotmatrix_field" - ;; - 2) # root - _lp_username - __dotmatrix_make_field "$lp_username" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} - _DOTMATRIX_USER="$dotmatrix_field" - ;; - esac - return $user_type -} - - -__dotmatrix_activate_hostname() { - local hostname - if _lp_hostname; then - case "$lp_connection" in - ssh) - local client_ip client_port server_ip server_port hostname= - IFS=" " read -r client_ip client_port server_ip server_port <<<"$SSH_CONNECTION" - local username=${USER:-${USERNAME:-${LOGNAME-}}} - if _lp_create_link "ssh://${username}@${server_ip}:${server_port}" "$lp_hostname"; then - hostname="$link" - else - hostname="$lp_hostname" - fi - # If we want a different color for each host - if (( LP_ENABLE_SSH_COLORS )); then - LP_COLOR_SSH="$LP_COLOR_HOST_HASH" - hostname="${LP_COLOR_SSH}${hostname}" - else - hostname="${hostname}" - fi - ;; - tel) - hostname="${lp_hostname}" - ;; - *) - hostname+="${DOTMATRIX_HOST_LOCAL}" - ;; - esac - else - hostname="${DOTMATRIX_HOST_LOCAL}" - fi - - __dotmatrix_make_field "$hostname" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_HOSTNAME="${dotmatrix_field}" -} - - -__dotmatrix_activate_multiplexer() { - local lp_multiplexer multiplexer - if _lp_multiplexer ; then - case "$lp_multiplexer" in - tmux) - __dotmatrix_make_sep_link ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - multiplexer="${dotmatrix_sep}" - ;; - screen) - __dotmatrix_make_sep_link ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - multiplexer="${dotmatrix_sep}" - ;; - *) - __dotmatrix_make_sep_link ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - multiplexer="${dotmatrix_sep}" - ;; - esac - else - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - multiplexer="${dotmatrix_sep}" - fi - - _DOTMATRIX_MULTIPLEXER="${multiplexer}" -} - - -######################################################################## -# Functions called at directory change. -######################################################################## - -__dotmatrix_directory_FS() { - local fs= - if (( LP_ENABLE_PERM )); then - if _lp_chroot ; then - if [[ -w "$PWD" ]]; then - __dotmatrix_make_sep_open ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - fs="$dotmatrix_sep" - else - __dotmatrix_make_sep_dang ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - fs="$dotmatrix_sep" - fi - else - if [[ -w "$PWD" ]]; then - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - fs="$dotmatrix_sep" - else - __dotmatrix_make_sep_link ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - fs="$dotmatrix_sep" - fi - fi - fi - _DOTMATRIX_FS="$fs" -} - - -__dotmatrix_directory_path() { - local lp_terminal_format - - lp_terminal_format ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - local path_format="${lp_terminal_format}" - - lp_terminal_format ${DOTMATRIX_COLOR_SEP_DARK[@]+"${DOTMATRIX_COLOR_SEP_DARK[@]}"} - local separator_format=$lp_terminal_format - - lp_terminal_format ${DOTMATRIX_COLOR_PATH_SHORT[@]+"${DOTMATRIX_COLOR_PATH_SHORT[@]}"} - local shortened_format=$lp_terminal_format - - lp_terminal_format ${DOTMATRIX_COLOR_PATH_VCS[@]+"${DOTMATRIX_COLOR_PATH_VCS[@]}"} - local vcs_format=$lp_terminal_format - - lp_terminal_format ${DOTMATRIX_COLOR_PATH_LAST[@]+"${DOTMATRIX_COLOR_PATH_LAST[@]}"} - local last_dir_format=$lp_terminal_format - - local lp_path_format - _lp_path_format "$path_format" "$last_dir_format" "$vcs_format" "$shortened_format" \ - "${DOTMATRIX_SPACE_PATH}${DOTMATRIX_SOFT}${DOTMATRIX_SPACE_PATH}" "$separator_format" - - _DOTMATRIX_PATH=${lp_path_format} -} - - -######################################################################## -# Functions called at dotmatrix_prompt update. -######################################################################## - -__dotmatrix_prompt_vcs() { - if _lp_find_vcs ; then - declare -a color color_behind color_ahead - - _lp_smart_mark - - _DOTMATRIX_VCS="" - - # Mark & commits off remote - if _lp_vcs_commits_off_remote; then # There is remote-space-[local]. - _lp_vcs_remote # Get remote name. - if [[ "$lp_vcs_remote" == "origin" ]]; then - lp_vcs_remote="$DOTMATRIX_VCS_REMOTE_ORIGIN" - fi - - # Remote segment. - if [[ "$lp_vcs_commit_behind" -ne "0" ]]; then # NOTE remote segment. - if [[ "$lp_vcs_commit_behind" -ge "${DOTMATRIX_VCS_BEHIND_THRESHOLD}" ]]; then - color_behind=(${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"}) - else - color_behind=(${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"}) - fi - if (( LP_ENABLE_VCS_DIFFSTATS )) ; then - __dotmatrix_make_field "${lp_smart_mark}" "${color_behind[@]}" - _DOTMATRIX_VCS+="$dotmatrix_field" - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_sep" - __dotmatrix_make_field "${lp_vcs_remote} ${lp_vcs_commit_behind}" "${color_behind[@]}" - _DOTMATRIX_VCS+="$dotmatrix_field" - else - __dotmatrix_make_field "${lp_smart_mark}" "${color_behind[@]}" - _DOTMATRIX_VCS+="$dotmatrix_field" - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_sep" - __dotmatrix_make_field "${lp_vcs_remote} ${DOTMATRIX_DIFF}" "${color_behind[@]}" - _DOTMATRIX_VCS+="$dotmatrix_field" - fi - - else # LITE remote segment. - __dotmatrix_make_field "${lp_smart_mark}" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_sep" - __dotmatrix_make_field "${lp_vcs_remote}" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - fi - - # Link between remote and local. - # We already have `color_behind`. - if [[ "$lp_vcs_commit_ahead" -ne "0" ]]; then # NOTE local segment. - if [[ "$lp_vcs_commit_ahead" -ge "${DOTMATRIX_VCS_AHEAD_THRESHOLD}" ]]; then - color_ahead=(${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"}) - else - color_ahead=(${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"}) - fi - else # No commit ahead. - color_ahead=(${DOTMATRIX_COLOR_GLOW[@]+"${DOTMATRIX_COLOR_GLOW[@]}"}) - fi - - # Choice of link type. - # Both remote and local have commits. - if [[ "$lp_vcs_commit_behind" -ne "0" && "$lp_vcs_commit_ahead" -ne "0" ]]; then - __dotmatrix_make_sep_link_opposed "${color_ahead[@]}" - # Only remote have commit. - elif [[ "$lp_vcs_commit_behind" -ne "0" && "$lp_vcs_commit_ahead" -eq "0" ]]; then - __dotmatrix_make_sep_link_reverse "${color_ahead[@]}" - # Only local have commits. - else - __dotmatrix_make_sep_link "${color_ahead[@]}" - fi - _DOTMATRIX_VCS+="$dotmatrix_sep" - - # Local segment. - if [[ "$lp_vcs_commit_ahead" -ne "0" ]]; then # NOTE local segment. - # We already have `color_ahead`. - if (( LP_ENABLE_VCS_DIFFSTATS )) ; then - __dotmatrix_make_field "$lp_vcs_commit_ahead" "${color_ahead[@]}" - _DOTMATRIX_VCS+="$dotmatrix_field" - else - __dotmatrix_make_field "$DOTMATRIX_DIFF" "${color_ahead[@]}" - _DOTMATRIX_VCS+="$dotmatrix_field" - fi - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_GLOW[@]+"${DOTMATRIX_COLOR_GLOW[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_sep" - # else # 0 commit ahead => direct segment. - fi - - else # No commits off remote => There is no space between remote and branch, and no remote name. - __dotmatrix_make_field "${lp_smart_mark}" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_GLOW[@]+"${DOTMATRIX_COLOR_GLOW[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_sep" - # No local commit segment. - fi - - # Branch:bookmark/tag - if _lp_vcs_branch; then - __dotmatrix_make_field "$lp_vcs_branch" ${DOTMATRIX_COLOR_GLOW[@]+"${DOTMATRIX_COLOR_GLOW[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - - if _lp_vcs_bookmark; then - __dotmatrix_make_field ":${lp_vcs_bookmark}" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - fi - if _lp_vcs_tag; then - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_DARK[@]+"${DOTMATRIX_COLOR_SEP_DARK[@]}"} - __dotmatrix_make_field "$lp_vcs_tag" ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} - _DOTMATRIX_VCS+="${dotmatrix_sep}${dotmatrix_field}" - fi - - elif _lp_vcs_bookmark; then - __dotmatrix_make_field "$lp_vcs_bookmark" ${DOTMATRIX_COLOR_GLOW[@]+"${DOTMATRIX_COLOR_GLOW[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - elif _lp_vcs_tag; then - __dotmatrix_make_field "$lp_vcs_tag" ${DOTMATRIX_COLOR_GLOW[@]+"${DOTMATRIX_COLOR_GLOW[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - else - _lp_vcs_commit_id - __dotmatrix_make_field "${lp_vcs_commit_id:0:7}" ${DOTMATRIX_COLOR_GLOW[@]+"${DOTMATRIX_COLOR_GLOW[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - fi # vcs branch - - # Diff stats - local ret has_lines= - if _lp_vcs_uncommitted_files; then - _lp_vcs_unstaged_lines; ret=$? - _lp_vcs_uncommitted_lines - if [[ $((ret+lp_vcs_uncommitted_i_lines+lp_vcs_uncommitted_d_lines)) -gt "${DOTMATRIX_VCS_DIFF_THRESHOLD}" ]]; then - color=(${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"}) - else - color=(${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"}) - fi - __dotmatrix_make_sep_link "${color[@]}" - _DOTMATRIX_VCS+="$dotmatrix_sep" - - # Only show unstaged changes if the VCS supports staging, otherwise - # show uncommitted changes - if (( ret == 0 )); then - if [[ "$lp_vcs_unstaged_i_lines" == "$lp_vcs_unstaged_d_lines" ]] ; then - # If same number of lines inserted and deleted: display a single number. - __dotmatrix_make_field "±$lp_vcs_unstaged_i_lines" "${color[@]}" - has_lines="$dotmatrix_field" - else - __dotmatrix_make_field "+$lp_vcs_unstaged_i_lines" "${color[@]}" - has_lines="$dotmatrix_field" - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} - has_lines+="$dotmatrix_sep" - __dotmatrix_make_field "-$lp_vcs_unstaged_d_lines" "${color[@]}" - has_lines+="$dotmatrix_field" - fi - - elif (( ret == 1 )); then - # Maybe just removed a file, in which case no line is reported to be impacted, - # but this is still a change. - __dotmatrix_make_field "±0" ${DOTMATRIX_COLOR_DARK[@]+"${color[@]}"} - has_lines="${dotmatrix_field}" - else - if [[ "$lp_vcs_uncommitted_i_lines" == "$lp_vcs_uncommitted_d_lines" ]] ; then - __dotmatrix_make_field "±$lp_vcs_uncommitted_i_lines" "${color[@]}" - has_lines="$dotmatrix_field" - else - __dotmatrix_make_field "+$lp_vcs_uncommitted_i_lines" "${color[@]}" - has_lines="$dotmatrix_field" - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} - has_lines+="$dotmatrix_sep" - __dotmatrix_make_field "-$lp_vcs_uncommitted_d_lines" "${color[@]}" - has_lines+="$dotmatrix_field" - fi - fi - if (( LP_ENABLE_VCS_DIFFSTATS )) ; then - _DOTMATRIX_VCS+="$has_lines" - else - __dotmatrix_make_field "$DOTMATRIX_DIFF" "${color[@]}" - _DOTMATRIX_VCS+="$dotmatrix_field" - fi # LP_ENABLE_VCS_DIFFSTATS - fi # uncommitted files - - # Stash / untracked / head - local stash="" untracked="" head="" - if _lp_vcs_stash_count; then - stash="$DOTMATRIX_MARK_STASH" - fi - if _lp_vcs_untracked_files; then - untracked="$DOTMATRIX_MARK_UNTRACKED" - fi - if _lp_vcs_head_status; then - head="$lp_vcs_head_status" - # if [[ -n "${lp_vcs_head_details-}" ]]; then - # pass - # fi - fi - if [[ -n "$stash" || -n "$untracked" || -n "$head" ]] ; then - __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_sep" - fi - - if [[ -n "$stash" ]] ; then - __dotmatrix_make_field "$stash" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - if [[ -n "$untracked" ]] ; then - __dotmatrix_make_field "$untracked" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} - _DOTMATRIX_VCS+="${dotmatrix_sep}${dotmatrix_field}" - fi - if [[ -n "$head" ]] ; then - __dotmatrix_make_field "$head" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} - _DOTMATRIX_VCS+="${dotmatrix_sep}${dotmatrix_field}" - fi - else # no stash - if [[ -n "$untracked" ]] ; then - __dotmatrix_make_field "$untracked" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - if [[ -n "$head" ]] ; then - __dotmatrix_make_field "$head" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - __dotmatrix_make_sep_soft ${DOTMATRIX_COLOR_SEP_LITE[@]+"${DOTMATRIX_COLOR_SEP_LITE[@]}"} - _DOTMATRIX_VCS+="${dotmatrix_sep}${dotmatrix_field}" - fi - else # no untracked - if [[ -n "$head" ]] ; then - __dotmatrix_make_field "$head" ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} - _DOTMATRIX_VCS+="$dotmatrix_field" - fi - fi - fi # stash - return 0 - else - _DOTMATRIX_VCS="" - return 1 - fi # find_vcs -} - -######################################################################## -# Helper functions -######################################################################## - -__dotmatrix_join_fields() { - dotmatrix_join_fields="" - local sep="${1-}" - shift - if [[ -n "$*" ]] ; then - local first_field="${1-}" - shift - dotmatrix_join_fields="${first_field}" - for f in "$@"; do - [[ -z $f ]] && continue - dotmatrix_join_fields+="${sep}${f}" - done - fi -} - -__dotmatrix_make_field() { # string, color_array - local lp_terminal_format string="${1-}" - [[ -z $string ]] && return 1 - - shift - lp_terminal_format "$@" - - dotmatrix_field="${lp_terminal_format}${DOTMATRIX_SPACE_FIELD}${string}${DOTMATRIX_SPACE_FIELD}" -} - -__dotmatrix_make_sep_plug() { # color - # fg, bg, bold, underline, fallback_fg, fallback_bg - # 0 = set last color to current color - # -1 = set color to last color - # -2 = keep last color - # -3 = set last fg to last bg (and conversely) - local lp_terminal_format sep - - local bg="${2-}" - [[ -z $bg ]] && bg=-1 - local fbg="${6-}" - [[ -z $fbg ]] && fbg=-1 - - sep="${DOTMATRIX_PLUG}" - if [[ "${_lp_last_ab_color-}" == "$bg" ]] ; then - sep="${DOTMATRIX_MEAN}" - fi - - lp_terminal_format -3 "$bg" 0 0 -3 "$fbg" - dotmatrix_sep="${DOTMATRIX_SPACE_VOID}${lp_terminal_format}${sep}${DOTMATRIX_SPACE_VOID}" -} - -__dotmatrix_make_sep_link() { # color - local lp_terminal_format - dotmatrix_sep="" - - local fg="${2-}" - [[ -z $fg ]] && fg=-1 - local fbg="${6-}" - [[ -z $fbg ]] && fbg=-1 - - lp_terminal_format -3 -1 0 0 -1 "$fbg" - dotmatrix_sep+="${DOTMATRIX_SPACE_VOID}${lp_terminal_format}${DOTMATRIX_LINK[_LP_FIRST_INDEX]}" - - local dsfg="${DOTMATRIX_COLOR_SEP_FAIR[_LP_FIRST_INDEX]}" - [[ -z $dsfg ]] && dsfg=-1 - lp_terminal_format "$dsfg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_LINK[_LP_FIRST_INDEX+1]}" - - lp_terminal_format "$fg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_LINK[_LP_FIRST_INDEX+2]}${DOTMATRIX_SPACE_FILL}" -} - -__dotmatrix_make_sep_link_reverse() { # color - local lp_terminal_format - dotmatrix_sep="" - - local fg="${2-}" - [[ -z $fg ]] && fg=-1 - local fbg="${6-}" - [[ -z $fbg ]] && fbg=-1 - - lp_terminal_format -3 -1 0 0 -1 "$fbg" - dotmatrix_sep+="${DOTMATRIX_SPACE_VOID}${lp_terminal_format}${DOTMATRIX_LINK_R[_LP_FIRST_INDEX]}" - - local dsfg="${DOTMATRIX_COLOR_SEP_FAIR[_LP_FIRST_INDEX]}" - [[ -z $dsfg ]] && dsfg=-1 - lp_terminal_format "$dsfg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_LINK_R[_LP_FIRST_INDEX+1]}" - - lp_terminal_format "$fg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_LINK_R[_LP_FIRST_INDEX+2]}${DOTMATRIX_SPACE_FILL}" -} - -__dotmatrix_make_sep_link_opposed() { # color - local lp_terminal_format - dotmatrix_sep="" - - local fg="${2-}" - [[ -z $fg ]] && fg=-1 - local fbg="${6-}" - [[ -z $fbg ]] && fbg=-1 - - lp_terminal_format -3 -1 0 0 -1 "$fbg" - dotmatrix_sep+="${DOTMATRIX_SPACE_VOID}${lp_terminal_format}${DOTMATRIX_LINK_R[_LP_FIRST_INDEX]}" - - local dsfg="${DOTMATRIX_COLOR_SEP_FAIR[_LP_FIRST_INDEX]}" - [[ -z $dsfg ]] && dsfg=-1 - lp_terminal_format "$dsfg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_LINK[_LP_FIRST_INDEX+1]}" - - lp_terminal_format "$fg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_LINK[_LP_FIRST_INDEX+2]}${DOTMATRIX_SPACE_FILL}" -} - - -__dotmatrix_make_sep_open() { # color - local lp_terminal_format - - local fg="${2-}" - [[ -z $fg ]] && fg=-1 - local fbg="${6-}" - [[ -z $fbg ]] && fbg=-1 - - lp_terminal_format -3 -1 0 0 -1 "$fbg" - dotmatrix_sep+="${DOTMATRIX_SPACE_VOID}${lp_terminal_format}${DOTMATRIX_OPEN[_LP_FIRST_INDEX]}" - - local dsfg="${DOTMATRIX_COLOR_SEP_FAIR[_LP_FIRST_INDEX]}" - [[ -z $dsfg ]] && dsfg=-1 - lp_terminal_format "$dsfg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_OPEN[_LP_FIRST_INDEX+1]}" - - lp_terminal_format "$fg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_OPEN[_LP_FIRST_INDEX+2]}${DOTMATRIX_SPACE_FILL}" -} - -__dotmatrix_make_sep_dang() { # color - local lp_terminal_format - - local fg="${2-}" - [[ -z $fg ]] && fg=-1 - local fbg="${6-}" - [[ -z $fbg ]] && fbg=-1 - - lp_terminal_format -3 -1 0 0 -1 "$fbg" - dotmatrix_sep+="${DOTMATRIX_SPACE_VOID}${lp_terminal_format}${DOTMATRIX_DANG[_LP_FIRST_INDEX]}" - - local dcwfg="${DOTMATRIX_COLOR_WARN[_LP_FIRST_INDEX+1]}" - [[ -z $dcwfg ]] && dcwfg=-1 - lp_terminal_format "$dcwfg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_DANG[_LP_FIRST_INDEX+1]}" - - lp_terminal_format "$fg" -1 0 0 -1 "$fbg" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_DANG[_LP_FIRST_INDEX+2]}${DOTMATRIX_SPACE_FILL}" -} - -__dotmatrix_make_sep_soft() { # color - local lp_terminal_format - - local fg="${1-}" - [[ -z $fg ]] && fg=-1 - local fbg="${5-}" - [[ -z $fbg ]] && fbg=-1 - - lp_terminal_format "$fg" -2 0 0 "$fbg" - dotmatrix_sep="${lp_terminal_format}${DOTMATRIX_SOFT}" -} - -__dotmatrix_make_sep_mid() { # color - local lp_terminal_format - - local fg="${1-}" - [[ -z $fg ]] && fg=-1 - local fbg="${5-}" - [[ -z $fbg ]] && fbg=-1 - - lp_terminal_format "$fg" -2 0 0 "$fbg" - dotmatrix_sep="${lp_terminal_format}${DOTMATRIX_SPACE_VOID}${DOTMATRIX_MEAN}${DOTMATRIX_SPACE_VOID}" -} - -__dotmatrix_make_sep_last() { # [has_warns [has_notes]] - local lp_terminal_format - local has_warns="${1:-0}" - local has_notes="${2:-0}" - lp_terminal_format -3 -1 0 0 -3 -1 - dotmatrix_sep="${lp_terminal_format}${DOTMATRIX_ENDS[_LP_FIRST_INDEX+0]}${NO_COL}" - if [[ $has_warns -eq 0 && $has_notes -gt 0 ]] ; then - # Use the background of COLOR_NOTE as a foreground here. - lp_terminal_format "${DOTMATRIX_COLOR_NOTE[1]}" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_ENDS[_LP_FIRST_INDEX+1]}${NO_COL}" - else - if [[ $has_warns -gt 0 ]]; then - # Use the background of COLOR_WARN as a foreground here. - lp_terminal_format "${DOTMATRIX_COLOR_WARN[1]}" - dotmatrix_sep+="${lp_terminal_format}${DOTMATRIX_ENDS[_LP_FIRST_INDEX+1]}${DOTMATRIX_ENDS[_LP_FIRST_INDEX+1]}${NO_COL}" - else - dotmatrix_sep="${lp_terminal_format}${DOTMATRIX_ENDS[_LP_FIRST_INDEX+0]}${NO_COL}" - fi - fi -} - -__dotmatrix_make_sep_side() { # no arg - local lp_terminal_format - lp_terminal_format -3 -1 0 0 -3 -1 # Reset to no background. - local dsf=(${DOTMATRIX_COLOR_SEP_FAIR[@]+"${DOTMATRIX_COLOR_SEP_FAIR[@]}"}) - [[ -z "${dsf[*]}" ]] && dsf=(-1) - lp_terminal_format "${dsf[@]}" - dotmatrix_sep="${lp_terminal_format}${DOTMATRIX_ENDS[_LP_FIRST_INDEX+2]}" -} - diff --git a/jolly.theme b/jolly.theme new file mode 100644 index 0000000..184b94e --- /dev/null +++ b/jolly.theme @@ -0,0 +1,1421 @@ + +######################################################################## +# API +######################################################################## + +_lp_jolly_theme_activate() { + + if ! _lp_version_greatereq 2 2 0 ; then + _lp_join "." ${_LP_VERSION[@]} + printf "WARNING: the Jolly theme requires Liquid Prompt >= 2.2.0, but you have version $lp_join, some features will not work and the prompt may crash.\n" + fi + + LP_ENABLE_VCS_DIFFSTATS=${LP_ENABLE_VCS_DIFFSTATS:-1} + _LP_LOAD_THRESHOLD=${_LP_LOAD_THRESHOLD:-80} + _LP_LOAD_CAP=${_LP_LOAD_CAP:-100} + + JOLLY_DISPLAY_TEXT=${JOLLY_DISPLAY_TEXT:-"T"} + JOLLY_DISPLAY_X11=${JOLLY_DISPLAY_X11:-"X"} + JOLLY_HOST_LOCAL=${JOLLY_HOST_LOCAL:-"⌂"} + JOLLY_MARK_STASH=${JOLLY_MARK_STASH:-"✝"} + JOLLY_MARK_UNTRACKED=${JOLLY_MARK_UNTRACKED:-"?"} # ⛶ + JOLLY_DIFF=${JOLLY_DIFF:-"≠"} + + JOLLY_ENABLE_GRADIENT_LINE=${JOLLY_ENABLE_GRADIENT_LINE:-0} + JOLLY_ENABLE_SHELL=${JOLLY_ENABLE_SHELL:-0} + + JOLLY_SHELL_ZSH=${JOLLY_SHELL_ZSH:-"z"} + JOLLY_SHELL_BASH=${JOLLY_SHELL_BASH:-"b"} + + JOLLY_VCS_REMOTE_ORIGIN=${JOLLY_VCS_REMOTE_ORIGIN:-"🖈"} + + JOLLY_ENABLE_HISTORY=${JOLLY_ENABLE_HISTORY:-0} + JOLLY_HISTORY_LAST_LEN=${JOLLY_HISTORY_LAST_LEN:-$((COLUMNS/4))} + JOLLY_HISTORY_LAST_LEN_MARK=${JOLLY_HISTORY_LAST_LEN_MARK:-"[…]"} + JOLLY_HISTORY_MOST_BACK=${JOLLY_HISTORY_MOST_BACK:-100} + + # Thresholds based on 75th quantile for: + # nb of commits in PR on Github and added+removed lines. + # See: https://promyze.com/observations-on-10000-pull-requests-on-github/ + JOLLY_VCS_AHEAD_THRESHOLD=${JOLLY_VCS_AHEAD_THRESHOLD:-5} + JOLLY_VCS_BEHIND_THRESHOLD=${JOLLY_VCS_BEHIND_THRESHOLD:-5} + JOLLY_VCS_DIFF_THRESHOLD=${JOLLY_VCS_DIFF_THRESHOLD:-300} + + JOLLY_DETACHED_THRESHOLD=${JOLLY_DETACHED_THRESHOLD:-3} + JOLLY_RUNNING_THRESHOLD=${JOLLY_RUNNING_THRESHOLD:-3} + JOLLY_STOPPED_THRESHOLD=${JOLLY_STOPPED_THRESHOLD:-3} + + JOLLY_BATTERY_THRESHOLD=${JOLLY_BATTERY_THRESHOLD:-$((LP_BATTERY_THRESHOLD/2))} + JOLLY_RAM_THRESHOLD=${JOLLY_RAM_THRESHOLD:-$((LP_RAM_THRESHOLD/2))} + JOLLY_DISK_THRESHOLD=${JOLLY_DISK_THRESHOLD:-$((LP_DISK_THRESHOLD/2))} + JOLLY_TEMP_THRESHOLD=${JOLLY_TEMP_THRESHOLD:-$((LP_TEMP_THRESHOLD*2))} + # Use prefixed _LP_* variables, which are integers. + JOLLY_LOAD_THRESHOLD=${JOLLY_LOAD_THRESHOLD:-$((_LP_LOAD_THRESHOLD+(_LP_LOAD_CAP-_LP_LOAD_THRESHOLD)/2))} + + JOLLY_MARK_ERROR=${JOLLY_MARK_ERROR:-""} + + # Sets of characters + # "dotmatrix" variant by default (non-patched font) + JOLLY_HOST_LOCAL=${JOLLY_HOST_LOCAL:-"⌂"} + JOLLY_USER_LOCAL=${JOLLY_USER_LOCAL:-"♟"} + JOLLY_VCS=${JOLLY_VCS:-"╟┘"} + JOLLY_MARK=${JOLLY_MARK:-"⯀"} + JOLLY_MARK_SUDO=${JOLLY_MARK_SUDO:-"⋮"} + JOLLY_LINE=${JOLLY_LINE:-"━"} + JOLLY_PLUG=${JOLLY_PLUG:-"▛"} + JOLLY_SOFT=${JOLLY_SOFT:-"╱"} + JOLLY_MEAN=${JOLLY_MEAN:-"▞"} + # Separator arrays (left center right) + JOLLY_LINK=( ${JOLLY_LINK[@]+"${JOLLY_LINK[@]}"} ) + [[ ${#JOLLY_LINK[@]} == 0 ]] && JOLLY_LINK=("▙" " " "▜") + JOLLY_LINK_R=( ${JOLLY_LINK_R[@]+"${JOLLY_LINK_R[@]}"} ) + [[ ${#JOLLY_LINK_R[@]} == 0 ]] && JOLLY_LINK_R=("▛" " " "▟") + JOLLY_OPEN=( ${JOLLY_OPEN[@]+"${JOLLY_OPEN[@]}"} ) + [[ ${#JOLLY_OPEN[@]} == 0 ]] && JOLLY_OPEN=("▙" " ▚ " "▜") + JOLLY_DANG=( ${JOLLY_DANG[@]+"${JOLLY_DANG[@]}"} ) + [[ ${#JOLLY_DANG[@]} == 0 ]] && JOLLY_DANG=("▙" " □ " "▜") + JOLLY_ENDS=( ${JOLLY_ENDS[@]+"${JOLLY_ENDS[@]}"} ) + [[ ${#JOLLY_ENDS[@]} == 0 ]] && JOLLY_ENDS=("▛" "▞▗ ▝" "▖ ▘▞▟") + JOLLY_ITEMS=( ${JOLLY_ITEMS[@]+"${JOLLY_ITEMS[@]}"} ) + [[ ${#JOLLY_ITEMS[@]} == 0 ]] && JOLLY_ITEMS=("┫" "┃" "┣") + + JOLLY_SPACED=${JOLLY_SPACED:-1} + + # Number of spaces to add + if [[ ${JOLLY_SPACED} == 0 ]] ; then + JOLLY_SPACE_VOID="" + JOLLY_SPACE_FILL="" + JOLLY_SPACE_PATH=${JOLLY_SPACE_PATH:-""} + JOLLY_SPACE_FIELD=${JOLLY_SPACE_FIELD:-""} + JOLLY_SPACE_LINE=${JOLLY_SPACE_LINE:-""} + + elif [[ ${JOLLY_SPACED} == 1 ]] ; then + JOLLY_SPACE_VOID=" " + JOLLY_SPACE_FILL="█" + JOLLY_SPACE_PATH=${JOLLY_SPACE_PATH:-" "} + JOLLY_SPACE_FIELD=${JOLLY_SPACE_FIELD:-""} + JOLLY_SPACE_LINE=${JOLLY_SPACE_LINE:-" "} + else + local n="${JOLLY_SPACED:-1}" + [[ $n -lt 0 ]] && n=1 + local i + JOLLY_SPACE_VOID="" + JOLLY_SPACE_FILL="" + for ((i=0; i < n; i++)); do + JOLLY_SPACE_VOID+=" " # Regular space + JOLLY_SPACE_FILL+="█" # Inverted space + done + + JOLLY_SPACE_PATH=${JOLLY_SPACE_PATH:-"${JOLLY_SPACE_VOID}"} + JOLLY_SPACE_FIELD=${JOLLY_SPACE_FIELD:-""} + JOLLY_SPACE_LINE=${JOLLY_SPACE_LINE:-""} + fi + + + # Color arrays defaults fg bg b u ffg fbg + JOLLY_COLOR_DARK=( ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} ) + [[ ${#JOLLY_COLOR_DARK[@]} == 0 ]] && JOLLY_COLOR_DARK=(252 239 0 0 15 0) + + JOLLY_COLOR_LITE=( ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} ) + [[ ${#JOLLY_COLOR_LITE[@]} == 0 ]] && JOLLY_COLOR_LITE=(239 252 0 0 0 15) + + JOLLY_COLOR_GLOW=( ${JOLLY_COLOR_GLOW[@]+"${JOLLY_COLOR_GLOW[@]}"} ) + [[ ${#JOLLY_COLOR_GLOW[@]} == 0 ]] && JOLLY_COLOR_GLOW=( 255 239 1 0 0 15) + + JOLLY_COLOR_NOTE=( ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} ) + [[ ${#JOLLY_COLOR_NOTE[@]} == 0 ]] && JOLLY_COLOR_NOTE=( 15 33 0 0 15 12) + + JOLLY_COLOR_WARN=( ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} ) + [[ ${#JOLLY_COLOR_WARN[@]} == 0 ]] && JOLLY_COLOR_WARN=(196 220 1 0 0 11) + + JOLLY_COLOR_FAIR=( ${JOLLY_COLOR_FAIR[@]+"${JOLLY_COLOR_FAIR[@]}"} ) + [[ ${#JOLLY_COLOR_FAIR[@]} == 0 ]] && JOLLY_COLOR_FAIR=( 0 239 1 0 0 8) + + + JOLLY_COLOR_PATH_SHORT=( ${JOLLY_COLOR_PATH_SHORT[@]+"${JOLLY_COLOR_PATH_SHORT[@]}"} ) + [[ ${#JOLLY_COLOR_PATH_SHORT[@]} == 0 ]] && JOLLY_COLOR_PATH_SHORT=(252 239 0 0 0 15) + + JOLLY_COLOR_PATH_VCS=( ${JOLLY_COLOR_PATH_VCS[@]+"${JOLLY_COLOR_PATH_VCS[@]}"} ) + [[ ${#JOLLY_COLOR_PATH_VCS[@]} == 0 ]] && JOLLY_COLOR_PATH_VCS=(252 239 0 1 0 15) + + JOLLY_COLOR_PATH_LAST=( ${JOLLY_COLOR_PATH_LAST[@]+"${JOLLY_COLOR_PATH_LAST[@]}"} ) + [[ ${#JOLLY_COLOR_PATH_LAST[@]} == 0 ]] && JOLLY_COLOR_PATH_LAST=(15 239 1 0 0 15) + + + JOLLY_COLOR_LINE=( ${JOLLY_COLOR_LINE[@]+"${JOLLY_COLOR_LINE[@]}"} ) + [[ ${#JOLLY_COLOR_LINE[@]} == 0 ]] && JOLLY_COLOR_LINE=(244 -1 0 0 15 -1) + + JOLLY_COLOR_LINE_START=( ${JOLLY_COLOR_LINE_START[@]+"${JOLLY_COLOR_LINE_START[@]}"} ) + [[ ${#JOLLY_COLOR_LINE_START[@]} == 0 ]] && JOLLY_COLOR_LINE_START=(255 -1 1 0 15 -1) + + JOLLY_COLOR_LINE_END=( ${JOLLY_COLOR_LINE_END[@]+"${JOLLY_COLOR_LINE_END[@]}"} ) + [[ ${#JOLLY_COLOR_LINE_END[@]} == 0 ]] && JOLLY_COLOR_LINE_END=(232 -1 1 0 15 -1) + + + JOLLY_COLOR_MARK=( ${JOLLY_COLOR_MARK[@]+"${JOLLY_COLOR_MARK[@]}"} ) + [[ ${#JOLLY_COLOR_MARK[@]} == 0 ]] && JOLLY_COLOR_MARK=(15 -1 0 0 15 -1) + + JOLLY_COLOR_SEP_DARK=( ${JOLLY_COLOR_SEP_DARK[@]+"${JOLLY_COLOR_SEP_DARK[@]}"} ) + [[ ${#JOLLY_COLOR_SEP_DARK[@]} == 0 ]] && JOLLY_COLOR_SEP_DARK=( 0 -2 0 0 0 -2) + + JOLLY_COLOR_SEP_FAIR=( ${JOLLY_COLOR_SEP_FAIR[@]+"${JOLLY_COLOR_SEP_FAIR[@]}"} ) + [[ ${#JOLLY_COLOR_SEP_FAIR[@]} == 0 ]] && JOLLY_COLOR_SEP_FAIR=(244 -2 0 0 0 -2) + + JOLLY_COLOR_SEP_LITE=( ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} ) + [[ ${#JOLLY_COLOR_SEP_LITE[@]} == 0 ]] && JOLLY_COLOR_SEP_LITE=( 15 -2 0 0 15 -2) + + # Default line color for unset variables. + LP_COLOR_ENV_VARS_UNSET=${LP_COLOR_ENV_VARS_UNSET:-""} + # Use the background of notes as a foreground for set variables. + lp_terminal_format "${JOLLY_COLOR_NOTE[1]}" + LP_COLOR_ENV_VARS_SET=${LP_COLOR_ENV_VARS_SET:-"$lp_terminal_format"} + + # LP_COLORMAP=( ${LP_COLORMAP[@]+"${LP_COLORMAP[@]}"} ) + # if [[ ${#LP_COLORMAP[@]} == 0 ]]; then + local lp_terminal_format + lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + local l1="$lp_terminal_format" + lp_terminal_format ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} + local l2="$lp_terminal_format" + lp_terminal_format ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + local l3="$lp_terminal_format" + LP_COLORMAP=( + "" # l0 + "$l1" + "$l2" + "$l3" + ) + # fi + + __jolly_activate_display + # __jolly_activate_shell + __jolly_activate_connection + __jolly_activate_user + __jolly_activate_multiplexer + __jolly_activate_hostname +} + + +_lp_jolly_theme_directory() { + lp_terminal_format ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + __jolly_directory_FS + __jolly_directory_path +} + + +_lp_jolly_make_header() { + + # Arguments: fg, bg, bold, underline, fallback_fg, fallback_bg + # Color codes can be any integer in 256 XTerm's system colors in [0–255]. + # Special color codes: + # -1 : no color + # -2 : previously set color + # -3 : swap fg and bg + local lp_terminal_format + + #################################################################### + # HEADER (LEFT) + #################################################################### + + _lp_jolly_make_header="" + _lp_jolly_make_header+="${_JOLLY_DISPLAY}" + _lp_jolly_make_header+="${_JOLLY_CONNECTION}" + _lp_jolly_make_header+="${_JOLLY_USER}" + _lp_jolly_make_header+="${_JOLLY_MULTIPLEXER}" + _lp_jolly_make_header+="${_JOLLY_HOSTNAME}" + _lp_jolly_make_header+="${_JOLLY_FS}" + _lp_jolly_make_header+="${_JOLLY_PATH} " + + if _lp_dirstack; then + # Pseudo-recall the path section format. + lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + __jolly_make_sep_plug ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _lp_jolly_make_header+="${jolly_sep}" + __jolly_make_field "$lp_dirstack" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _lp_jolly_make_header+="${jolly_field}" + fi +} + +_lp_jolly_make_side() { + + #################################################################### + # HEADER SIDE (RIGHT) + #################################################################### + + local _lp_jolly_has_notes=0 + local _lp_jolly_has_warns=0 + + # JOLLY_COLOR_SEP_FAIR + __jolly_make_sep_side "" + _lp_jolly_make_side="${jolly_sep}" + + # battery / load / temperature + local battery= + if _lp_battery_color ; then + if [[ $lp_battery -le "$JOLLY_BATTERY_THRESHOLD" ]]; then + __jolly_make_field "$lp_battery$_LP_PERCENT" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + battery="${jolly_field}${LP_MARK_BATTERY}" + _lp_jolly_has_warns=$((_lp_jolly_has_warns+1)) + else + __jolly_make_field "$lp_battery$_LP_PERCENT" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + battery="${jolly_field}${LP_MARK_BATTERY}" + _lp_jolly_has_notes=$((_lp_jolly_has_notes+1)) + fi + fi + + local load= + if _lp_load_color ; then + if [[ $lp_load_adjusted -ge "$JOLLY_LOAD_THRESHOLD" ]]; then + __jolly_make_field "$lp_load" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + load="${jolly_field}${LP_MARK_LOAD}" + _lp_jolly_has_warns=$((_lp_jolly_has_warns+1)) + else + __jolly_make_field "$lp_load" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + load="${jolly_field}${LP_MARK_LOAD}" + _lp_jolly_has_notes=$((_lp_jolly_has_notes+1)) + fi + fi + + local ram= + if _lp_ram_color ; then + if [[ $lp_ram_perc -le "$JOLLY_RAM_THRESHOLD" ]]; then + __jolly_make_field "$lp_ram_perc$_LP_PERCENT" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + ram="${jolly_field}${LP_MARK_RAM}" + _lp_jolly_has_warns=$((_lp_jolly_has_warns+1)) + else + __jolly_make_field "$lp_ram_perc$_LP_PERCENT" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + ram="${jolly_field}${LP_MARK_RAM}" + _lp_jolly_has_notes=$((_lp_jolly_has_notes+1)) + fi + fi + + local disk= + if _lp_disk_color ; then + if [[ $lp_disk_perc -le "$JOLLY_DISK_THRESHOLD" ]]; then + __jolly_make_field "$lp_disk_perc$_LP_PERCENT" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + disk="${jolly_field}${LP_MARK_DISK}" + _lp_jolly_has_warns=$((_lp_jolly_has_warns+1)) + else + __jolly_make_field "$lp_disk_perc$_LP_PERCENT" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + disk="${jolly_field}${LP_MARK_DISK}" + _lp_jolly_has_notes=$((_lp_jolly_has_notes+1)) + fi + fi + + local temperature= + if _lp_temperature_color ; then + if [[ $lp_temperature -ge "$JOLLY_TEMP_THRESHOLD" ]]; then + __jolly_make_field "$lp_temperature" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + temperature="${jolly_field}${LP_MARK_TEMP}" + _lp_jolly_has_warns=$((_lp_jolly_has_warns+1)) + else + __jolly_make_field "$lp_temperature" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + temperature="${jolly_field}${LP_MARK_TEMP}" + _lp_jolly_has_notes=$((_lp_jolly_has_notes+1)) + fi + fi + + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_DARK[@]+"${JOLLY_COLOR_SEP_DARK[@]}"} + declare -a blt=($battery $load $ram $disk $temperature) # Unquoted on purpose. + if [[ ${#blt[@]} -gt 0 ]] ; then + _lp_join "$jolly_sep" ${blt[@]} + if [[ -n "$lp_join" ]] ; then + + # Match the side sep + local fg="${JOLLY_COLOR_SEP_FAIR[0]}" + local ffg="${JOLLY_COLOR_SEP_FAIR[4]}" + lp_terminal_format "$fg" -2 0 0 "$ffg" -2 + # No space before sep. + _lp_jolly_make_side+="${lp_terminal_format}${JOLLY_SPACE_VOID}${lp_join}" + + fi + else + lp_terminal_format ${JOLLY_COLOR_FAIR[@]+"${JOLLY_COLOR_FAIR[@]}"} + _lp_jolly_make_side+="${lp_terminal_format}" + fi + + # jobs: detached / running / stopped + + local detached_sessions= + if _lp_detached_sessions ; then + if [[ -n "${lp_detached_sessions}" && "${lp_detached_sessions}" -gt 0 ]] ; then + if [[ "${lp_detached_sessions}" -ge "${JOLLY_DETACHED_THRESHOLD}" ]]; then + __jolly_make_field "${lp_detached_sessions}d" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + detached_sessions="${jolly_field}" + _lp_jolly_has_warns=$((_lp_jolly_has_warns+1)) + else + __jolly_make_field "${lp_detached_sessions}d" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} + detached_sessions="${jolly_field}" + _lp_jolly_has_notes=$((_lp_jolly_has_notes+1)) + fi + fi + fi + + local running_jobs= + local stopped_jobs= + if _lp_jobcount ; then + if [[ -n "${lp_running_jobs}" && "${lp_running_jobs}" -gt 0 ]] ; then + if [[ "${lp_running_jobs}" -ge "${JOLLY_RUNNING_THRESHOLD}" ]]; then + __jolly_make_field "${lp_running_jobs}&" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + running_jobs="${jolly_field}" + _lp_jolly_has_warns=$((_lp_jolly_has_warns+1)) + else + __jolly_make_field "${lp_running_jobs}&" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} + running_jobs="${jolly_field}" + _lp_jolly_has_notes=$((_lp_jolly_has_notes+1)) + fi + fi + + if [[ -n "${lp_stopped_jobs}" && "${lp_stopped_jobs}" -gt 0 ]] ; then + if [[ "${lp_stopped_jobs}" -ge "${JOLLY_STOPPED_THRESHOLD}" ]]; then + __jolly_make_field "${lp_stopped_jobs}z" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + stopped_jobs="${jolly_field}" + _lp_jolly_has_warns=$((_lp_jolly_has_warns+1)) + else + __jolly_make_field "${lp_stopped_jobs}z" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} + stopped_jobs="${jolly_field}" + _lp_jolly_has_notes=$((_lp_jolly_has_notes+1)) + fi + fi + fi + + lp_terminal_format ${JOLLY_COLOR_FAIR[@]+"${JOLLY_COLOR_FAIR[@]}"} + if [[ $_lp_jolly_has_warns -gt 0 ]]; then + __jolly_make_sep_plug ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + else + __jolly_make_sep_plug ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} + fi + local djc_plug="${jolly_sep}" + + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} + declare -a drs=($detached_sessions $running_jobs $stopped_jobs) # Unquoted on purpose. + if [[ ${#drs[@]} -gt 0 ]] ; then + _lp_join "$jolly_sep" "${drs[@]}" + if [[ -n "$lp_join" ]] ; then + _lp_jolly_make_side+="${djc_plug}${lp_join}" + fi + else + lp_terminal_format ${JOLLY_COLOR_FAIR[@]+"${JOLLY_COLOR_FAIR[@]}"} + _lp_jolly_make_side+="${lp_terminal_format}" + fi + + # Called here for an easy access to the configured color. + if __jolly_activate_shell ; then + _lp_jolly_make_side+="${_JOLLY_SHELL}" + fi + + # clock + if _lp_time ; then + __jolly_make_sep_plug ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + _lp_jolly_make_side+="${jolly_sep}" + if _lp_analog_time ; then + __jolly_make_field "$lp_analog_time" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + _lp_jolly_make_side+="$jolly_field" + else + __jolly_make_field "$lp_time" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + _lp_jolly_make_side+="$jolly_field" + fi + fi +} + +_lp_jolly_make_env() { + #################################################################### + # IN LINE + #################################################################### + + local color_line_end="" + if (( LP_ENABLE_SSH_COLORS )); then + local lp_hostname_hash + __lp_hostname_hash + __lp_foreground_color "$(( 1 + lp_hostname_hash % 6 ))" + color_line_end="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}" + fi + lp_terminal_format ${JOLLY_COLOR_LINE[@]+"${JOLLY_COLOR_LINE[@]}"} + color_line_start="$lp_terminal_format" + _lp_jolly_make_env_inline_left="${NO_COL}$LP_PS1_PREFIX${lp_terminal_format}${JOLLY_LINE}" + + # Dev env section. + local ista="$_LP_FIRST_INDEX" + local imid=$((_LP_FIRST_INDEX+1)) + local iend=$((_LP_FIRST_INDEX+2)) + local d="${color_line_start}${JOLLY_ITEMS[ista]}${JOLLY_SPACE_LINE}" + local I="${color_line_start}${JOLLY_SPACE_LINE}${JOLLY_ITEMS[imid]}${JOLLY_SPACE_LINE}" + local b="${color_line_start}${JOLLY_SPACE_LINE}${JOLLY_ITEMS[iend]}${color_line_end}" + if _lp_env_vars "${LP_COLOR_ENV_VARS_SET}" "${LP_COLOR_ENV_VARS_UNSET}"; then + local lp_join + _lp_join "$I" ${lp_env_vars[@]} + _lp_jolly_make_env_inline_left+="${d}${lp_join}$b" + fi + if _lp_software_collections ; then + _lp_jolly_make_env_inline_left+="${d}sc:${lp_software_collections}$b" + fi + if _lp_python_env ; then + _lp_jolly_make_env_inline_left+="${d}py:${lp_python_env}$b" + fi + if _lp_node_env ; then + _lp_jolly_make_env_inline_left+="${d}node:${lp_node_env}$b" + fi + if _lp_ruby_env ; then + _lp_jolly_make_env_inline_left+="${d}ruby:${lp_ruby_env}$b" + fi + if _lp_container ; then + _lp_jolly_make_env_inline_left+="${d}c:${lp_container}$b" + fi + if _lp_kubernetes_context ; then + _lp_jolly_make_env_inline_left+="${d}kub:${lp_kubernetes_context}$b" + fi + if _lp_terraform_env ; then + _lp_jolly_make_env_inline_left+="${d}tf:${lp_terraform_env}$b" + fi + if _lp_aws_profile ; then + _lp_jolly_make_env_inline_left+="${d}aws:${lp_aws_profile}$b" + fi + if _lp_cmake ; then + local lp_join + _lp_join "$I" ${lp_cmake_c_compiler} ${lp_cmake_cxx_compiler} ${lp_cmake_generator} ${lp_cmake_buildtype} + _lp_jolly_make_env_inline_left+="$d${lp_join}$b" + fi + if _lp_modules; then + _lp_jolly_make_env_inline_left+="$d" + _lp_join "$I" "${lp_modules[@]}" + _lp_jolly_make_env_inline_left+="${lp_join}$b" + fi + + # History section. + _lp_jolly_make_env_inline_right= + if _lp_os; then + _lp_join "$I" ${lp_os_arch} ${lp_os_family} ${lp_os_kernel} ${lp_os_distrib} ${lp_os_version} + _lp_jolly_make_env_inline_right+="$d${lp_join}$b" + fi + if ((JOLLY_ENABLE_HISTORY)) ; then + local hist_max + hist_max=$((JOLLY_HISTORY_LAST_LEN-${#JOLLY_HISTORY_LAST_LEN_MARK})) + local hist_last + hist_last=$(history | tail -n 1 | cut -d" " -f5-) + if [[ ${#hist_last} -gt $hist_max ]] ; then + if (( _LP_SHELL_zsh )) ; then + hist_last="${hist_last[1,$hist_max]}${JOLLY_HISTORY_LAST_LEN_MARK}" + else # bash + hist_last="${hist_last:0:$hist_max}${JOLLY_HISTORY_LAST_LEN_MARK}" + fi + fi + local hist_most + hist_most=$(history | tail -n "${JOLLY_HISTORY_MOST_BACK}" | awk '{print $4}' | sort | uniq --count | sort --numeric-sort --reverse | head -n 1 | awk '{print $2}') + __lp_escape "$hist_last" + local hlast="$ret" + __lp_escape "$hist_most" + local hmost="$ret" + _lp_jolly_make_env_inline_right="$d${hlast}$I${hmost}$b" + fi +} + +_lp_jolly_make_vcs() { + + _lp_jolly_make_vcs="" + lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + + if (( LP_ENABLE_WIFI_STRENGTH )) ; then + if _lp_wifi_signal_strength ; then + lp_terminal_format ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + _lp_jolly_make_vcs+="${lp_terminal_format}${LP_MARK_WIFI}" + else + _lp_jolly_make_vcs+="${lp_terminal_format}${LP_MARK_WIFI}" + fi + else + _lp_jolly_make_vcs+="${lp_terminal_format}·" + fi + + if _lp_http_proxy ; then + __jolly_make_sep_link ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _lp_jolly_make_vcs+="${jolly_sep}" + else + __jolly_make_sep_plug ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _lp_jolly_make_vcs+="${jolly_sep}" + fi + + if __jolly_prompt_vcs; then + _lp_jolly_make_vcs+="${_JOLLY_VCS}" + fi +} + +_lp_jolly_make_input() { + #################################################################### + # PROMPT LINE + #################################################################### + _lp_jolly_make_input= + + if _lp_runtime_format ; then + __jolly_make_sep_plug ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} + __jolly_make_field "${lp_runtime_format}" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} + _lp_jolly_make_input+="${jolly_sep}${jolly_field}" + fi + + if _lp_error ; then + local error_msg= + if _lp_error_meaning; then + error_msg="${lp_error_meaning}" + else + error_msg="${lp_error}" + fi + __jolly_make_sep_link ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + __jolly_make_field "${JOLLY_MARK_ERROR}${JOLLY_SPACE_VOID}${error_msg}" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + _lp_jolly_make_input+="${jolly_sep}${jolly_field}" + fi + + __jolly_make_sep_plug ${JOLLY_COLOR_MARK[@]+"${JOLLY_COLOR_MARK[@]}"} + _lp_jolly_make_input+="${jolly_sep}" + lp_terminal_format ${JOLLY_COLOR_MARK[@]+"${JOLLY_COLOR_MARK[@]}"} + local mark_color="$lp_terminal_format" + + # No need to check LP_ENABLE_SHLVL, _lp_shell_level does it. + if _lp_shell_level ; then + local i + for ((i=0; i < lp_shell_level-1; i++)); do + _lp_jolly_make_input+="${mark_color}${JOLLY_MARK}" + done + fi + + # Warning _lp_jolly_make_input mark if either root or sudo. + _lp_user + user="$?" + # No need to check LP_ENABLE_SUDO, _lp_sudo_active does it. + _lp_sudo_active + sudo="$?" + if [[ "$sudo" == 0 || "$user" == 2 ]] ; then + local dcwfg="${JOLLY_COLOR_WARN[_LP_FIRST_INDEX+1]}" + [[ -z $dcwfg ]] && dcwfg=-1 + lp_terminal_format $dcwfg + _lp_jolly_make_input+="${lp_terminal_format}${JOLLY_MARK_SUDO}${JOLLY_MARK}" + else + _lp_jolly_make_input+="${mark_color}${JOLLY_MARK}" + fi + + _lp_jolly_make_input+="${NO_COL}" +} + +_lp_jolly_theme_prompt() { + + local header side inline jolly_prompt + + _lp_jolly_make_header + header+="$_lp_jolly_make_header" + + _lp_jolly_make_side + side="$_lp_jolly_make_side" + + # header/side assembling + if _lp_dirstack; then + lp_terminal_format ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + else + # Recall a dark format to correctly reset sections history + # to match the path's section colors. + lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + fi + + __jolly_make_sep_last "$_lp_jolly_has_warns" "$_lp_jolly_has_notes" + header+="$jolly_sep" + + # Right-align the $side with spaces. + _lp_fill "$header$NO_COL" "$side" " " + header="$lp_fill${NO_COL}" + + _lp_jolly_make_env + local inline_left="$_lp_jolly_make_env_inline_left" + local inline_right="$_lp_jolly_make_env_inline_right" + + _lp_jolly_inline_right+="${JOLLY_LINE}" + + inline= + # FIXME deprecated + # # FIXME use _lp_fill-like function to handle multi-character line? + # if ((JOLLY_ENABLE_GRADIENT_LINE)); then + # # Fill up the center section with a line colored as a gradient. + # local ret + # __lp_strip_escapes "$_lp_jolly_make_env_inline_left" + # local left_as_text="$ret" + # local line_width=$((${COLUMNS:-80}-${#left_as_text})) + + # local line="$_lp_jolly_make_env" + # local i c f a b j + # for ((i=0; i < line_width; i++)); do # For each character in the line. + # local dash_colors=() + # for ((c=_LP_FIRST_INDEX; c < 6+_LP_FIRST_INDEX; c++)); do # For each color parameter. + # a="${JOLLY_COLOR_LINE_START[c]}" + # b="${JOLLY_COLOR_LINE_END[c]}" + # j=$((a+(b-a)*i/line_width)) + # dash_colors+=("$j") + # done + # lp_terminal_format "${dash_colors[@]}" + # line+="${lp_terminal_format}${JOLLY_LINE}" + # # line+="${lp_terminal_format}${i}(${dash_colors[@]}) " + # done + + # _lp_jolly_make_env="${line}${NO_COL}" + + # else + # Fill up the remaining space with a fixed-color line. + _lp_fill "$inline_left" "$inline_right" "$JOLLY_LINE" + # Format here is JOLLY_COLOR_LINE. + inline="${lp_terminal_format}${lp_fill}${NO_COL}" + # fi + + _lp_jolly_make_vcs + jolly_prompt="$_lp_jolly_make_vcs" + + _lp_jolly_make_input + jolly_prompt+="$_lp_jolly_make_input" + + # Assemble and setup + local n=$'\n' + PS1="${n}${header}${n}${inline}${n}${jolly_prompt} " +} + + + +######################################################################## +# DotVector theme +######################################################################## + +_lp_dotvector_theme_activate() { + _lp_jolly_theme_activate +} + +_lp_dotvector_theme_directory() { + _lp_jolly_theme_directory +} + +_lp_dotvector_theme_prompt() { + local header side inline input vcs main + + _lp_jolly_make_header + header+="$_lp_jolly_make_header" + + _lp_jolly_make_side + side="$_lp_jolly_make_side" + + # header/side assembling + if _lp_dirstack; then + lp_terminal_format ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + else + # Recall a dark format to correctly reset sections history + # to match the path's section colors. + lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + fi + + __jolly_make_sep_last "$_lp_jolly_has_warns" "$_lp_jolly_has_notes" + header+="$jolly_sep" + + _lp_jolly_make_vcs + + lp_terminal_format -3 -1 + local last_color="$lp_terminal_format" + + lp_terminal_format ${JOLLY_COLOR_LINE[@]} + local line_color="$lp_terminal_format" + lp_terminal_format ${JOLLY_COLOR_LITE[_LP_FIRST_INDEX+0]} -1 0 0 + local before="${line_color}${JOLLY_LINE}${lp_terminal_format}${JOLLY_LINK[_LP_FIRST_INDEX+2]}" + + local after="${JOLLY_SPACE_VOID}${last_color}${JOLLY_LINK_R[_LP_FIRST_INDEX+0]}" + + vcs="${before}${_lp_jolly_make_vcs}${after}" + + # Right-align the $side with spaces. + # _lp_fill "$header$NO_COL" "$side" " " + # header="$lp_fill${NO_COL}" + + _lp_jolly_make_env + local inline_left="$_lp_jolly_make_env_inline_left" + local inline_right="$_lp_jolly_make_env_inline_right" + + _lp_jolly_inline_right+="${JOLLY_LINE}" + + _lp_fill "${header}${vcs}${inline_left}" "${inline_right}${side}" "$JOLLY_LINE" + main="${lp_terminal_format}${lp_fill}${NO_COL}" + + lp_terminal_format ${JOLLY_COLOR_LITE[@]} + local start="${lp_terminal_format}" + + _lp_jolly_make_input + input="$start$_lp_jolly_make_input" + + # Assemble and setup + local n=$'\n' + PS1="${n}${main}${n}${input} " +} + + +######################################################################## +# Functions called at "activate" stage. +######################################################################## + +__jolly_activate_display() { + if _lp_connected_display ; then + __jolly_make_field "$JOLLY_DISPLAY_X11" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _JOLLY_DISPLAY="$jolly_field" + else + __jolly_make_field "$JOLLY_DISPLAY_TEXT" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + _JOLLY_DISPLAY="$jolly_field" + fi +} + +__jolly_activate_shell() { + ((JOLLY_ENABLE_SHELL)) || return 2 + + if ((_LP_SHELL_zsh)) ; then + __jolly_make_sep_plug ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + __jolly_make_field "$JOLLY_SHELL_ZSH" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + _JOLLY_SHELL="${jolly_sep}${jolly_field}" + else + __jolly_make_sep_plug ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + __jolly_make_field "$JOLLY_SHELL_BASH" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _JOLLY_SHELL="${jolly_sep}${jolly_field}" + fi +} + + +__jolly_activate_connection() { + _lp_user + user_type="$?" + local user_color + case "$user_type" in + 0) # logged-in user + user_color=(${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}) + ;; + 1) # other user + user_color=(${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}) + ;; + 2) # root + user_color=(${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}) + ;; + esac + + + local connection + _lp_connection + case "$lp_connection" in + lcl) + __jolly_make_sep_plug "${user_color[@]}" + connection="${jolly_sep}" + ;; + su) + __jolly_make_sep_link "${user_color[@]}" + connection="${jolly_sep}" + ;; + ssh) + __jolly_make_sep_open "${user_color[@]}" + connection="${jolly_sep}" + ;; + tel) + __jolly_make_sep_dang "${user_color[@]}" + connection="${jolly_sep}" + ;; + *) + __jolly_make_sep_plug "${user_color[@]}" + connection="${jolly_sep}" + ;; + esac + + _JOLLY_CONNECTION="${connection}" +} + + +__jolly_activate_user() { + _lp_user + user_type="$?" + case "$user_type" in + 0) # logged-in user + if [[ -z $lp_username ]] ; then # Honors LP_USER_ALWAYS + __jolly_make_field "$JOLLY_USER_LOCAL" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + _JOLLY_USER="$jolly_field" + else + __jolly_make_field "$lp_username" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + _JOLLY_USER="$jolly_field" + fi + ;; + 1) # other user + _lp_username_color + __jolly_make_field "$lp_username_color" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} + _JOLLY_USER="$jolly_field" + ;; + 2) # root + _lp_username + __jolly_make_field "$lp_username" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} + _JOLLY_USER="$jolly_field" + ;; + esac + return $user_type +} + + +__jolly_activate_hostname() { + local hostname= + if _lp_hostname; then + case "$lp_connection" in + ssh) + hostname="$lp_hostname" + local client_ip client_port server_ip server_port + IFS=" " read -r client_ip client_port server_ip server_port <<<"$SSH_CONNECTION" + local username=${USER:-${USERNAME:-${LOGNAME-}}} + if _lp_create_link "ssh://${username}@${server_ip}:${server_port}" "$hostname"; then + hostname="$link" + else + hostname="$hostname" + fi + # If we want a different color for each host + if (( LP_ENABLE_SSH_COLORS )); then + LP_COLOR_SSH="$LP_COLOR_HOST_HASH" + hostname="${LP_COLOR_SSH}${hostname}" + else + hostname="${hostname}" + fi + ;; + tel) + hostname="${lp_hostname}" + ;; + *) + hostname+="${JOLLY_HOST_LOCAL}" + ;; + esac + else + hostname="${JOLLY_HOST_LOCAL}" + fi + + if __jolly_make_field "$hostname" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} ; then + _JOLLY_HOSTNAME="${jolly_field}" + else + if __jolly_make_field "$lp_hostname" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} ; then + _JOLLY_HOSTNAME="${jolly_field}" + else + _JOLLY_HOSTNAME="${lp_hostname}" + fi + fi +} + + +__jolly_activate_multiplexer() { + local lp_multiplexer multiplexer + if _lp_multiplexer ; then + case "$lp_multiplexer" in + tmux) + __jolly_make_sep_link ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + multiplexer="${jolly_sep}" + ;; + screen) + __jolly_make_sep_link ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + multiplexer="${jolly_sep}" + ;; + *) + __jolly_make_sep_link ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + multiplexer="${jolly_sep}" + ;; + esac + else + __jolly_make_sep_plug ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + multiplexer="${jolly_sep}" + fi + + _JOLLY_MULTIPLEXER="${multiplexer}" +} + + +######################################################################## +# Functions called at directory change. +######################################################################## + +__jolly_directory_FS() { + local fs= + if (( LP_ENABLE_PERM )); then + if _lp_chroot ; then + if [[ -w "$PWD" ]]; then + __jolly_make_sep_open ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + fs="$jolly_sep" + else + __jolly_make_sep_dang ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + fs="$jolly_sep" + fi + else + if [[ -w "$PWD" ]]; then + __jolly_make_sep_plug ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + fs="$jolly_sep" + else + __jolly_make_sep_link ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + fs="$jolly_sep" + fi + fi + fi + _JOLLY_FS="$fs" +} + + +__jolly_directory_path() { + local lp_terminal_format + + lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + local path_format="${lp_terminal_format}" + + lp_terminal_format ${JOLLY_COLOR_SEP_DARK[@]+"${JOLLY_COLOR_SEP_DARK[@]}"} + local separator_format=$lp_terminal_format + + lp_terminal_format ${JOLLY_COLOR_PATH_SHORT[@]+"${JOLLY_COLOR_PATH_SHORT[@]}"} + local shortened_format=$lp_terminal_format + + lp_terminal_format ${JOLLY_COLOR_PATH_VCS[@]+"${JOLLY_COLOR_PATH_VCS[@]}"} + local vcs_format=$lp_terminal_format + + lp_terminal_format ${JOLLY_COLOR_PATH_LAST[@]+"${JOLLY_COLOR_PATH_LAST[@]}"} + local last_dir_format=$lp_terminal_format + + local lp_path_format + _lp_path_format "$path_format" "$last_dir_format" "$vcs_format" "$shortened_format" \ + "${JOLLY_SPACE_PATH}${JOLLY_SOFT}${JOLLY_SPACE_PATH}" "$separator_format" + + _JOLLY_PATH=${lp_path_format} +} + + +######################################################################## +# Functions called at jolly_prompt update. +######################################################################## + +__jolly_prompt_vcs() { + if _lp_find_vcs ; then + declare -a color color_behind color_ahead + + _lp_smart_mark + + _JOLLY_VCS="" + + # Mark & commits off remote + if _lp_vcs_commits_off_remote; then # There is remote-space-[local]. + _lp_vcs_remote # Get remote name. + if [[ "$lp_vcs_remote" == "origin" ]]; then + lp_vcs_remote="$JOLLY_VCS_REMOTE_ORIGIN" + fi + + # Remote segment. + if [[ "$lp_vcs_commit_behind" -ne "0" ]]; then # NOTE remote segment. + if [[ "$lp_vcs_commit_behind" -ge "${JOLLY_VCS_BEHIND_THRESHOLD}" ]]; then + color_behind=(${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}) + else + color_behind=(${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}) + fi + if (( LP_ENABLE_VCS_DIFFSTATS )) ; then + __jolly_make_field "${lp_smart_mark}" "${color_behind[@]}" + _JOLLY_VCS+="$jolly_field" + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} + _JOLLY_VCS+="$jolly_sep" + __jolly_make_field "${lp_vcs_remote} ${lp_vcs_commit_behind}" "${color_behind[@]}" + _JOLLY_VCS+="$jolly_field" + else + __jolly_make_field "${lp_smart_mark}" "${color_behind[@]}" + _JOLLY_VCS+="$jolly_field" + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} + _JOLLY_VCS+="$jolly_sep" + __jolly_make_field "${lp_vcs_remote} ${JOLLY_DIFF}" "${color_behind[@]}" + _JOLLY_VCS+="$jolly_field" + fi + + else # LITE remote segment. + __jolly_make_field "${lp_smart_mark}" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _JOLLY_VCS+="$jolly_field" + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} + _JOLLY_VCS+="$jolly_sep" + __jolly_make_field "${lp_vcs_remote}" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _JOLLY_VCS+="$jolly_field" + fi + + # Link between remote and local. + # We already have `color_behind`. + if [[ "$lp_vcs_commit_ahead" -ne "0" ]]; then # NOTE local segment. + if [[ "$lp_vcs_commit_ahead" -ge "${JOLLY_VCS_AHEAD_THRESHOLD}" ]]; then + color_ahead=(${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}) + else + color_ahead=(${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}) + fi + else # No commit ahead. + color_ahead=(${JOLLY_COLOR_GLOW[@]+"${JOLLY_COLOR_GLOW[@]}"}) + fi + + # Choice of link type. + # Both remote and local have commits. + if [[ "$lp_vcs_commit_behind" -ne "0" && "$lp_vcs_commit_ahead" -ne "0" ]]; then + __jolly_make_sep_link_opposed "${color_ahead[@]}" + # Only remote have commit. + elif [[ "$lp_vcs_commit_behind" -ne "0" && "$lp_vcs_commit_ahead" -eq "0" ]]; then + __jolly_make_sep_link_reverse "${color_ahead[@]}" + # Only local have commits. + else + __jolly_make_sep_link "${color_ahead[@]}" + fi + _JOLLY_VCS+="$jolly_sep" + + # Local segment. + if [[ "$lp_vcs_commit_ahead" -ne "0" ]]; then # NOTE local segment. + # We already have `color_ahead`. + if (( LP_ENABLE_VCS_DIFFSTATS )) ; then + __jolly_make_field "$lp_vcs_commit_ahead" "${color_ahead[@]}" + _JOLLY_VCS+="$jolly_field" + else + __jolly_make_field "$JOLLY_DIFF" "${color_ahead[@]}" + _JOLLY_VCS+="$jolly_field" + fi + __jolly_make_sep_plug ${JOLLY_COLOR_GLOW[@]+"${JOLLY_COLOR_GLOW[@]}"} + _JOLLY_VCS+="$jolly_sep" + # else # 0 commit ahead => direct segment. + fi + + else # No commits off remote => There is no space between remote and branch, and no remote name. + __jolly_make_field "${lp_smart_mark}" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _JOLLY_VCS+="$jolly_field" + __jolly_make_sep_plug ${JOLLY_COLOR_GLOW[@]+"${JOLLY_COLOR_GLOW[@]}"} + _JOLLY_VCS+="$jolly_sep" + # No local commit segment. + fi + + # Branch:bookmark/tag + if _lp_vcs_branch; then + __jolly_make_field "$lp_vcs_branch" ${JOLLY_COLOR_GLOW[@]+"${JOLLY_COLOR_GLOW[@]}"} + _JOLLY_VCS+="$jolly_field" + + if _lp_vcs_bookmark; then + __jolly_make_field ":${lp_vcs_bookmark}" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + _JOLLY_VCS+="$jolly_field" + fi + if _lp_vcs_tag; then + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_DARK[@]+"${JOLLY_COLOR_SEP_DARK[@]}"} + __jolly_make_field "$lp_vcs_tag" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} + _JOLLY_VCS+="${jolly_sep}${jolly_field}" + fi + + elif _lp_vcs_bookmark; then + __jolly_make_field "$lp_vcs_bookmark" ${JOLLY_COLOR_GLOW[@]+"${JOLLY_COLOR_GLOW[@]}"} + _JOLLY_VCS+="$jolly_field" + elif _lp_vcs_tag; then + __jolly_make_field "$lp_vcs_tag" ${JOLLY_COLOR_GLOW[@]+"${JOLLY_COLOR_GLOW[@]}"} + _JOLLY_VCS+="$jolly_field" + else + _lp_vcs_commit_id + __jolly_make_field "${lp_vcs_commit_id:0:7}" ${JOLLY_COLOR_GLOW[@]+"${JOLLY_COLOR_GLOW[@]}"} + _JOLLY_VCS+="$jolly_field" + fi # vcs branch + + # Diff stats + local ret has_lines= + if _lp_vcs_uncommitted_files; then + _lp_vcs_unstaged_lines; ret=$? + _lp_vcs_uncommitted_lines + if [[ $((ret+lp_vcs_uncommitted_i_lines+lp_vcs_uncommitted_d_lines)) -gt "${JOLLY_VCS_DIFF_THRESHOLD}" ]]; then + color=(${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}) + else + color=(${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}) + fi + __jolly_make_sep_link "${color[@]}" + _JOLLY_VCS+="$jolly_sep" + + # Only show unstaged changes if the VCS supports staging, otherwise + # show uncommitted changes + if (( ret == 0 )); then + if [[ "$lp_vcs_unstaged_i_lines" == "$lp_vcs_unstaged_d_lines" ]] ; then + # If same number of lines inserted and deleted: display a single number. + __jolly_make_field "±$lp_vcs_unstaged_i_lines" "${color[@]}" + has_lines="$jolly_field" + else + __jolly_make_field "+$lp_vcs_unstaged_i_lines" "${color[@]}" + has_lines="$jolly_field" + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} + has_lines+="$jolly_sep" + __jolly_make_field "-$lp_vcs_unstaged_d_lines" "${color[@]}" + has_lines+="$jolly_field" + fi + + elif (( ret == 1 )); then + # Maybe just removed a file, in which case no line is reported to be impacted, + # but this is still a change. + __jolly_make_field "±0" ${JOLLY_COLOR_DARK[@]+"${color[@]}"} + has_lines="${jolly_field}" + else + if [[ "$lp_vcs_uncommitted_i_lines" == "$lp_vcs_uncommitted_d_lines" ]] ; then + __jolly_make_field "±$lp_vcs_uncommitted_i_lines" "${color[@]}" + has_lines="$jolly_field" + else + __jolly_make_field "+$lp_vcs_uncommitted_i_lines" "${color[@]}" + has_lines="$jolly_field" + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} + has_lines+="$jolly_sep" + __jolly_make_field "-$lp_vcs_uncommitted_d_lines" "${color[@]}" + has_lines+="$jolly_field" + fi + fi + if (( LP_ENABLE_VCS_DIFFSTATS )) ; then + _JOLLY_VCS+="$has_lines" + else + __jolly_make_field "$JOLLY_DIFF" "${color[@]}" + _JOLLY_VCS+="$jolly_field" + fi # LP_ENABLE_VCS_DIFFSTATS + fi # uncommitted files + + # Stash / untracked / head + local stash="" untracked="" head="" + if _lp_vcs_stash_count; then + stash="$JOLLY_MARK_STASH" + fi + if _lp_vcs_untracked_files; then + untracked="$JOLLY_MARK_UNTRACKED" + fi + if _lp_vcs_head_status; then + head="$lp_vcs_head_status" + # if [[ -n "${lp_vcs_head_details-}" ]]; then + # pass + # fi + fi + if [[ -n "$stash" || -n "$untracked" || -n "$head" ]] ; then + __jolly_make_sep_plug ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _JOLLY_VCS+="$jolly_sep" + fi + + if [[ -n "$stash" ]] ; then + __jolly_make_field "$stash" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _JOLLY_VCS+="$jolly_field" + if [[ -n "$untracked" ]] ; then + __jolly_make_field "$untracked" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} + _JOLLY_VCS+="${jolly_sep}${jolly_field}" + fi + if [[ -n "$head" ]] ; then + __jolly_make_field "$head" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} + _JOLLY_VCS+="${jolly_sep}${jolly_field}" + fi + else # no stash + if [[ -n "$untracked" ]] ; then + __jolly_make_field "$untracked" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _JOLLY_VCS+="$jolly_field" + if [[ -n "$head" ]] ; then + __jolly_make_field "$head" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + __jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} + _JOLLY_VCS+="${jolly_sep}${jolly_field}" + fi + else # no untracked + if [[ -n "$head" ]] ; then + __jolly_make_field "$head" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} + _JOLLY_VCS+="$jolly_field" + fi + fi + fi # stash + return 0 + else + _JOLLY_VCS="" + return 1 + fi # find_vcs +} + +######################################################################## +# Helper functions +######################################################################## + +__jolly_join_fields() { + jolly_join_fields="" + local sep="${1-}" + shift + if [[ -n "$*" ]] ; then + local first_field="${1-}" + shift + jolly_join_fields="${first_field}" + for f in "$@"; do + [[ -z $f ]] && continue + jolly_join_fields+="${sep}${f}" + done + fi +} + +__jolly_make_field() { # string, color_array + local string="${1-}" + local lp_terminal_format + [[ -z $string ]] && return 1 + + shift + lp_terminal_format "$@" + + jolly_field="${lp_terminal_format}${JOLLY_SPACE_FIELD}${string}${JOLLY_SPACE_FIELD}" +} + +__jolly_make_sep_plug() { # color + # fg, bg, bold, underline, fallback_fg, fallback_bg + # 0 = set last color to current color + # -1 = set color to last color + # -2 = keep last color + # -3 = set last fg to last bg (and conversely) + local lp_terminal_format sep + + local bg="${2-}" + [[ -z $bg ]] && bg=-1 + local fbg="${6-}" + [[ -z $fbg ]] && fbg=-1 + + sep="${JOLLY_PLUG}" + if [[ "${_lp_last_ab_color-}" == "$bg" ]] ; then + sep="${JOLLY_MEAN}" + fi + + lp_terminal_format -3 "$bg" 0 0 -3 "$fbg" + jolly_sep="${JOLLY_SPACE_VOID}${lp_terminal_format}${sep}${JOLLY_SPACE_VOID}" +} + +__jolly_make_sep_link() { # color + local lp_terminal_format + jolly_sep="" + + local fg="${2-}" + [[ -z $fg ]] && fg=-1 + local fbg="${6-}" + [[ -z $fbg ]] && fbg=-1 + + lp_terminal_format -3 -1 0 0 -1 "$fbg" + jolly_sep+="${JOLLY_SPACE_VOID}${lp_terminal_format}${JOLLY_LINK[_LP_FIRST_INDEX]}" + + local dsfg="${JOLLY_COLOR_SEP_FAIR[_LP_FIRST_INDEX]}" + [[ -z $dsfg ]] && dsfg=-1 + lp_terminal_format "$dsfg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_LINK[_LP_FIRST_INDEX+1]}" + + lp_terminal_format "$fg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_LINK[_LP_FIRST_INDEX+2]}${JOLLY_SPACE_FILL}" +} + +__jolly_make_sep_link_reverse() { # color + local lp_terminal_format + jolly_sep="" + + local fg="${2-}" + [[ -z $fg ]] && fg=-1 + local fbg="${6-}" + [[ -z $fbg ]] && fbg=-1 + + lp_terminal_format -3 -1 0 0 -1 "$fbg" + jolly_sep+="${JOLLY_SPACE_VOID}${lp_terminal_format}${JOLLY_LINK_R[_LP_FIRST_INDEX]}" + + local dsfg="${JOLLY_COLOR_SEP_FAIR[_LP_FIRST_INDEX]}" + [[ -z $dsfg ]] && dsfg=-1 + lp_terminal_format "$dsfg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_LINK_R[_LP_FIRST_INDEX+1]}" + + lp_terminal_format "$fg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_LINK_R[_LP_FIRST_INDEX+2]}${JOLLY_SPACE_FILL}" +} + +__jolly_make_sep_link_opposed() { # color + local lp_terminal_format + jolly_sep="" + + local fg="${2-}" + [[ -z $fg ]] && fg=-1 + local fbg="${6-}" + [[ -z $fbg ]] && fbg=-1 + + lp_terminal_format -3 -1 0 0 -1 "$fbg" + jolly_sep+="${JOLLY_SPACE_VOID}${lp_terminal_format}${JOLLY_LINK_R[_LP_FIRST_INDEX]}" + + local dsfg="${JOLLY_COLOR_SEP_FAIR[_LP_FIRST_INDEX]}" + [[ -z $dsfg ]] && dsfg=-1 + lp_terminal_format "$dsfg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_LINK[_LP_FIRST_INDEX+1]}" + + lp_terminal_format "$fg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_LINK[_LP_FIRST_INDEX+2]}${JOLLY_SPACE_FILL}" +} + + +__jolly_make_sep_open() { # color + local lp_terminal_format + + local fg="${2-}" + [[ -z $fg ]] && fg=-1 + local fbg="${6-}" + [[ -z $fbg ]] && fbg=-1 + + lp_terminal_format -3 -1 0 0 -1 "$fbg" + jolly_sep+="${JOLLY_SPACE_VOID}${lp_terminal_format}${JOLLY_OPEN[_LP_FIRST_INDEX]}" + + local dsfg="${JOLLY_COLOR_SEP_FAIR[_LP_FIRST_INDEX]}" + [[ -z $dsfg ]] && dsfg=-1 + lp_terminal_format "$dsfg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_OPEN[_LP_FIRST_INDEX+1]}" + + lp_terminal_format "$fg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_OPEN[_LP_FIRST_INDEX+2]}${JOLLY_SPACE_FILL}" +} + +__jolly_make_sep_dang() { # color + local lp_terminal_format + + local fg="${2-}" + [[ -z $fg ]] && fg=-1 + local fbg="${6-}" + [[ -z $fbg ]] && fbg=-1 + + lp_terminal_format -3 -1 0 0 -1 "$fbg" + jolly_sep+="${JOLLY_SPACE_VOID}${lp_terminal_format}${JOLLY_DANG[_LP_FIRST_INDEX]}" + + local dcwfg="${JOLLY_COLOR_WARN[_LP_FIRST_INDEX+1]}" + [[ -z $dcwfg ]] && dcwfg=-1 + lp_terminal_format "$dcwfg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_DANG[_LP_FIRST_INDEX+1]}" + + lp_terminal_format "$fg" -1 0 0 -1 "$fbg" + jolly_sep+="${lp_terminal_format}${JOLLY_DANG[_LP_FIRST_INDEX+2]}${JOLLY_SPACE_FILL}" +} + +__jolly_make_sep_soft() { # color + local lp_terminal_format + + local fg="${1-}" + [[ -z $fg ]] && fg=-1 + local fbg="${5-}" + [[ -z $fbg ]] && fbg=-1 + + lp_terminal_format "$fg" -2 0 0 "$fbg" + jolly_sep="${lp_terminal_format}${JOLLY_SOFT}" +} + +__jolly_make_sep_mid() { # color + local lp_terminal_format + + local fg="${1-}" + [[ -z $fg ]] && fg=-1 + local fbg="${5-}" + [[ -z $fbg ]] && fbg=-1 + + lp_terminal_format "$fg" -2 0 0 "$fbg" + jolly_sep="${lp_terminal_format}${JOLLY_SPACE_VOID}${JOLLY_MEAN}${JOLLY_SPACE_VOID}" +} + +__jolly_make_sep_last() { # [has_warns [has_notes]] + local lp_terminal_format + local has_warns="${1:-0}" + local has_notes="${2:-0}" + lp_terminal_format -3 -1 0 0 -3 -1 + jolly_sep="${lp_terminal_format}${JOLLY_ENDS[_LP_FIRST_INDEX+0]}${NO_COL}" + if [[ $has_warns -eq 0 && $has_notes -gt 0 ]] ; then + # Use the background of COLOR_NOTE as a foreground here. + lp_terminal_format "${JOLLY_COLOR_NOTE[1]}" + jolly_sep+="${lp_terminal_format}${JOLLY_ENDS[_LP_FIRST_INDEX+1]}${NO_COL}" + else + if [[ $has_warns -gt 0 ]]; then + # Use the background of COLOR_WARN as a foreground here. + lp_terminal_format "${JOLLY_COLOR_WARN[1]}" + jolly_sep+="${lp_terminal_format}${JOLLY_ENDS[_LP_FIRST_INDEX+1]}${JOLLY_ENDS[_LP_FIRST_INDEX+1]}${NO_COL}" + else + jolly_sep="${lp_terminal_format}${JOLLY_ENDS[_LP_FIRST_INDEX+0]}${NO_COL}" + fi + fi +} + +__jolly_make_sep_side() { # no arg + local lp_terminal_format + lp_terminal_format -3 -1 0 0 -3 -1 # Reset to no background. + local dsf=(${JOLLY_COLOR_SEP_FAIR[@]+"${JOLLY_COLOR_SEP_FAIR[@]}"}) + [[ -z "${dsf[*]}" ]] && dsf=(-1) + lp_terminal_format "${dsf[@]}" + jolly_sep="${lp_terminal_format}${JOLLY_ENDS[_LP_FIRST_INDEX+2]}" +} + diff --git a/liquidprompt_dotmatrix_design.png b/liquidprompt_jolly_design.png similarity index 100% rename from liquidprompt_dotmatrix_design.png rename to liquidprompt_jolly_design.png diff --git a/presets/colors-all-blues.conf b/presets/colors-all-blues.conf index b68b839..01aebc2 100644 --- a/presets/colors-all-blues.conf +++ b/presets/colors-all-blues.conf @@ -4,23 +4,23 @@ li=75 fa=27 # Color arrays defaults: fg bg b u ffg fbg -DOTMATRIX_COLOR_DARK=( 153 $da 0 0 15 0) -DOTMATRIX_COLOR_LITE=( 21 $li 0 0 0 15) -DOTMATRIX_COLOR_GLOW=( 0 $li 0 0 0 15) -DOTMATRIX_COLOR_NOTE=( 15 24 1 0 15 4) -DOTMATRIX_COLOR_WARN=( 0 135 1 0 9 11) -DOTMATRIX_COLOR_FAIR=( 0 $li 1 0 0 8) +JOLLY_COLOR_DARK=( 153 $da 0 0 15 0) +JOLLY_COLOR_LITE=( 21 $li 0 0 0 15) +JOLLY_COLOR_GLOW=( 0 $li 0 0 0 15) +JOLLY_COLOR_NOTE=( 15 24 1 0 15 4) +JOLLY_COLOR_WARN=( 0 135 1 0 9 11) +JOLLY_COLOR_FAIR=( 0 $li 1 0 0 8) -DOTMATRIX_COLOR_PATH_SHORT=( 15 $da 0 0 0 15) -DOTMATRIX_COLOR_PATH_VCS=( 15 $da 0 1 0 15) -DOTMATRIX_COLOR_PATH_LAST=( 15 $da 1 0 0 15) +JOLLY_COLOR_PATH_SHORT=( 15 $da 0 0 0 15) +JOLLY_COLOR_PATH_VCS=( 15 $da 0 1 0 15) +JOLLY_COLOR_PATH_LAST=( 15 $da 1 0 0 15) -DOTMATRIX_COLOR_LINE=($fa -1 0 0 7 -1) -DOTMATRIX_COLOR_LINE_START=($fa -1 1 0 7 -1) -DOTMATRIX_COLOR_LINE_END=( $fa -1 1 0 7 -1) +JOLLY_COLOR_LINE=($fa -1 0 0 7 -1) +JOLLY_COLOR_LINE_START=($fa -1 1 0 7 -1) +JOLLY_COLOR_LINE_END=( $fa -1 1 0 7 -1) -DOTMATRIX_COLOR_MARK=(15 -1 0 0 15 -1) -DOTMATRIX_COLOR_SEP_DARK=( 0 -2 0 0 15 -2) -DOTMATRIX_COLOR_SEP_FAIR=( 0 -2 0 0 0 -2) -DOTMATRIX_COLOR_SEP_LITE=( $li -2 0 0 15 -2) +JOLLY_COLOR_MARK=(15 -1 0 0 15 -1) +JOLLY_COLOR_SEP_DARK=( 0 -2 0 0 15 -2) +JOLLY_COLOR_SEP_FAIR=( 0 -2 0 0 0 -2) +JOLLY_COLOR_SEP_LITE=( $li -2 0 0 15 -2) diff --git a/presets/colors-cyan-magenta.conf b/presets/colors-cyan-magenta.conf index b9bbc2b..31ce875 100644 --- a/presets/colors-cyan-magenta.conf +++ b/presets/colors-cyan-magenta.conf @@ -1,4 +1,4 @@ -DOTMATRIX_COLOR_NOTE=( 15 30 0 0 15 2) -DOTMATRIX_COLOR_WARN=(231 128 1 0 0 9) +JOLLY_COLOR_NOTE=( 15 30 0 0 15 2) +JOLLY_COLOR_WARN=(231 128 1 0 0 9) diff --git a/presets/colors-green-red.conf b/presets/colors-green-red.conf index c9f96fe..af73d06 100644 --- a/presets/colors-green-red.conf +++ b/presets/colors-green-red.conf @@ -1,4 +1,4 @@ -DOTMATRIX_COLOR_NOTE=( 15 28 0 0 15 2) -DOTMATRIX_COLOR_WARN=(220 160 1 0 0 9) +JOLLY_COLOR_NOTE=( 15 28 0 0 15 2) +JOLLY_COLOR_WARN=(220 160 1 0 0 9) diff --git a/presets/colors-high-contrast.conf b/presets/colors-high-contrast.conf index b45db0e..2689bb0 100644 --- a/presets/colors-high-contrast.conf +++ b/presets/colors-high-contrast.conf @@ -3,23 +3,23 @@ da=238 li=254 # Color arrays defaults: fg bg b u ffg fbg -DOTMATRIX_COLOR_DARK=( $li $da 0 0 15 0) -DOTMATRIX_COLOR_LITE=( $da $li 0 0 0 15) -DOTMATRIX_COLOR_GLOW=( 0 $li 0 0 0 15) -DOTMATRIX_COLOR_NOTE=( 0 27 1 1 15 4) -DOTMATRIX_COLOR_WARN=( 88 220 1 1 9 11) -DOTMATRIX_COLOR_FAIR=( 0 $li 1 0 0 8) +JOLLY_COLOR_DARK=( $li $da 0 0 15 0) +JOLLY_COLOR_LITE=( $da $li 0 0 0 15) +JOLLY_COLOR_GLOW=( 0 $li 0 0 0 15) +JOLLY_COLOR_NOTE=( 0 27 1 1 15 4) +JOLLY_COLOR_WARN=( 88 220 1 1 9 11) +JOLLY_COLOR_FAIR=( 0 $li 1 0 0 8) -DOTMATRIX_COLOR_PATH_SHORT=( 15 $da 0 0 0 15) -DOTMATRIX_COLOR_PATH_VCS=( 15 $da 0 1 0 15) -DOTMATRIX_COLOR_PATH_LAST=( 15 $da 1 0 0 15) +JOLLY_COLOR_PATH_SHORT=( 15 $da 0 0 0 15) +JOLLY_COLOR_PATH_VCS=( 15 $da 0 1 0 15) +JOLLY_COLOR_PATH_LAST=( 15 $da 1 0 0 15) -DOTMATRIX_COLOR_LINE=(247 -1 0 0 7 -1) -DOTMATRIX_COLOR_LINE_START=(247 -1 1 0 7 -1) -DOTMATRIX_COLOR_LINE_END=( 247 -1 1 0 7 -1) +JOLLY_COLOR_LINE=(247 -1 0 0 7 -1) +JOLLY_COLOR_LINE_START=(247 -1 1 0 7 -1) +JOLLY_COLOR_LINE_END=( 247 -1 1 0 7 -1) -DOTMATRIX_COLOR_MARK=(15 -1 0 0 15 -1) -DOTMATRIX_COLOR_SEP_DARK=( 15 -2 0 0 15 -2) -DOTMATRIX_COLOR_SEP_FAIR=( 0 -2 0 0 0 -2) -DOTMATRIX_COLOR_SEP_LITE=( 0 -2 0 0 15 -2) +JOLLY_COLOR_MARK=(15 -1 0 0 15 -1) +JOLLY_COLOR_SEP_DARK=( 15 -2 0 0 15 -2) +JOLLY_COLOR_SEP_FAIR=( 0 -2 0 0 0 -2) +JOLLY_COLOR_SEP_LITE=( 0 -2 0 0 15 -2) diff --git a/presets/variant-chevron.conf b/presets/variant-chevron.conf index 8bc2d88..c0386ef 100644 --- a/presets/variant-chevron.conf +++ b/presets/variant-chevron.conf @@ -1,26 +1,26 @@ -DOTMATRIX_SPACED=${DOTMATRIX_SPACED:-1} +JOLLY_SPACED=${JOLLY_SPACED:-1} # Powerline chevron theme -DOTMATRIX_HOST_LOCAL=${DOTMATRIX_HOST_LOCAL:-""} -DOTMATRIX_USER_LOCAL=${DOTMATRIX_USER_LOCAL:-""} -DOTMATRIX_VCS=${DOTMATRIX_VCS:-""} -DOTMATRIX_MARK=${DOTMATRIX_MARK:-""} -DOTMATRIX_MARK_SUDO=${DOTMATRIX_MARK_SUDO:-"⁘"} # ⁘ 🞙 -DOTMATRIX_LINE=${DOTMATRIX_LINE:-"━"} -DOTMATRIX_PLUG=${DOTMATRIX_PLUG:-""} -DOTMATRIX_SOFT=${DOTMATRIX_SOFT:-"╱"} -DOTMATRIX_MEAN=${DOTMATRIX_MEAN:-""} +JOLLY_HOST_LOCAL=${JOLLY_HOST_LOCAL:-""} +JOLLY_USER_LOCAL=${JOLLY_USER_LOCAL:-""} +JOLLY_VCS=${JOLLY_VCS:-""} +JOLLY_MARK=${JOLLY_MARK:-""} +JOLLY_MARK_SUDO=${JOLLY_MARK_SUDO:-"⁘"} # ⁘ 🞙 +JOLLY_LINE=${JOLLY_LINE:-"━"} +JOLLY_PLUG=${JOLLY_PLUG:-""} +JOLLY_SOFT=${JOLLY_SOFT:-"╱"} +JOLLY_MEAN=${JOLLY_MEAN:-""} -DOTMATRIX_LINK=( ${DOTMATRIX_LINK[@]+"${DOTMATRIX_LINK[@]}"} ) -[[ ${#DOTMATRIX_LINK[@]} == 0 ]] && DOTMATRIX_LINK=("" "" "") -DOTMATRIX_LINK_R=( ${DOTMATRIX_LINK_R[@]+"${DOTMATRIX_LINK_R[@]}"} ) -[[ ${#DOTMATRIX_LINK_R[@]} == 0 ]] && DOTMATRIX_LINK_R=("" "" "") -DOTMATRIX_OPEN=( ${DOTMATRIX_OPEN[@]+"${DOTMATRIX_OPEN[@]}"} ) -[[ ${#DOTMATRIX_OPEN[@]} == 0 ]] && DOTMATRIX_OPEN=("" "" "") -DOTMATRIX_DANG=( ${DOTMATRIX_DANG[@]+"${DOTMATRIX_DANG[@]}"} ) -[[ ${#DOTMATRIX_DANG[@]} == 0 ]] && DOTMATRIX_DANG=("" "" "") -DOTMATRIX_ENDS=( ${DOTMATRIX_ENDS[@]+"${DOTMATRIX_ENDS[@]}"} ) -[[ ${#DOTMATRIX_ENDS[@]} == 0 ]] && DOTMATRIX_ENDS=("" "" "") -DOTMATRIX_ITEMS=( ${DOTMATRIX_ITEMS[@]+"${DOTMATRIX_ITEMS[@]}"} ) -[[ ${#DOTMATRIX_ITEMS[@]} == 0 ]] && DOTMATRIX_ITEMS=("" "┃" "") +JOLLY_LINK=( ${JOLLY_LINK[@]+"${JOLLY_LINK[@]}"} ) +[[ ${#JOLLY_LINK[@]} == 0 ]] && JOLLY_LINK=("" "" "") +JOLLY_LINK_R=( ${JOLLY_LINK_R[@]+"${JOLLY_LINK_R[@]}"} ) +[[ ${#JOLLY_LINK_R[@]} == 0 ]] && JOLLY_LINK_R=("" "" "") +JOLLY_OPEN=( ${JOLLY_OPEN[@]+"${JOLLY_OPEN[@]}"} ) +[[ ${#JOLLY_OPEN[@]} == 0 ]] && JOLLY_OPEN=("" "" "") +JOLLY_DANG=( ${JOLLY_DANG[@]+"${JOLLY_DANG[@]}"} ) +[[ ${#JOLLY_DANG[@]} == 0 ]] && JOLLY_DANG=("" "" "") +JOLLY_ENDS=( ${JOLLY_ENDS[@]+"${JOLLY_ENDS[@]}"} ) +[[ ${#JOLLY_ENDS[@]} == 0 ]] && JOLLY_ENDS=("" "" "") +JOLLY_ITEMS=( ${JOLLY_ITEMS[@]+"${JOLLY_ITEMS[@]}"} ) +[[ ${#JOLLY_ITEMS[@]} == 0 ]] && JOLLY_ITEMS=("" "┃" "") diff --git a/presets/variant-round.conf b/presets/variant-round.conf index 167cab3..5175c1b 100644 --- a/presets/variant-round.conf +++ b/presets/variant-round.conf @@ -1,26 +1,26 @@ -DOTMATRIX_SPACED=${DOTMATRIX_SPACED:-1} +JOLLY_SPACED=${JOLLY_SPACED:-1} # Powerline round theme -DOTMATRIX_HOST_LOCAL=${DOTMATRIX_HOST_LOCAL:-""} -DOTMATRIX_USER_LOCAL=${DOTMATRIX_USER_LOCAL:-""} -DOTMATRIX_VCS=${DOTMATRIX_VCS:-""} -DOTMATRIX_MARK=${DOTMATRIX_MARK:-""} -DOTMATRIX_MARK_SUDO=${DOTMATRIX_MARK_SUDO:-"⚬"} # ⁘ ⚬ 🞙 -DOTMATRIX_LINE=${DOTMATRIX_LINE:-"━"} -DOTMATRIX_PLUG=${DOTMATRIX_PLUG:-""} -DOTMATRIX_SOFT=${DOTMATRIX_SOFT:-"╱"} -DOTMATRIX_MEAN=${DOTMATRIX_MEAN:-""} +JOLLY_HOST_LOCAL=${JOLLY_HOST_LOCAL:-""} +JOLLY_USER_LOCAL=${JOLLY_USER_LOCAL:-""} +JOLLY_VCS=${JOLLY_VCS:-""} +JOLLY_MARK=${JOLLY_MARK:-""} +JOLLY_MARK_SUDO=${JOLLY_MARK_SUDO:-"⚬"} # ⁘ ⚬ 🞙 +JOLLY_LINE=${JOLLY_LINE:-"━"} +JOLLY_PLUG=${JOLLY_PLUG:-""} +JOLLY_SOFT=${JOLLY_SOFT:-"╱"} +JOLLY_MEAN=${JOLLY_MEAN:-""} -DOTMATRIX_LINK=( ${DOTMATRIX_LINK[@]+"${DOTMATRIX_LINK[@]}"} ) -[[ ${#DOTMATRIX_LINK[@]} == 0 ]] && DOTMATRIX_LINK=("█" "" "") -DOTMATRIX_LINK_R=( ${DOTMATRIX_LINK_R[@]+"${DOTMATRIX_LINK_R[@]}"} ) -[[ ${#DOTMATRIX_LINK_R[@]} == 0 ]] && DOTMATRIX_LINK_R=("" "" "█") -DOTMATRIX_OPEN=( ${DOTMATRIX_OPEN[@]+"${DOTMATRIX_OPEN[@]}"} ) -[[ ${#DOTMATRIX_OPEN[@]} == 0 ]] && DOTMATRIX_OPEN=("█" "" "") -DOTMATRIX_DANG=( ${DOTMATRIX_DANG[@]+"${DOTMATRIX_DANG[@]}"} ) -[[ ${#DOTMATRIX_DANG[@]} == 0 ]] && DOTMATRIX_DANG=("█" "" "") -DOTMATRIX_ENDS=( ${DOTMATRIX_ENDS[@]+"${DOTMATRIX_ENDS[@]}"} ) -[[ ${#DOTMATRIX_ENDS[@]} == 0 ]] && DOTMATRIX_ENDS=("" "" "") -DOTMATRIX_ITEMS=( ${DOTMATRIX_ITEMS[@]+"${DOTMATRIX_ITEMS[@]}"} ) -[[ ${#DOTMATRIX_ITEMS[@]} == 0 ]] && DOTMATRIX_ITEMS=("" "┃" "") +JOLLY_LINK=( ${JOLLY_LINK[@]+"${JOLLY_LINK[@]}"} ) +[[ ${#JOLLY_LINK[@]} == 0 ]] && JOLLY_LINK=("█" "" "") +JOLLY_LINK_R=( ${JOLLY_LINK_R[@]+"${JOLLY_LINK_R[@]}"} ) +[[ ${#JOLLY_LINK_R[@]} == 0 ]] && JOLLY_LINK_R=("" "" "█") +JOLLY_OPEN=( ${JOLLY_OPEN[@]+"${JOLLY_OPEN[@]}"} ) +[[ ${#JOLLY_OPEN[@]} == 0 ]] && JOLLY_OPEN=("█" "" "") +JOLLY_DANG=( ${JOLLY_DANG[@]+"${JOLLY_DANG[@]}"} ) +[[ ${#JOLLY_DANG[@]} == 0 ]] && JOLLY_DANG=("█" "" "") +JOLLY_ENDS=( ${JOLLY_ENDS[@]+"${JOLLY_ENDS[@]}"} ) +[[ ${#JOLLY_ENDS[@]} == 0 ]] && JOLLY_ENDS=("" "" "") +JOLLY_ITEMS=( ${JOLLY_ITEMS[@]+"${JOLLY_ITEMS[@]}"} ) +[[ ${#JOLLY_ITEMS[@]} == 0 ]] && JOLLY_ITEMS=("" "┃" "") diff --git a/presets/variant-slant.conf b/presets/variant-slant.conf index 60dbe02..5254d9d 100644 --- a/presets/variant-slant.conf +++ b/presets/variant-slant.conf @@ -1,25 +1,25 @@ -DOTMATRIX_SPACED=${DOTMATRIX_SPACED:-1} +JOLLY_SPACED=${JOLLY_SPACED:-1} # Powerline slanted theme -DOTMATRIX_HOST_LOCAL=${DOTMATRIX_HOST_LOCAL:-""} -DOTMATRIX_USER_LOCAL=${DOTMATRIX_USER_LOCAL:-""} -DOTMATRIX_VCS=${DOTMATRIX_VCS:-""} -DOTMATRIX_MARK=${DOTMATRIX_MARK:-""} -DOTMATRIX_MARK_SUDO=${DOTMATRIX_MARK_SUDO:-"🞙"} # ⁘ ⚬ 🞙 -DOTMATRIX_LINE=${DOTMATRIX_LINE:-"━"} -DOTMATRIX_PLUG=${DOTMATRIX_PLUG:-""} -DOTMATRIX_SOFT=${DOTMATRIX_SOFT:-"╱"} -DOTMATRIX_MEAN=${DOTMATRIX_MEAN:-" "} -DOTMATRIX_LINK=( ${DOTMATRIX_LINK[@]+"${DOTMATRIX_LINK[@]}"} ) -[[ ${#DOTMATRIX_LINK[@]} == 0 ]] && DOTMATRIX_LINK=("" "" " ") -DOTMATRIX_LINK_R=( ${DOTMATRIX_LINK_R[@]+"${DOTMATRIX_LINK_R[@]}"} ) -[[ ${#DOTMATRIX_LINK_R[@]} == 0 ]] && DOTMATRIX_LINK_R=("" "" "") -DOTMATRIX_OPEN=( ${DOTMATRIX_OPEN[@]+"${DOTMATRIX_OPEN[@]}"} ) -[[ ${#DOTMATRIX_OPEN[@]} == 0 ]] && DOTMATRIX_OPEN=("" "" " ") -DOTMATRIX_DANG=( ${DOTMATRIX_DANG[@]+"${DOTMATRIX_DANG[@]}"} ) -[[ ${#DOTMATRIX_DANG[@]} == 0 ]] && DOTMATRIX_DANG=("" " " " ") -DOTMATRIX_ENDS=( ${DOTMATRIX_ENDS[@]+"${DOTMATRIX_ENDS[@]}"} ) -[[ ${#DOTMATRIX_ENDS[@]} == 0 ]] && DOTMATRIX_ENDS=("" " " " ") -DOTMATRIX_ITEMS=( ${DOTMATRIX_ITEMS[@]+"${DOTMATRIX_ITEMS[@]}"} ) -[[ ${#DOTMATRIX_ITEMS[@]} == 0 ]] && DOTMATRIX_ITEMS=("" "┃" "") +JOLLY_HOST_LOCAL=${JOLLY_HOST_LOCAL:-""} +JOLLY_USER_LOCAL=${JOLLY_USER_LOCAL:-""} +JOLLY_VCS=${JOLLY_VCS:-""} +JOLLY_MARK=${JOLLY_MARK:-""} +JOLLY_MARK_SUDO=${JOLLY_MARK_SUDO:-"🞙"} # ⁘ ⚬ 🞙 +JOLLY_LINE=${JOLLY_LINE:-"━"} +JOLLY_PLUG=${JOLLY_PLUG:-""} +JOLLY_SOFT=${JOLLY_SOFT:-"╱"} +JOLLY_MEAN=${JOLLY_MEAN:-" "} +JOLLY_LINK=( ${JOLLY_LINK[@]+"${JOLLY_LINK[@]}"} ) +[[ ${#JOLLY_LINK[@]} == 0 ]] && JOLLY_LINK=("" "" " ") +JOLLY_LINK_R=( ${JOLLY_LINK_R[@]+"${JOLLY_LINK_R[@]}"} ) +[[ ${#JOLLY_LINK_R[@]} == 0 ]] && JOLLY_LINK_R=("" "" "") +JOLLY_OPEN=( ${JOLLY_OPEN[@]+"${JOLLY_OPEN[@]}"} ) +[[ ${#JOLLY_OPEN[@]} == 0 ]] && JOLLY_OPEN=("" "" " ") +JOLLY_DANG=( ${JOLLY_DANG[@]+"${JOLLY_DANG[@]}"} ) +[[ ${#JOLLY_DANG[@]} == 0 ]] && JOLLY_DANG=("" " " " ") +JOLLY_ENDS=( ${JOLLY_ENDS[@]+"${JOLLY_ENDS[@]}"} ) +[[ ${#JOLLY_ENDS[@]} == 0 ]] && JOLLY_ENDS=("" " " " ") +JOLLY_ITEMS=( ${JOLLY_ITEMS[@]+"${JOLLY_ITEMS[@]}"} ) +[[ ${#JOLLY_ITEMS[@]} == 0 ]] && JOLLY_ITEMS=("" "┃" "") diff --git a/presets/variant-text.conf b/presets/variant-text.conf index 5bb2cb3..b2ced90 100644 --- a/presets/variant-text.conf +++ b/presets/variant-text.conf @@ -1,27 +1,26 @@ -DOTMATRIX_SPACED=${DOTMATRIX_SPACED:-0} +JOLLY_SPACED=${JOLLY_SPACED:-0} -# Dotmatrix theme -DOTMATRIX_HOST_LOCAL=${DOTMATRIX_HOST_LOCAL:-"lcl"} -DOTMATRIX_USER_LOCAL=${DOTMATRIX_USER_LOCAL:-"me"} -DOTMATRIX_VCS=${DOTMATRIX_VCS:-"VCS"} -DOTMATRIX_MARK=${DOTMATRIX_MARK:-">"} -DOTMATRIX_MARK_SUDO=${DOTMATRIX_MARK_SUDO:-"!"} -DOTMATRIX_LINE=${DOTMATRIX_LINE:-"━"} -DOTMATRIX_PLUG=${DOTMATRIX_PLUG:-"▌"} -DOTMATRIX_SOFT=${DOTMATRIX_SOFT:-"╱"} -DOTMATRIX_MEAN=${DOTMATRIX_MEAN:-"┃"} +JOLLY_HOST_LOCAL=${JOLLY_HOST_LOCAL:-"lcl"} +JOLLY_USER_LOCAL=${JOLLY_USER_LOCAL:-"me"} +JOLLY_VCS=${JOLLY_VCS:-"VCS"} +JOLLY_MARK=${JOLLY_MARK:-">"} +JOLLY_MARK_SUDO=${JOLLY_MARK_SUDO:-"!"} +JOLLY_LINE=${JOLLY_LINE:-"━"} +JOLLY_PLUG=${JOLLY_PLUG:-"▌"} +JOLLY_SOFT=${JOLLY_SOFT:-"╱"} +JOLLY_MEAN=${JOLLY_MEAN:-"┃"} # Separator arrays (left center right) -DOTMATRIX_LINK=( ${DOTMATRIX_LINK[@]+"${DOTMATRIX_LINK[@]}"} ) -[[ ${#DOTMATRIX_LINK[@]} == 0 ]] && DOTMATRIX_LINK=("▌" "<" "▐") -DOTMATRIX_LINK_R=( ${DOTMATRIX_LINK_R[@]+"${DOTMATRIX_LINK_R[@]}"} ) -[[ ${#DOTMATRIX_LINK_R[@]} == 0 ]] && DOTMATRIX_LINK_R=("▌" ">" "▐") -DOTMATRIX_OPEN=( ${DOTMATRIX_OPEN[@]+"${DOTMATRIX_OPEN[@]}"} ) -[[ ${#DOTMATRIX_OPEN[@]} == 0 ]] && DOTMATRIX_OPEN=("▌" "<<" "▐") -DOTMATRIX_DANG=( ${DOTMATRIX_DANG[@]+"${DOTMATRIX_DANG[@]}"} ) -[[ ${#DOTMATRIX_DANG[@]} == 0 ]] && DOTMATRIX_DANG=("▌" "<<<" "▐") -DOTMATRIX_ENDS=( ${DOTMATRIX_ENDS[@]+"${DOTMATRIX_ENDS[@]}"} ) -[[ ${#DOTMATRIX_ENDS[@]} == 0 ]] && DOTMATRIX_ENDS=("▌" "···" "···▐") -DOTMATRIX_ITEMS=( ${DOTMATRIX_ITEMS[@]+"${DOTMATRIX_ITEMS[@]}"} ) -[[ ${#DOTMATRIX_ITEMS[@]} == 0 ]] && DOTMATRIX_ITEMS=("┫" "┃" "┣") +JOLLY_LINK=( ${JOLLY_LINK[@]+"${JOLLY_LINK[@]}"} ) +[[ ${#JOLLY_LINK[@]} == 0 ]] && JOLLY_LINK=("▌" "<" "▐") +JOLLY_LINK_R=( ${JOLLY_LINK_R[@]+"${JOLLY_LINK_R[@]}"} ) +[[ ${#JOLLY_LINK_R[@]} == 0 ]] && JOLLY_LINK_R=("▌" ">" "▐") +JOLLY_OPEN=( ${JOLLY_OPEN[@]+"${JOLLY_OPEN[@]}"} ) +[[ ${#JOLLY_OPEN[@]} == 0 ]] && JOLLY_OPEN=("▌" "<<" "▐") +JOLLY_DANG=( ${JOLLY_DANG[@]+"${JOLLY_DANG[@]}"} ) +[[ ${#JOLLY_DANG[@]} == 0 ]] && JOLLY_DANG=("▌" "<<<" "▐") +JOLLY_ENDS=( ${JOLLY_ENDS[@]+"${JOLLY_ENDS[@]}"} ) +[[ ${#JOLLY_ENDS[@]} == 0 ]] && JOLLY_ENDS=("▌" "···" "···▐") +JOLLY_ITEMS=( ${JOLLY_ITEMS[@]+"${JOLLY_ITEMS[@]}"} ) +[[ ${#JOLLY_ITEMS[@]} == 0 ]] && JOLLY_ITEMS=("┫" "┃" "┣")