-
Notifications
You must be signed in to change notification settings - Fork 0
/
fish_prompt.fish
52 lines (46 loc) · 1.59 KB
/
fish_prompt.fish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function fish_prompt
# Capture exit status
test "$status" -eq 0
and set -l color cyan
or set -l color red
# Configure __fish_git_prompt
set -g __fish_git_prompt_char_stateseparator ' '
set -g __fish_git_prompt_color white
set -g __fish_git_prompt_color_flags red
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
set -g __fish_git_prompt_color white
set -g __fish_git_prompt_color_flags red
set -g __fish_git_prompt_color_prefix $color
set -g __fish_git_prompt_color_suffix $color
# Setup colors
set -l reg (set_color normal)
set color $reg(set_color $color)
# Declare variables
set --query __fish_prompt_hostname
or set __fish_prompt_hostname (command hostname \
| string match -v localhost \
| cut -d . -f 1)
set -l cwd (realpath $PWD 2>/dev/null | string replace ~ '~')
set -l length (string length "$USER$__fish_prompt_hostname$cwd")
set -l max_length (math "$COLUMNS - 12")
if test $length -ge $max_length
set cwd (prompt_pwd)
set length (string length "$USER$__fish_prompt_hostname$cwd")
end
if not set --query __fish_prompt_char
test (id -u) -eq 0
and set -g __fish_prompt_char '#'
or set -g __fish_prompt_char '>'
end
# Line 1
echo -n $color'┌['$reg"$USER"
test -z "$__fish_prompt_hostname"
or echo -n $color'@'$reg"$__fish_prompt_hostname"
echo -n $color']-('$reg"$cwd"$color')'$reg
__fish_git_prompt "-[%s]"
# Line 2
echo -ne \n$color'└'$__fish_prompt_char $reg
end