Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3a609c9
fish_prompt: support virtual environments in .venv
Jan 25, 2022
c7ab2ff
fish_prompt: use a more appropriate emoji for command duration
Jan 25, 2022
51683aa
fish_prompt: shorten branch names with multiple namespaces
Jan 25, 2022
42988f7
fish_prompt: adjust ruby version display
scorphus May 30, 2022
7af16aa
fish_*prompt: support swapping command duration and current time
scorphus May 30, 2022
eb296a9
fish_prompt: fall back to ruby --version when rbenv reports none
scorphus Feb 15, 2024
cbf4847
fish_title: show virtualenv in title if activated
scorphus Mar 2, 2025
b13be35
fish_prompt: remove special chars
scorphus Mar 2, 2025
432dcc7
fish_prompt: fall back to python3 when python is not available
scorphus Jun 7, 2026
00509ce
fish_prompt: refresh Rust version after any rustup command
scorphus Jun 7, 2026
064ee68
fish_prompt: show short SHA in detached HEAD
scorphus Jun 8, 2026
89c78b1
fish_prompt: count ahead commits with rev-list --count
scorphus Jun 8, 2026
ec33bf1
fish_prompt: filter dirty-remotes loop with contains, not grep
scorphus Jun 8, 2026
27c431e
fish_prompt: take pwd color as a parameter
scorphus Jun 8, 2026
f96ee8e
fish_right_prompt: print separator with printf instead of echo
scorphus Jun 8, 2026
5167883
fish_prompt: drop unused append parameter from _prompt_versions
scorphus Jun 8, 2026
e87993b
fish_prompt: drop external tr from _prompt_versions pipeline
scorphus Jun 8, 2026
de6ca64
fish_prompt, fish_title: drop blank lines inside function bodies
scorphus Nov 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ set -g theme_display_pwd_on_second_line yes

```fish
set -g theme_display_git_on_first_line yes
```

* To display command duration in right prompt:

```fish
set -g theme_display_command_duration_in_right_prompt yes

```
Comment on lines +44 to 49

* To omit only dirty status of current local Git repository and have
Expand Down
63 changes: 34 additions & 29 deletions functions/fish_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,41 @@
function _prompt_rubies -a color -d 'Display current Ruby (rvm/rbenv)'
type -q ruby; or return
[ "$theme_display_ruby" = 'no' ]; and return
set -gx ruby_version
if type -q rvm-prompt
if [ "$RUBY_VERSION" != "$LAST_RUBY_VERSION" -o -z "$ruby_version" ]
set -gx ruby_version (rvm-prompt i v g)
set -gx LAST_RUBY_VERSION $RUBY_VERSION
end
else if type -q rbenv
set -gx ruby_version (rbenv version-name)
else if [ -z "$ruby_version" ]
end
if test -z "$ruby_version"; or [ (type -P ruby) != "$LAST_RUBY_PATH" ]
set -gx ruby_version (ruby --version | cut -d\ -f2)
set -gx LAST_RUBY_PATH (type -P ruby)
end
echo -n -s $color (echo -n -s $ruby_version | cut -d- -f2-)
end

function _prompt_virtualenv -a color -d "Display currently activated Python virtual environment"
type -q python; or return
set -l python_cmd python
type -q $python_cmd; or set python_cmd python3
type -q $python_cmd; or return
[ "$theme_display_virtualenv" = 'no' ]; and return
if [ "$VIRTUAL_ENV" != "$LAST_VIRTUAL_ENV" -o -z "$PYTHON_VERSION" ]
set -gx PYTHON_VERSION (python --version 2>&1 | cut -d\ -f2)
set -gx PYTHON_VERSION ($python_cmd --version 2>&1 | cut -d\ -f2)
set -gx LAST_VIRTUAL_ENV $VIRTUAL_ENV
end
echo -n -s $color $PYTHON_VERSION
[ -n "$VIRTUAL_ENV" ]; and echo -n -s '@'(basename "$VIRTUAL_ENV")
set venv_name (basename "$VIRTUAL_ENV")
test $venv_name = ".venv"; and set venv_name (basename (dirname "$VIRTUAL_ENV"))
[ -n "$VIRTUAL_ENV" ]; and echo -n -s '@'$venv_name
Comment on lines +39 to +41
end

function _prompt_rust -a color -d "Display currently activated Rust"
type -q rustc; or return
[ "$theme_display_rust" != 'yes' ]; and return
if echo $history[1] | grep -q 'rustup default'; or not set -q RUST_VERSION
if string match -q 'rustup *' $history[1]; or not set -q RUST_VERSION
set -U RUST_VERSION (rustc --version | cut -d\ -f2)
end
echo -n -s $color $RUST_VERSION
Expand All @@ -61,26 +68,28 @@ function _prompt_whoami -a sep_color -a color -d "Display user@host if on a SSH
end

function _git_branch_name
echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
set -l branch (command git symbolic-ref --short HEAD 2> /dev/null)
if test -z "$branch"
set -l sha (command git rev-parse --short HEAD 2> /dev/null)
test -n "$sha"; and set branch ":$sha"
end
echo $branch
end

function _is_git_dirty
echo (command git status -s --ignore-submodules=dirty 2> /dev/null)
end

function _git_ahead_count -a remote -a branch_name
echo (command git log $remote/$branch_name..HEAD 2> /dev/null | \
grep '^commit' | wc -l | tr -d ' ')
command git rev-list --count $remote/$branch_name..HEAD 2> /dev/null
end

function _git_dirty_remotes -a remote_color -a ahead_color
set current_branch (command git rev-parse --abbrev-ref HEAD 2> /dev/null)
set current_ref (command git rev-parse HEAD 2> /dev/null)

for remote in (git remote | grep 'origin\|upstream')

for remote in (command git remote)
contains $remote origin upstream; or continue
set -l git_ahead_count (_git_ahead_count $remote $current_branch)

set remote_branch "refs/remotes/$remote/$current_branch"
set remote_ref (git for-each-ref --format='%(objectname)' $remote_branch)
if test "$remote_ref" != ''
Expand All @@ -94,22 +103,19 @@ function _git_dirty_remotes -a remote_color -a ahead_color
end
end

function _prompt_versions -a blue gray green orange red append
function _prompt_versions -a blue gray green orange red
set -l prompt_rubies (_prompt_rubies $red)

set -l prompt_virtualenv (_prompt_virtualenv $blue)

set -l prompt_rust (_prompt_rust $orange)

set -l prompt_node (_prompt_node $green)

echo -n -e -s "$prompt_rubies $prompt_virtualenv $prompt_rust $prompt_node" | string trim | string replace -ar " +" "$gray|" | tr -d '\n'
echo -n -e -s "$prompt_rubies $prompt_virtualenv $prompt_rust $prompt_node" | string trim | string replace -ar " +" "$gray|"
end

function _prompt_git -a gray normal orange red yellow
test "$theme_display_git" = no; and return
set -l git_branch (_git_branch_name)
test -z $git_branch; and return
set git_branch (string replace -ar '(\.?[^/]{1})[^/]*/' '$1/' $git_branch)
Comment on lines 116 to +118
if test "$theme_display_git_dirty" = no
echo -n -s $gray '‹' $yellow $git_branch $gray '› '
return
Expand All @@ -122,9 +128,8 @@ function _prompt_git -a gray normal orange red yellow
end
end

function _prompt_pwd
set_color -o cyan
printf '%s' (prompt_pwd)
function _prompt_pwd -a color
printf '%s%s' $color (prompt_pwd)
end

function _prompt_status_arrows -a exit_code
Expand All @@ -142,27 +147,27 @@ end

function fish_prompt
set -l exit_code $status

set -l gray (set_color 666)
set -l blue (set_color blue)
set -l red (set_color red)
set -l normal (set_color normal)
set -l yellow (set_color yellow)
set -l orange (set_color ff9900)
set -l green (set_color green)

set -l cyan (set_color -o cyan)
printf $gray'['

_prompt_whoami $gray $green

if test "$theme_display_pwd_on_second_line" != yes
_prompt_pwd
_prompt_pwd $cyan
printf '%s|' $gray
end

_prompt_versions $blue $gray $green $orange $red

printf '%s] ⚡️ %0.3fs' $gray (math $CMD_DURATION / 1000)
if test "$theme_display_command_duration_in_right_prompt" != yes
printf '%s] … %0.3fs ' $gray (math $CMD_DURATION / 1000)
else
printf '%s] %s ' $gray (date +%H:%M:%S)
end

if set -q SCORPHISH_GIT_INFO_ON_FIRST_LINE
set theme_display_git_on_first_line
Expand All @@ -174,7 +179,7 @@ function fish_prompt

if test "$theme_display_pwd_on_second_line" = yes
printf $gray'\n‹'
_prompt_pwd
_prompt_pwd $cyan
printf $gray'›'
end

Expand Down
8 changes: 6 additions & 2 deletions functions/fish_right_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ function fish_right_prompt
end
printf '%d' $exit_code
set_color -o 666
echo '|'
printf '|'
set_color -o 777
printf '%s' (date +%H:%M:%S)
if test "$theme_display_command_duration_in_right_prompt" != yes
printf '%s' (date +%H:%M:%S)
else
printf '%0.3fs' (math $CMD_DURATION / 1000)
end
set_color normal
end
11 changes: 7 additions & 4 deletions functions/fish_title.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
# https://opensource.org/licenses/MIT
# Copyright (c) 2014, Pablo S. Blum de Aguiar <scorphus@gmail.com>


function fish_title
if [ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" ]
printf '(%s) %s' $_ (prompt_pwd)
set -l bin_venv
if test "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV"
set bin_venv "($_)"
else
printf '(%s) %s' (basename "$VIRTUAL_ENV") (prompt_pwd)
set -l venv (basename "$VIRTUAL_ENV")
test "$venv" = ".venv"; and set venv (basename (dirname "$VIRTUAL_ENV"))
set bin_venv "($_) <$venv>"
Comment thread
scorphus marked this conversation as resolved.
end
printf " %s %s [%s] " $bin_venv (prompt_pwd) (hostname)
end