Last active
January 12, 2022 19:48
-
-
Save theffc/75ebea64a1ed32cea14961abf175a524 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fish_prompt | |
# This prompt shows: | |
# - green lines if the last return command is OK, red otherwise | |
# - your user name, in red if root or yellow otherwise | |
# - your hostname, in cyan if ssh or blue otherwise | |
# - the current path (with prompt_pwd) | |
# - date +%X | |
# - the current virtual environment, if any | |
# - the current git status, if any, with fish_git_prompt | |
# - the current battery state, if any, and if your power cable is unplugged, and if you have "acpi" | |
# - current background jobs, if any | |
# It goes from: | |
# ┬─[nim@Hattori:~]─[11:39:00] | |
# ╰─>$ echo here | |
# To: | |
# ┬─[nim@Hattori:~/w/dashboard]─[11:37:14]─[V:django20]─[G:master↑1|●1✚1…1]─[B:85%, 05:41:42 remaining] | |
# │ 2 15054 0% arrêtée sleep 100000 | |
# │ 1 15048 0% arrêtée sleep 100000 | |
# ╰─>$ echo there | |
set -l retc red | |
test $status = 0; and set retc green | |
set -q __fish_git_prompt_showupstream | |
or set -g __fish_git_prompt_showupstream auto | |
function _nim_prompt_wrapper | |
set retc $argv[1] | |
set field_name $argv[2] | |
set field_value $argv[3] | |
set_color normal | |
set_color $retc | |
echo -n '─' | |
set_color $retc | |
echo -n '[' | |
set_color normal | |
test -n $field_name | |
and echo -n $field_name | |
set_color $retc | |
echo -n $field_value | |
set_color $retc | |
echo -n ']' | |
end | |
set_color $retc | |
echo -n '┬─[' | |
set_color -o blue | |
set -g fish_prompt_pwd_dir_length 13 | |
echo -n (prompt_pwd) | |
set_color $retc | |
echo -n ']' | |
# Date | |
_nim_prompt_wrapper $retc '' (date +%X) | |
# Virtual Environment | |
set -q VIRTUAL_ENV_DISABLE_PROMPT | |
or set -g VIRTUAL_ENV_DISABLE_PROMPT true | |
set -q VIRTUAL_ENV | |
and _nim_prompt_wrapper $retc V (basename "$VIRTUAL_ENV") | |
# git | |
set prompt_git (fish_git_prompt | string trim -c ' ()') | |
test -n "$prompt_git" | |
and _nim_prompt_wrapper $retc '⑂' $prompt_git | |
# Battery status | |
type -q acpi | |
and test (acpi -a 2> /dev/null | string match -r off) | |
and _nim_prompt_wrapper $retc B (acpi -b | cut -d' ' -f 4-) | |
# New line | |
echo | |
# Background jobs | |
set_color normal | |
for job in (jobs) | |
set_color $retc | |
echo -n '│ ' | |
set_color brown | |
echo $job | |
end | |
set_color normal | |
set_color $retc | |
echo -n '╰─> ' | |
set_color normal | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment