seafly is a modern, informative, and configurable command prompt for the Bash shell.
Inspiration provided by:
🚀 For maximum performance, seafly will use, if available, the excellent gitstatus command.
The font in use is Iosevka.
seafly is a single line prompt that is divided into the following segments:
<Optional Prefix> <Host> <Git Branch> <Git Indicators> <Current Path> <Prompt Symbol>
Note, when SEAFLY_LAYOUT=2
is set the prompt will be:
<Optional Prefix> <Host> <Current Path> <Git Branch> <Git Indicators> <Prompt Symbol>
Please refer to the configuration section below for more details.
-
When in a Git repository the checked out Git branch will be displayed.
-
When in a Git repository, dirty state, upstream and stash indicators will be displayed. Note, these can individually be disabled if desired.
-
The prompt symbol will change to an alert color, by default red, if the last command did not execute successfully.
seafly by default will use Unicode characters for the prompt symbol and certain Git indicators. These symbols will display correctly when using a modern font such as Iosevka.
Also, seafly by default will use colors that favour a dark background.
Both the symbols and colors used by seafly can be overridden, please refer to the configuration section below. As an example, the following configuration will:
- only use ASCII characters
- use colors appropriate for a light terminal theme
- style the Git section to mimic
$(__git_ps1)
provided by thegit-prompt.sh
script that ships with Git
SEAFLY_PROMPT_SYMBOL=">"
SEAFLY_PS2_PROMPT_SYMBOL=">"
SEAFLY_GIT_PREFIX="("
SEAFLY_GIT_SUFFIX=")"
SEAFLY_GIT_DIRTY="*"
SEAFLY_GIT_STASH="$"
SEAFLY_GIT_AHEAD=">"
SEAFLY_GIT_BEHIND="<"
SEAFLY_GIT_DIVERGED="<>"
SEAFLY_NORMAL_COLOR="$(tput setaf 63)"
SEAFLY_ALERT_COLOR="$(tput setaf 202)"
SEAFLY_HOST_COLOR="$(tput setaf 242)"
SEAFLY_GIT_COLOR="$(tput setaf 99)"
SEAFLY_PATH_COLOR="$(tput setaf 70)"
. ~/.bash-seafly-prompt/command_prompt.bash
A modern 256 or true color terminal is required.
Please also make sure the TERM
environment variable is set to either
xterm-256color
or screen-256color
.
Setting TERM
to xterm-256color
is usually done at the terminal level
either in a preferences dialog or a related configuration file, if required at
all. Note, some modern terminals will automatically set 256 colors by default,
for example, modern versions of Gnome
Terminal.
Setting TERM
to screen-256color
should only be done for
tmux sessions. If you are a tmux user then
please add the following to your ~/.tmux.conf
file:
set -g default-terminal "screen-256color"
set -ga terminal-overrides ',xterm-256color:Tc'
Install the seafly prompt script:
git clone --depth 1 https://github.com/bluz71/bash-seafly-prompt ~/.bash-seafly-prompt
Source the seafly prompt script in your ~/.bashrc
file:
. ~/.bash-seafly-prompt/command_prompt.bash
Note, to update to the latest version of seafly:
cd ~/.bash-seafly-prompt
git pull
The gitstatus command, a
high-performance alternative to the git status
command, is designed
specifically for low-latency command prompt usage.
The seafly prompt does not require gitstatus, but it is strongly
recommended to install and use this command, especially when dealing with large
Git repositories. Git detail collation will otherwise fallback to the slower
git
command when gitstatus is not available.
If possible, please install gitstatus:
git clone --depth 1 https://github.com/romkatv/gitstatus.git ~/.gitstatus
If gitstatus is already installed in an alternate directory then please export its location in an environment variable:
export SEAFLY_GITSTATUS_DIR=/location/of/gitstatus
Certain behaviours and visuals of the seafly prompt can be controlled through environment variables.
Note, a dash character denotes an unset default value.
Option | Description | Default Value |
---|---|---|
SEAFLY_PRE_COMMAND |
A command to run each time the prompt is displayed. Please make sure any pre-command is very fast. For example, "history -a" . |
- |
SEAFLY_PROMPT_PREFIX |
A shell script snippet to populate the optional prefix segment. Please make sure the script snippet is simple and fast. Refer to the examples below. |
- |
SEAFLY_SHOW_USER |
Display the current user in the host segment. Set to 1 to display the user. |
0 |
SEAFLY_LAYOUT |
Specify the preferred layout. Layout 1 will display Git details followed by path.Layout 2 will flip the Git details and path. |
1 |
PROMPT_DIRTRIM |
Shorten the current directory path to a set maximum number of components. Set to 0 to not shorten the current path. |
4 |
GIT_PS1_SHOWDIRTYSTATE |
Indicate the presence of Git modifications. Set to 0 to skip. |
1 |
GIT_PS1_SHOWSTASHSTATE |
Indicate the presence of Git stashes. Set to 0 to skip. |
1 |
GIT_PS1_SHOWUPSTREAM |
Indicate differences exist between HEAD and upstream in a Git remote-tracking branch. Set to 0 to skip. |
1 |
🎁 A few SEAFLY_PROMPT_PREFIX
examples:
-
When using the chruby Ruby version manager and when in a Ruby project base directory display the current Ruby version within parenthesis:
SEAFLY_PROMPT_PREFIX='if [[ -f Gemfile ]]; then echo "($(chruby | grep "*" | cut -d" " -f3))"; fi'
-
When in an active Python Virtual Environment display the name of the current environment within parenthesis:
SEAFLY_PROMPT_PREFIX='if [[ -n $VIRTUAL_ENV ]]; then echo "($(basename $VIRTUAL_ENV))"; fi'
💣 In certain Git repositories, calculating dirty-state can be slow,
either due to the size of the repository or the speed of the file-system
hosting the repository. If so, the prompt may render slowly. One can either
set GIT_PS1_SHOWDIRTYSTATE=0
to disable dirty-state indication for all
repositories, or if only a few repositories have performance issues then one
can do the following to skip dirty-state indication on a per-repository basis:
% git config bash.showDirtyState false
🚀 Again, for best prompt rendering performance, when in Git repositories, please install and use the gitstatus command.
Option | Description | Default Value |
---|---|---|
SEAFLY_PROMPT_SYMBOL |
The prompt symbol | ❯ |
SEAFLY_PS2_PROMPT_SYMBOL |
The PS2 secondary prompt symbol |
❯ |
SEAFLY_GIT_PREFIX |
Symbol to the left of the Git branch | - |
SEAFLY_GIT_SUFFIX |
Symbol to the right of the Git indicators | - |
SEAFLY_GIT_DIRTY |
Symbol indicating that a Git repository contains modifications | ✗ |
SEAFLY_GIT_STAGED |
Symbol indicating that a Git repository contains staged changes | ✓ |
SEAFLY_GIT_STASH |
Symbol indicating that a Git repository contains one or more stashes | ⚑ |
SEAFLY_GIT_AHEAD |
Symbol indicating that a Git remote-tracking branch is ahead of upstream | ↑ |
SEAFLY_GIT_BEHIND |
Symbol indicating that a Git remote-tracking branch is behind upstream | ↓ |
SEAFLY_GIT_DIVERGED |
Symbol indicating that a Git remote-tracking branch is both ahead and behind upstream | ↕ |
The default color values listed below, such as 111
and 203
, derive from
xterm 256 color values. Please refer to this
chart when customizing seafly colors.