-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfish_prompt.fish
119 lines (96 loc) · 2.72 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Status Chars
set __fish_git_prompt_char_dirtystate '!'
set __fish_git_prompt_char_untrackedfiles '☡'
set __fish_git_prompt_char_stashstate '↩'
set __fish_git_prompt_char_cleanstate '✓'
# Display the state of the branch when inside of a git repo
function __simple_ass_prompt_parse_git_branch_state -d "Display the state of the branch"
git update-index --really-refresh -q 1> /dev/null
# Check for changes to be commited
if git_is_touched
echo -n "$__fish_git_prompt_char_dirtystate"
else
echo -n "$__fish_git_prompt_char_cleanstate"
end
# Check for untracked files
set -l git_untracked (command git ls-files --others --exclude-standard 2> /dev/null)
if [ -n "$git_untracked" ]
echo -n "$__fish_git_prompt_char_untrackedfiles"
end
# Check for stashed files
if git_is_stashed
echo -n "$__fish_git_prompt_char_stashstate"
end
# Check if branch is ahead, behind or diverged of remote
git_ahead
end
# Display current git branch
function __simple_ass_prompt_git -d "Display the actual git branch"
set -l ref
set -l std_prompt (prompt_pwd)
set -l is_dot_git (string match '*/.git' $std_prompt)
if git_is_repo; and test -z $is_dot_git
printf 'on '
set_color purple
set -l git_branch (command git symbolic-ref --quiet --short HEAD 2> /dev/null; or git rev-parse --short HEAD 2> /dev/null; or echo -n '(unknown)')
printf '%s ' $git_branch
set state (__simple_ass_prompt_parse_git_branch_state)
set_color 0087ff
printf '[%s]' $state
set_color normal
end
end
# Print current user
function __simple_ass_prompt_get_user -d "Print the user"
if test $USER = 'root'
set_color red
else
set_color d75f00
end
printf '%s' (whoami)
end
# Get Machines Hostname
function __simple_ass_prompt_get_host -d "Get Hostname"
if test $SSH_TTY
tput bold
set_color red
else
set_color af8700
end
printf '%s' (hostname|cut -d . -f 1)
end
# Get Project Working Directory
function __simple_ass_prompt_pwd -d "Get PWD"
set_color $fish_color_cwd
printf '%s ' (prompt_pwd)
end
# Simple-ass-prompt
function fish_prompt
set -l code $status
# Logged in user
__simple_ass_prompt_get_user
set_color normal
printf ' at '
# Machine logged in to
__simple_ass_prompt_get_host
set_color normal
printf ' in '
# Path
__simple_ass_prompt_pwd
set_color normal
# Git info
__simple_ass_prompt_git
# Line 2
echo
if test -e "Cargo.toml"
printf "(rust:%s) " (set_color red)(rustup show | tail -n 3 | head -n 1 | cut -d '-' -f 1)(set_color normal)
end
if test $VIRTUAL_ENV
printf "(python:%s) " (set_color blue)(basename $VIRTUAL_ENV)(set_color normal)
end
if test $code -eq 127
set_color red
end
printf '↪ '
set_color normal
end