├── FUNDING.yml ├── LICENSE ├── command_prompt.bash └── README.md /FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: bluz71 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-present bash-seafly-prompt authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /command_prompt.bash: -------------------------------------------------------------------------------- 1 | # A modern, informative and configurable command prompt for the Bash shell. 2 | # 3 | # URL: github.com/bluz71/bash-seafly-prompt 4 | # License: MIT (https://opensource.org/licenses/MIT) 5 | 6 | 7 | # Non-interactive shells don't have a prompt, exit early. 8 | [[ $- =~ i ]] || return 0 9 | 10 | # Set a simple prompt for non-256color, non-alacritty and non-kitty terminals. 11 | if [[ $TERM != *-256color ]] && [[ $TERM != alacritty* ]] && [[ $TERM != *-kitty ]]; then 12 | PS1='\h \w > ' 13 | return 0 14 | fi 15 | 16 | # Default colors used in the prompt. 17 | : ${SEAFLY_PREFIX_COLOR:="\e[38;5;217m"} 18 | : ${SEAFLY_SUCCESS_COLOR:=$(echo -ne '\e[38;5;111m')} 19 | : ${SEAFLY_ALERT_COLOR:=$(echo -ne '\e[38;5;203m')} 20 | : ${SEAFLY_HOST_COLOR:="\e[38;5;255m"} 21 | : ${SEAFLY_GIT_COLOR:="\e[38;5;147m"} 22 | : ${SEAFLY_PATH_COLOR:="\e[38;5;114m"} 23 | : ${NOCOLOR:=$(echo -ne '\e[m')} 24 | 25 | # Shorten directory paths to a maximum of four components unless PROMPT_DIRTRIM 26 | # has already been set. 27 | : ${PROMPT_DIRTRIM:=4} 28 | 29 | # Default Git indicator values. 30 | : ${GIT_PS1_SHOWDIRTYSTATE:=1} 31 | : ${GIT_PS1_SHOWSTASHSTATE:=1} 32 | : ${GIT_PS1_SHOWUPSTREAM:=1} 33 | 34 | # Default layout settings. 35 | : ${SEAFLY_LAYOUT:=1} 36 | : ${SEAFLY_MULTILINE:=0} 37 | : ${SEAFLY_SHOW_USER:=0} 38 | : ${SEAFLY_SHOW_HOST:=1} 39 | : ${SEAFLY_SHOW_USERHOST_CONNECTED:=1} 40 | 41 | # Default symbols used in the prompt. 42 | : ${SEAFLY_PROMPT_SYMBOL:="❯"} 43 | : ${SEAFLY_PS2_PROMPT_SYMBOL:="❯"} 44 | : ${SEAFLY_GIT_PREFIX:=" "} 45 | : ${SEAFLY_GIT_SUFFIX:=""} 46 | : ${SEAFLY_GIT_DIRTY:="✗"} 47 | : ${SEAFLY_GIT_STAGED:="✓"} 48 | : ${SEAFLY_GIT_STASH:="⚑"} 49 | : ${SEAFLY_GIT_AHEAD:="↑"} 50 | : ${SEAFLY_GIT_BEHIND:="↓"} 51 | : ${SEAFLY_GIT_DIVERGED:="↕"} 52 | 53 | # Collate Git details using either the 54 | # [git-status-fly](https://github.com/bluz71/git-status-fly) or 55 | # [git-status-snap](https://github.com/bluz71/git-status-snap) utilities. 56 | # 57 | _seafly_git_status_parser() { 58 | if (( SEAFLY_GIT_STATUS_FLY == 1 )); then 59 | . <(git-status-fly) 60 | else 61 | . <(git-status-snap) 62 | fi 63 | [[ -z "$GSF_REPOSITORY" ]] && return 64 | 65 | # We are in a Git repository. 66 | local branch=$GSF_BRANCH 67 | if [[ $branch == "HEAD" ]]; then 68 | branch="detached*$(git rev-parse --short HEAD 2>/dev/null)" 69 | fi 70 | branch=${branch//\\/\\\\} # Escape backslashes 71 | branch=${branch//\$/\\\$} # Escape dollars 72 | local ellipsis="…" # Truncate, with ellipsis, long branch names 73 | branch="${branch:0:30}${ellipsis:0:$(( ${#branch} > 30 ))}" 74 | 75 | local dirty 76 | local staged 77 | if [[ $branch != "detached*" && 78 | $GIT_PS1_SHOWDIRTYSTATE -ne 0 && 79 | $(git config --bool bash.showDirtyState) != "false" ]]; then 80 | [[ -n $GSF_DIRTY ]] && dirty=$SEAFLY_GIT_DIRTY 81 | [[ -n $GSF_STAGED ]] && staged=$SEAFLY_GIT_STAGED 82 | fi 83 | 84 | local stash 85 | if [[ $GIT_PS1_SHOWSTASHSTATE -ne 0 ]]; then 86 | [[ -n $GSF_STASH ]] && stash=$SEAFLY_GIT_STASH 87 | fi 88 | 89 | local upstream 90 | if [[ $GIT_PS1_SHOWUPSTREAM -ne 0 && -n $GSF_UPSTREAM ]]; then 91 | if (( GSF_UPSTREAM == 2 )); then 92 | upstream=$SEAFLY_GIT_DIVERGED 93 | elif (( GSF_UPSTREAM == 1 )); then 94 | upstream=$SEAFLY_GIT_AHEAD 95 | elif (( GSF_UPSTREAM < 0 )); then 96 | upstream=$SEAFLY_GIT_BEHIND 97 | elif (( GSF_UPSTREAM == 0 )); then 98 | upstream="=" 99 | fi 100 | fi 101 | 102 | local spacer 103 | if [[ -n $dirty || -n $staged || -n $stash || -n $upstream ]]; then 104 | spacer=" " 105 | fi 106 | _seafly_git="$SEAFLY_GIT_PREFIX$branch$spacer\[$SEAFLY_ALERT_COLOR\]$dirty\[$SEAFLY_SUCCESS_COLOR\]$staged$upstream\[$SEAFLY_GIT_COLOR\]$stash$SEAFLY_GIT_SUFFIX " 107 | } 108 | 109 | # Collate Git details using just the 'git' command. 110 | # 111 | _seafly_git_command() { 112 | local is_git_repo 113 | if [[ $(git rev-parse --is-inside-work-tree --is-bare-repository 2>/dev/null) =~ true ]]; then 114 | is_git_repo=1 115 | fi 116 | (( is_git_repo == 1 )) || return 117 | 118 | # We are in a Git repository. 119 | local branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)" 120 | if [[ $branch == "HEAD" ]]; then 121 | branch="detached*$(git rev-parse --short HEAD 2>/dev/null)" 122 | fi 123 | branch=${branch//\\/\\\\} # Escape backslashes 124 | branch=${branch//\$/\\\$} # Escape dollars 125 | local ellipsis="…" # Truncate, with ellipsis, long branch names 126 | branch="${branch:0:30}${ellipsis:0:$(( ${#branch} > 30 ))}" 127 | 128 | local dirty 129 | local staged 130 | if [[ $branch != "detached*" && 131 | $GIT_PS1_SHOWDIRTYSTATE -ne 0 && 132 | $(git config --bool bash.showDirtyState) != "false" ]]; then 133 | git diff --no-ext-diff --quiet --exit-code --ignore-submodules 2>/dev/null || dirty=$SEAFLY_GIT_DIRTY 134 | git diff --no-ext-diff --quiet --cached --exit-code --ignore-submodules 2>/dev/null || staged=$SEAFLY_GIT_STAGED 135 | fi 136 | 137 | local stash 138 | if [[ $GIT_PS1_SHOWSTASHSTATE -ne 0 ]]; then 139 | git rev-parse --verify --quiet refs/stash >/dev/null && stash=$SEAFLY_GIT_STASH 140 | fi 141 | 142 | local upstream 143 | if [[ $GIT_PS1_SHOWUPSTREAM -ne 0 ]]; then 144 | case "$(git rev-list --left-right --count HEAD...@'{u}' 2>/dev/null)" in 145 | "") # no upstream 146 | upstream="" ;; 147 | "0 0") # equal to upstream 148 | upstream="=" ;; 149 | "0 "*) # behind upstream 150 | upstream=$SEAFLY_GIT_BEHIND ;; 151 | *" 0") # ahead of upstream 152 | upstream=$SEAFLY_GIT_AHEAD ;; 153 | *) # diverged from upstream 154 | upstream=$SEAFLY_GIT_DIVERGED ;; 155 | esac 156 | fi 157 | 158 | local spacer 159 | if [[ -n $dirty || -n $staged || -n $stash || -n $upstream ]]; then 160 | spacer=" " 161 | fi 162 | _seafly_git="$SEAFLY_GIT_PREFIX$branch$spacer\[$SEAFLY_ALERT_COLOR\]$dirty\[$SEAFLY_SUCCESS_COLOR\]$staged$upstream\[$SEAFLY_GIT_COLOR\]$stash$SEAFLY_GIT_SUFFIX " 163 | } 164 | 165 | _seafly_command_prompt() { 166 | # Run the pre-command hook if it is set, if not set this will evaluate to a 167 | # no-op. 168 | "${seafly_pre_command_hook-:}" 169 | 170 | local prompt_prefix 171 | # Run and save the output from the prompt-prefix hook if it is set, if not 172 | # set prefix-value will evaluate to a no-op. 173 | local prefix_value=$("${seafly_prompt_prefix_hook-:}") 174 | if [[ -n $prefix_value ]]; then 175 | prompt_prefix="\[$SEAFLY_PREFIX_COLOR\]$prefix_value " 176 | fi 177 | if (( SEAFLY_MULTILINE == 1 )); then 178 | prompt_prefix="\n$prompt_prefix" 179 | fi 180 | 181 | local prompt_start 182 | if [[ $SEAFLY_SHOW_USERHOST_CONNECTED -eq 0 ]] || [[ $SEAFLY_SHOW_USERHOST_CONNECTED -eq 1 && -n $SSH_CONNECTION ]]; then 183 | if [[ $SEAFLY_SHOW_USER -eq 1 && $SEAFLY_SHOW_HOST -eq 1 ]]; then 184 | prompt_start="\[$SEAFLY_HOST_COLOR\]\u@\h " 185 | elif (( SEAFLY_SHOW_USER == 1 )); then 186 | prompt_start="\[$SEAFLY_HOST_COLOR\]\u " 187 | elif (( SEAFLY_SHOW_HOST == 1 )); then 188 | prompt_start="\[$SEAFLY_HOST_COLOR\]\h " 189 | fi 190 | fi 191 | 192 | # Collate Git details, if applicable, for the current directory. 193 | if (( SEAFLY_GIT_STATUS_FLY == 1 || SEAFLY_GIT_STATUS_SNAP == 1 )); then 194 | # Use either git-status-fly or git-status-snap utilities. 195 | _seafly_git_status_parser 196 | else 197 | # Use the fallback 'git' command, this will be much slower. 198 | _seafly_git_command 199 | fi 200 | 201 | local prompt_middle 202 | if (( SEAFLY_LAYOUT == 1 )); then 203 | prompt_middle="\[$SEAFLY_PATH_COLOR\]\w\[$SEAFLY_GIT_COLOR\] $_seafly_git" 204 | else 205 | prompt_middle="\[$SEAFLY_GIT_COLOR\]$_seafly_git\[$SEAFLY_PATH_COLOR\]\w " 206 | fi 207 | unset _seafly_git 208 | 209 | # Success prompt symbol color indicates that the last command ran 210 | # without issue whilst alert prompt symbol color indicates that the last 211 | # command failed. 212 | _seafly_colors=("$SEAFLY_ALERT_COLOR" "$SEAFLY_SUCCESS_COLOR") 213 | 214 | local prompt_end="\[\${_seafly_colors[\$((!\$?))]}\]$SEAFLY_PROMPT_SYMBOL\[\$NOCOLOR\] " 215 | if (( SEAFLY_MULTILINE == 1 )); then 216 | prompt_end="\n$prompt_end" 217 | fi 218 | 219 | PS1="$prompt_prefix$prompt_start$prompt_middle$prompt_end" 220 | PS2="\[$SEAFLY_SUCCESS_COLOR\]$SEAFLY_PS2_PROMPT_SYMBOL\[\$NOCOLOR\] " 221 | } 222 | 223 | # Use [git-status-fly](https://github.com/bluz71/git-status-fly) if it is 224 | # available. 225 | if [[ -x $(command -v git-status-fly 2>/dev/null) ]]; then 226 | export SEAFLY_GIT_STATUS_FLY=1 227 | elif [[ -x $(command -v git-status-snap 2>/dev/null) ]]; then 228 | export SEAFLY_GIT_STATUS_SNAP=1 229 | fi 230 | 231 | # Bind and call the '_seafly_command_prompt' function as the Bash prompt. 232 | PROMPT_COMMAND=_seafly_command_prompt 233 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![seafly](https://raw.githubusercontent.com/bluz71/misc-binaries/master/headings/seafly.png) 2 | ======== 3 | 4 | _seafly_ is a clean and fast command prompt for the 5 | [Bash](https://www.gnu.org/software/bash) shell heavily inspired by the [Pure 6 | ZSH](https://github.com/sindresorhus/pure) prompt. 7 | 8 | :rocket: For maximum repository performance, _seafly_ will use, if available, 9 | either the [git-status-fly](https://github.com/bluz71/git-status-fly) or 10 | [git-status-snap](https://github.com/bluz71/git-status-snap) utilities. Note, it 11 | is strongly recommened to use either of these utilities to accelerate prompt 12 | performance. 13 | 14 | Screenshot 15 | ---------- 16 | 17 | seafly 18 | 19 | The font in use is [Iosevka](https://github.com/be5invis/Iosevka). 20 | 21 | Layout 22 | ------ 23 | 24 | _seafly_ is a prompt that displays the following segments when using the 25 | default layout: 26 | 27 | ``` 28 | 29 | ``` 30 | 31 | Note, when `SEAFLY_LAYOUT=2` is set the prompt will instead display as: 32 | 33 | ``` 34 | 35 | ``` 36 | 37 | _seafly_ can also display as a multiline prompt when `SEAFLY_MULTILINE=1` is 38 | set. The layout will be the same as listed above but with additional newlines 39 | prior to the prefix and prompt symbol. 40 | 41 | Please refer to the configuration section below for more details. 42 | 43 | Behaviour 44 | --------- 45 | 46 | - When in a Git repository the checked out Git branch will be displayed. 47 | 48 | - When in a Git repository, dirty state, upstream and stash indicators will be 49 | displayed. Note, these can individually be disabled if desired. 50 | 51 | - The prompt symbol will change to an alert color, by default red, if the last 52 | command did not execute successfully. 53 | 54 | Visuals 55 | ------- 56 | 57 | _seafly_ by default will use Unicode characters for the prompt symbol and 58 | certain Git indicators. These symbols will display correctly when using a modern 59 | font such as [Iosevka](https://github.com/be5invis/Iosevka). 60 | 61 | Also, _seafly_ by default will use colors that favour a dark background. 62 | 63 | Both the symbols and colors used by _seafly_ can be overridden, please refer to 64 | the configuration section below. As an example, the following configuration 65 | will: 66 | 67 | - only use ASCII characters 68 | - use colors appropriate for a light terminal theme 69 | - style the Git section to mimic `$(__git_ps1)` provided by the 70 | [`git-prompt.sh` script](https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh) 71 | that ships with Git 72 | 73 | ```sh 74 | SEAFLY_PROMPT_SYMBOL=">" 75 | SEAFLY_PS2_PROMPT_SYMBOL=">" 76 | SEAFLY_GIT_PREFIX="(" 77 | SEAFLY_GIT_SUFFIX=")" 78 | SEAFLY_GIT_DIRTY="*" 79 | SEAFLY_GIT_STASH="$" 80 | SEAFLY_GIT_AHEAD=">" 81 | SEAFLY_GIT_BEHIND="<" 82 | SEAFLY_GIT_DIVERGED="<>" 83 | SEAFLY_SUCCESS_COLOR="$(tput setaf 63)" 84 | SEAFLY_ALERT_COLOR="$(tput setaf 202)" 85 | SEAFLY_HOST_COLOR="$(tput setaf 242)" 86 | SEAFLY_GIT_COLOR="$(tput setaf 99)" 87 | SEAFLY_PATH_COLOR="$(tput setaf 70)" 88 | . ~/.bash-seafly-prompt/command_prompt.bash 89 | ``` 90 | 91 | Requirements 92 | ------------ 93 | 94 | A modern 256 or true color terminal is required. 95 | 96 | Please also make sure the `TERM` environment variable is set to 97 | `xterm-256color`, `screen-256color` or equivalent terminal setting. 98 | 99 | For example setting `TERM` to `xterm-256color` is usually done at the terminal 100 | level either in a preferences dialog or a related configuration file, if 101 | required at all. Note, some modern terminals will automatically set 256 colors 102 | by default, for example, modern versions of [Gnome 103 | Terminal](https://wiki.gnome.org/Apps/Terminal). 104 | 105 | Setting `TERM` to `screen-256color` should only be done for 106 | [tmux](https://github.com/tmux/tmux/wiki) sessions. If you are a tmux user then 107 | please add the following to your `~/.tmux.conf` file: 108 | 109 | ``` 110 | set -g default-terminal "screen-256color" 111 | set -ga terminal-overrides ',xterm-256color:Tc' 112 | ``` 113 | 114 | Note, modern terminals such as [Alacritty](https://github.com/alacritty) and 115 | [kitty](https://sw.kovidgoyal.net/kitty) provide their own terminfo definitions 116 | which are also supported by _seafly_ prompt. 117 | 118 | Installation 119 | ------------ 120 | 121 | Install the _seafly_ prompt script: 122 | 123 | ```sh 124 | git clone --depth 1 https://github.com/bluz71/bash-seafly-prompt ~/.bash-seafly-prompt 125 | ``` 126 | 127 | Source the _seafly_ prompt script in your `~/.bashrc` file: 128 | 129 | ```sh 130 | . ~/.bash-seafly-prompt/command_prompt.bash 131 | ``` 132 | 133 | Note, to update to the latest version of _seafly_: 134 | 135 | ```sh 136 | cd ~/.bash-seafly-prompt 137 | git pull 138 | ``` 139 | 140 | git-status-fly 141 | -------------- 142 | 143 | The [git-status-fly](https://github.com/bluz71/git-status-fly) utility is a 144 | simple [Rust](https://www.rust-lang.org) implemented `git status` parser. 145 | Processing the output of `git status` using shell commands, such as `grep` and 146 | `awk`, is much slower than using an optimized binary such as _git-status-fly_. 147 | 148 | Install the _git-status-fly_ somewhere in the current `$PATH`. 149 | 150 | git-status-snap 151 | -------------- 152 | 153 | The [git-status-snap](https://github.com/bluz71/git-status-snap) utility is an 154 | alternative [Crystal](https://crystal-lang.org) implemented `git status` parser. 155 | Implementation and behaviour is the same as _git-status-fly_. 156 | 157 | Install the _git-status-snap_ somewhere in the current `$PATH`. 158 | 159 | Git Performance 160 | --------------- 161 | 162 | _seafly_ provides two ways to gather Git status, the previously mentioned 163 | _git-status-fly_ or _git-status-snap_ utilities, or a fallback method which 164 | collates details using just the `git` command. 165 | 166 | Which to use? See the following performance results and decide. 167 | 168 | Performance metrics are listed for the following four repositories: 169 | 170 | - _dotfiles_, small repository with 189 managed files 171 | - _rails_, medium repository with 4,574 managed files 172 | - _linux_, large repository with 79,878 managed files 173 | - _chromium_, extra large repository with 413,542 managed files 174 | 175 | Listed is the average time to compute the prompt function. 176 | 177 | Linux desktop with NVMe storage: 178 | 179 | | Repository | `git-status-fly` | `git-status-snap` | `git` fallback | 180 | |----------------|------------------|-------------------|----------------| 181 | | _dotfiles_ | `5ms` | `6ms` | `11ms` | 182 | | _rails_ | `7ms` | `7ms` | `14ms` | 183 | | _linux_(*) | `26ms` | `26ms` | `38ms` | 184 | | _chromium_ (*) | `122ms` | `123ms` | `154ms` | 185 | 186 | M1 Macbook Air: 187 | 188 | | Repository | `git-status-fly` | `git-status-snap` | `git` fallback | 189 | |----------------|------------------|-------------------|----------------| 190 | | _dotfiles_ | `33ms` | `39ms` | `61ms` | 191 | | _rails_ | `39ms` | `43ms` | `73ms` | 192 | | _linux_ (!) | `60ms` | `64ms` | `105ms` | 193 | | _chromium_ (!) | `103ms` | `108ms` | `155ms` | 194 | 195 | - **(*)**, the `git config feature.manyFiles true` option was enabled as 196 | [documented here](https://github.blog/2019-11-03-highlights-from-git-2-24/) 197 | 198 | - **(!)**, in addition to enabling `manyFiles`, the `git config core.fsmonitor 199 | true` file system monitor was also enabled as [documented 200 | here](https://github.blog/2022-06-29-improve-git-monorepo-performance-with-a-file-system-monitor) 201 | 202 | Note, as of May 2023 `fsmonitor` is implemented only for Windows and macOS, it 203 | is not available for Linux. 204 | 205 | In practise, a prompt startup time under 40ms feels instant. 206 | 207 | Configuration 208 | ------------- 209 | 210 | Certain behaviours and visuals of the _seafly_ prompt can be controlled 211 | through environment variables. 212 | 213 | Note, a dash character denotes an unset default value. 214 | 215 | ### Environment Variables 216 | 217 | | Option | Description | Default Value | 218 | | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------| ------------- | 219 | | **`SEAFLY_LAYOUT`** | Specify the preferred layout.
Layout `1` will display path followed Git details.
Layout `2` will flip the path and Git details. | 1 | 220 | | **`SEAFLY_MULTILINE`** | Specify multiline layout.
`SEAFLY_MULTILINE=1` will display the prompt over multiple lines. | 0 | 221 | | **`SEAFLY_SHOW_USER`** | Display the current user in the user/host segment.
Set to `1` to display the user.
Refer to `SEAFLY_SHOW_USERHOST_CONNECTED`. | 0 | 222 | | **`SEAFLY_SHOW_HOST`** | Display the current hostname in the user/host segment.
Set to `0` to not display the host.
Ref to `SEAFLY_SHOW_USERHOST_CONNECTED`. | 1 | 223 | | **`SEAFLY_SHOW_USERHOST_CONNECTED`** | Display the user/host segment only when connected to external hosts.
Set to `0` to always the user/host segment. | 1 | 224 | | **`PROMPT_DIRTRIM`** | Shorten the current directory path to a set maximum number of components.
Set to `0` to not shorten the current path. | 4 | 225 | | **`GIT_PS1_SHOWDIRTYSTATE`** | Indicate the presence of Git modifications.
Set to `0` to skip. | 1 | 226 | | **`GIT_PS1_SHOWSTASHSTATE`** | Indicate the presence of Git stashes.
Set to `0` to skip. | 1 | 227 | | **`GIT_PS1_SHOWUPSTREAM`** | Indicate differences exist between HEAD and upstream in a Git remote-tracking branch.
Set to `0` to skip. | 1 | 228 | 229 | ### Hooks 230 | 231 | | Hook | Description | Default Value | 232 | | ---------------------------------| ------------------------------------------------------------------------------------------------------------| ------------- | 233 | | **`seafly_pre_command_hook`** | A function hook to run each time the prompt is displayed.
Please make sure the hook is fast. | - | 234 | | **`seafly_prompt_prefix_hook`** | A function hook to populate the _optional prefix_ segment.
Please make sure the hook is simple and fast. | - | 235 | 236 | - A **`pre_command_hook`** example that appends and updates history each time 237 | the prompt is executed: 238 | 239 | ```bash 240 | seafly_pre_command_hook="seafly_pre_command" 241 | 242 | seafly_pre_command() { 243 | history -a && history -n 244 | } 245 | ``` 246 | 247 | - A **`prompt_prefix_hook`** example that displays the current Node version if 248 | `package.json` file is present or displays the name of the current Python 249 | virtual environment if one is active in the _optional prefix_ segment: 250 | 251 | ```bash 252 | seafly_prompt_prefix_hook="seafly_prompt_prefix" 253 | 254 | seafly_prompt_prefix() { 255 | if [[ -f package.json ]]; then 256 | echo "($(nvm current))" 257 | elif [[ -n $VIRTUAL_ENV ]]; then 258 | echo "($(basename $VIRTUAL_ENV))" 259 | fi 260 | } 261 | ``` 262 | 263 | ### Symbols 264 | 265 | | Option | Description | Default Value | 266 | | ------------------------------ | ------------------------------------------------------------------------------------- | ------------- | 267 | | **`SEAFLY_PROMPT_SYMBOL`** | The prompt symbol | ❯ | 268 | | **`SEAFLY_PS2_PROMPT_SYMBOL`** | The `PS2` secondary prompt symbol | ❯ | 269 | | **`SEAFLY_GIT_PREFIX`** | Symbol to the left of the Git branch |  | 270 | | **`SEAFLY_GIT_SUFFIX`** | Symbol to the right of the Git indicators | - | 271 | | **`SEAFLY_GIT_DIRTY`** | Symbol indicating that a Git repository contains modifications | ✗ | 272 | | **`SEAFLY_GIT_STAGED`** | Symbol indicating that a Git repository contains staged changes | ✓ | 273 | | **`SEAFLY_GIT_STASH`** | Symbol indicating that a Git repository contains one or more stashes | ⚑ | 274 | | **`SEAFLY_GIT_AHEAD`** | Symbol indicating that a Git remote-tracking branch is ahead of upstream | ↑ | 275 | | **`SEAFLY_GIT_BEHIND`** | Symbol indicating that a Git remote-tracking branch is behind upstream | ↓ | 276 | | **`SEAFLY_GIT_DIVERGED`** | Symbol indicating that a Git remote-tracking branch is both ahead and behind upstream | ↕ | 277 | 278 | ### Colors 279 | 280 | The default color values listed below, such as `111` and `203`, derive from 281 | xterm 256 color values. Please refer to [this 282 | chart](https://jonasjacek.github.io/colors) when customizing _seafly_ colors. 283 | 284 | | Option | Description | Default Value | Color | 285 | | -------------------------- | -------------------------------------------- | ------------- | ------------------------------------------------- | 286 | | **`SEAFLY_PREFIX_COLOR`** | _Optional prefix_ segment | `217` | ![normal](https://place-hold.it/32/5fd7af?text=+) | 287 | | **`SEAFLY_SUCCESS_COLOR`** | Standard prompt and certain Git indicators | `111` | ![normal](https://place-hold.it/32/87afff?text=+) | 288 | | **`SEAFLY_ALERT_COLOR`** | Alert prompt and Git dirty indicator | `203` | ![normal](https://place-hold.it/32/ff5f5f?text=+) | 289 | | **`SEAFLY_HOST_COLOR`** | Host segment | `255` | ![normal](https://place-hold.it/32/eeeeee?text=+) | 290 | | **`SEAFLY_GIT_COLOR`** | Git branch, stash and optional prefix/suffix | `147` | ![normal](https://place-hold.it/32/afafff?text=+) | 291 | | **`SEAFLY_PATH_COLOR`** | Current directory path | `114` | ![normal](https://place-hold.it/32/87d787?text=+) | 292 | 293 | Sponsor 294 | ------- 295 | 296 | [![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/bluz71) 297 | 298 | License 299 | ------- 300 | 301 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 302 | --------------------------------------------------------------------------------