2012-09-06 16:30:26 +08:00
|
|
|
|
# name: Nim
|
|
|
|
|
# author: Guilhem "Nim" Saurel − https://github.com/nim65s/dotfiles/
|
|
|
|
|
|
2018-07-06 04:30:52 +08:00
|
|
|
|
# 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 __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 -o green
|
|
|
|
|
echo -n '['
|
|
|
|
|
set_color normal
|
|
|
|
|
test -n $field_name
|
|
|
|
|
and echo -n $field_name:
|
|
|
|
|
set_color $retc
|
|
|
|
|
echo -n $field_value
|
|
|
|
|
set_color -o green
|
|
|
|
|
echo -n ']'
|
|
|
|
|
end
|
|
|
|
|
|
2012-09-06 16:30:26 +08:00
|
|
|
|
function fish_prompt
|
2016-11-02 10:19:45 +08:00
|
|
|
|
and set retc green
|
|
|
|
|
or set retc red
|
2012-09-06 16:30:26 +08:00
|
|
|
|
|
|
|
|
|
set_color $retc
|
2018-07-06 04:30:52 +08:00
|
|
|
|
echo -n '┬─'
|
2012-09-06 16:30:26 +08:00
|
|
|
|
set_color -o green
|
|
|
|
|
echo -n [
|
2017-07-21 01:45:32 +08:00
|
|
|
|
if test "$USER" = root -o "$USER" = toor
|
2012-09-06 16:30:26 +08:00
|
|
|
|
set_color -o red
|
|
|
|
|
else
|
|
|
|
|
set_color -o yellow
|
|
|
|
|
end
|
|
|
|
|
echo -n $USER
|
|
|
|
|
set_color -o white
|
|
|
|
|
echo -n @
|
|
|
|
|
if [ -z "$SSH_CLIENT" ]
|
|
|
|
|
set_color -o blue
|
|
|
|
|
else
|
|
|
|
|
set_color -o cyan
|
|
|
|
|
end
|
2016-10-24 06:02:14 +08:00
|
|
|
|
echo -n (prompt_hostname)
|
2012-09-06 16:30:26 +08:00
|
|
|
|
set_color -o white
|
2018-07-06 04:30:52 +08:00
|
|
|
|
echo -n :(prompt_pwd)
|
2012-09-06 16:30:26 +08:00
|
|
|
|
set_color -o green
|
|
|
|
|
echo -n ']'
|
2016-11-02 10:19:45 +08:00
|
|
|
|
|
2018-07-06 04:30:52 +08:00
|
|
|
|
# Date
|
|
|
|
|
_nim_prompt_wrapper $retc '' (date +%X)
|
|
|
|
|
|
|
|
|
|
# Virtual Environment
|
|
|
|
|
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 G $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
|
2012-09-06 16:30:26 +08:00
|
|
|
|
echo
|
2018-07-06 04:30:52 +08:00
|
|
|
|
|
|
|
|
|
# Background jobs
|
2012-09-06 16:30:26 +08:00
|
|
|
|
set_color normal
|
|
|
|
|
for job in (jobs)
|
|
|
|
|
set_color $retc
|
2018-07-06 04:30:52 +08:00
|
|
|
|
echo -n '│ '
|
2012-09-06 16:30:26 +08:00
|
|
|
|
set_color brown
|
|
|
|
|
echo $job
|
|
|
|
|
end
|
|
|
|
|
set_color normal
|
|
|
|
|
set_color $retc
|
2018-07-06 04:30:52 +08:00
|
|
|
|
echo -n '╰─>'
|
2012-09-06 16:30:26 +08:00
|
|
|
|
set_color -o red
|
|
|
|
|
echo -n '$ '
|
|
|
|
|
set_color normal
|
|
|
|
|
end
|