-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgettowork.zsh-theme
More file actions
69 lines (57 loc) · 2.31 KB
/
gettowork.zsh-theme
File metadata and controls
69 lines (57 loc) · 2.31 KB
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
ZSH_THEME_GIT_PROMPT_PREFIX="[ "
ZSH_THEME_GIT_PROMPT_SUFFIX=" ]"
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
function git_prompt_info() {
local ref
ref=$(git symbolic-ref --quiet HEAD 2> /dev/null) || return
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref#refs/heads/}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
function set_prompt() {
local venv_indicator=''
if [[ -n $VIRTUAL_ENV ]]; then
venv_indicator='%{$fg[white]%}(venv)%{$reset_color%} '
fi
# Inicia o prompt
PROMPT=""
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]]; then
local git_status="$(git status 2> /dev/null)"
# Configura a cor de fundo com base no status do Git
if [[ "$git_status" =~ "Changes not staged for commit" ]]; then
PROMPT='%B%{$BG[001]%}%{$FG[000]%} $(git_prompt_info) %{$reset_color%}%b' # Vermelho
elif [[ "$git_status" =~ "Changes to be committed" ]]; then
PROMPT='%B%{$BG[202]%}%{$FG[000]%} $(git_prompt_info) %{$reset_color%}%b' # Laranja
elif [[ "$git_status" =~ "nothing to commit" ]]; then
PROMPT='%B%{$BG[002]%}%{$FG[000]%} $(git_prompt_info) %{$reset_color%}%b' # Verde
else
PROMPT='%B%{$BG[001]%}%{$FG[000]%} $(git_prompt_info) %{$reset_color%}%b' # Vermelho
fi
local git_tracking_branch=$(git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD))
if [[ -n "$git_tracking_branch" ]]; then
local local_commit=$(git rev-parse @)
local remote_commit=$(git rev-parse "$git_tracking_branch")
local base_commit=$(git merge-base @ "$git_tracking_branch")
if [[ "$local_commit" != "$remote_commit" ]]; then
PROMPT='%B%{$BG[003]%}%{$FG[000]%} $(git_prompt_info) %{$reset_color%}%b' # Azul (mudança necessária)
fi
fi
PROMPT+='
'
fi
PROMPT+="${venv_indicator}%{$FG[006]%}%1/%{$reset_color%} ➙ %b"
}
RPROMPT='%B%{$FG[011]%}[%D{%H:%M:%S}]%{$reset_color%}%b'
# Set prompt on startup
set_prompt
# Update prompt before each command is executed
precmd() {
set_prompt
}
function zle-line-init zle-keymap-select {
case $KEYMAP in
(main|viins|visual|vicmd)
set_prompt
esac
}
typeset -agUz preexec_functions
preexec_functions+='set_prompt'