fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
867946468
master
1# name: Nim 2# author: Guilhem "Nim" Saurel − https://github.com/nim65s/dotfiles/ 3 4function fish_prompt 5# This prompt shows: 6# - green lines if the last return command is OK, red otherwise 7# - your user name, in red if root or yellow otherwise 8# - your hostname, in cyan if ssh or blue otherwise 9# - the current path (with prompt_pwd) 10# - date +%X 11# - the current virtual environment, if any 12# - the current git status, if any, with fish_git_prompt 13# - the current battery state, if any, and if your power cable is unplugged, and if you have "acpi" 14# - current background jobs, if any 15 16# It goes from: 17# ┬─[nim@Hattori:~]─[11:39:00] 18# ╰─>$ echo here 19 20# To: 21# ┬─[nim@Hattori:~/w/dashboard]─[11:37:14]─[V:django20]─[G:master↑1|●1✚1…1]─[B:85%, 05:41:42 remaining] 22# │ 2 15054 0% arrêtée sleep 100000 23# │ 1 15048 0% arrêtée sleep 100000 24# ╰─>$ echo there 25 26set -l retc red 27test $status = 0 ;and set retc green 28 29set -q __fish_git_prompt_showupstream 30or set -g __fish_git_prompt_showupstream auto 31 32function _nim_prompt_wrapper 33set retc$argv [ 1 ] 34set -l field_name$argv [ 2 ] 35set -l field_value$argv [ 3 ] 36 37set_color --reset 38set_color $retc 39echo -n'─' 40set_color -o green 41echo -n'[' 42set_color --reset 43test -n $field_name 44and echo -n$field_name : 45set_color $retc 46echo -n$field_value 47set_color -o green 48echo -n']' 49end 50 51set_color $retc 52echo -n'┬─' 53set_color -o green 54echo -n[ 55 56if functions -q fish_is_root_user;and fish_is_root_user 57set_color -o red 58else 59set_color -o yellow 60end 61 62echo -n$USER 63set_color -o white 64echo -n @ 65 66if test -z " $SSH_CLIENT " 67set_color -o blue 68else 69set_color -o cyan 70end 71 72echo -n( prompt_hostname ) 73set_color -o white 74echo -n :( prompt_pwd ) 75set_color -o green 76echo -n']' 77 78# Date 79_nim_prompt_wrapper $retc '' ( date +%X) 80 81# Vi-mode 82 83if test " $fish_key_bindings " = fish_vi_key_bindings 84or test " $fish_key_bindings " = fish_hybrid_key_bindings 85set -l mode 86switch $fish_bind_mode 87case default 88set mode( set_color --bold red) N 89case operator f F t T 90set mode( set_color --bold cyan) N 91case insert 92set mode( set_color --bold green) I 93case replace_one 94set mode( set_color --bold green) R 95case replace 96set mode( set_color --bold cyan) R 97case visual 98set mode( set_color --bold magenta) V 99end 100set mode$mode ( set_color --reset) 101_nim_prompt_wrapper $retc '' $mode 102end 103 104# Virtual Environment 105set -q VIRTUAL_ENV_DISABLE_PROMPT 106or set -g VIRTUAL_ENV_DISABLE_PROMPT true 107set -q VIRTUAL_ENV 108and _nim_prompt_wrapper $retc V( path basename" $VIRTUAL_ENV " ) 109 110# git 111set -l prompt_git( fish_git_prompt '%s' ) 112test -n " $prompt_git " 113and _nim_prompt_wrapper $retc G$prompt_git 114 115# Battery status 116type -q acpi 117and acpi -a2> /dev/null| string match -rq off 118and _nim_prompt_wrapper $retc B( acpi -b| cut -d' ' -f 4-) 119 120# New line 121echo 122 123# Background jobs 124set_color --reset 125 126for jobin ( jobs ) 127set_color $retc 128echo -n'│ ' 129set_color brown 130echo $job 131end 132 133set_color --reset 134set_color $retc 135echo -n'╰─>' 136set_color -o red 137echo -n'$ ' 138set_color --reset 139end 140 141# The default mode prompt would be prefixed, which ruins our alignment. 142function fish_mode_prompt 143end