This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fish_prompt.fish
67 lines (54 loc) · 1.82 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
# name: clearance
# ---------------
# Based on idan. Display the following bits on the left:
# - Virtualenv name (if applicable, see https://github.com/adambrenecki/virtualfish)
# - Current directory name
# - Git branch and dirty state (if inside a git repo)
# if user is root set a different prompt
set prmt '╰⟩ '
if fish_is_root_user
set prmt '╰# '
end
function _git_branch_name
echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
end
function _git_is_dirty
echo (command git status -s --ignore-submodules=dirty 2> /dev/null)
end
function fish_prompt
set -l last_status $status
set -l cyan (set_color cyan)
set -l yellow (set_color yellow)
set -l red (set_color red)
set -l blue (set_color blue)
set -l green (set_color green)
set -l normal (set_color normal)
# set the default prompt colour to red,
# the the status code was 0 - change it to a different colour
set -l prompt_color $red
if test $last_status = 0
set prompt_color $green
end
# ~
set -l cwd $normal(pwd | sed "s:^$HOME:~:")
# Output the prompt, left to right
# Display [venvname] if in a virtualenv
if set -q VIRTUAL_ENV
echo -n -s (set_color -b cyan black) '[' (basename "$VIRTUAL_ENV") ']' $normal ' '
end
# Print pwd or full path
echo -n -s $prompt_color '╭─ '$normal $USER ' ' $prompt_color at $normal ' ' $hostname $normal ' ' $prompt_color in $normal ' ' $cwd $normal
# Show git branch and status
if [ (_git_branch_name) ]
set -l git_branch (_git_branch_name)
if [ (_git_is_dirty) ]
set git_info '(' $yellow $git_branch $normal ')'
else
set git_info '(' $cyan $git_branch $normal ')'
end
echo -n -s $prompt_color ' ' $normal $git_info $normal
end
# Terminate with a nice prompt char
echo -e ''
echo -e -n -s $prompt_color $prmt $normal
end