Skip to content

Instantly share code, notes, and snippets.

@PCouaillier
Last active April 24, 2021 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PCouaillier/60e8c33a6d38ba3bff39fbd32977a021 to your computer and use it in GitHub Desktop.
Save PCouaillier/60e8c33a6d38ba3bff39fbd32977a021 to your computer and use it in GitHub Desktop.
fish prompt base on my-aws to a look like zsh candy shell
function fish_prompt --description 'Write out the prompt'
# Cache exit status
set -l last_status $status
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_user
if test (id -u) -eq 0
set -g __fish_user '#'
else
set -g __fish_user '&'
end
end
set -g __fish_prompt_char '><>'
# Setup colors
set -l white (set_color FFFFFF)
set -l turquoise (set_color 5fdfff)
set -l blue (set_color 53D1ED)
set -l dblue (set_color 33A1ED)
set -l green (set_color 87ff00)
set -l greeno (set_color -o 87ff00)
set -l purple (set_color af5fff)
set -l redo (set_color -o FF0000)
set -l yellow (set_color E0D757)
# Configure __fish_git_prompt
set -g __fish_git_prompt_char_stateseparator ' '
set -g __fish_git_prompt_color 5fdfff
set -g __fish_git_prompt_color_flags df5f00
set -g __fish_git_prompt_color_prefix white
set -g __fish_git_prompt_color_suffix white
set -g __fish_git_prompt_showdirtystate true
set -g __fish_git_prompt_showuntrackedfiles true
set -g __fish_git_prompt_showstashstate true
set -g __fish_git_prompt_show_informative_status true
# Env
set -l __work_dir (string replace $HOME '~' (pwd))
# Last status
set __exit_code -1
set -l __prompt 'y'
if test $last_status -eq 0
set __prompt $greeno$__fish_prompt_char$greeno' '
set __exit_code $white'0'
else
set __prompt $redo'x '
set __exit_code $redo$last_status
end
# Time
set -l __time $dblue'['(date +%H:%M:%S)']'
if test (tput cols) -gt 105
if test -s "./package.json"
set __node_v (echo -s (set_color 8CBF3D)" Ⓝ " (node --version | cut -d"." -f 1,2 | cut -c '2-'))
else
set __node_v ""
end
if test -s "./composer.json" -o -s "./composer.lock"
set __php_v (echo -s (set_color B0B3D6)" PHP" (php --version | head -n 1 | cut -c 5-7))
else
set __php_v ""
end
end
# Line
echo -sne '\n'$purple$__fish_user' ' \
$__time$white \
' ['$__work_dir']'$turquoise \
(__fish_git_prompt) \
$__node_v \
$__php_v \
' '$__exit_code \
'\n' \
$__prompt$white;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment