-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathz_all
108 lines (90 loc) · 1.86 KB
/
z_all
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
export TERM=xterm-256color
export GREP_COLOR=42
export EDITOR=vim
alias ls='ls -h --color'
alias l='ls'
alias ll='ls -l'
alias lg='ls | grep'
alias llg='ll | grep'
alias la='ls -a'
alias lla='ll -a'
alias llag='lla | grep'
alias grep='grep --color'
alias hexedit='hexedit --color'
alias dbox='dosbox -c dosbox.conf'
export PATH=$PATH:~/Projects/bash-tools
bindkey '^R' history-incremental-pattern-search-backward
zmodload zsh/nearcolor
function is_git() {
if [[ "$(git status >/dev/null 2>&1;echo $?)" == "0" ]]; then
echo 1;
else
echo 0;
fi
}
function git_prompt_current_branch() {
git branch | grep \* | cut -d' ' -f2-
}
function git_prompt_changes() {
local changes=$(git status -s | sed 's/^\ //g' | cut -d' ' -f1 | sort | uniq -c | tr '\n' ' ' | sed 's/\ //g')
if [ -z "$changes" ]; then
echo '';
else
echo "($changes)"
fi
}
function rainbow_color() {
hue="$1"
(( section = hue / 16 ))
case $section in
0) ((r = 15))
((g = hue % 16))
((b = 0))
;;
1) ((r = 15 - hue % 16))
((g = 15))
((b = 0))
;;
2) ((r = 0))
((g = 15))
((b = hue % 16))
;;
3) ((r = 0))
((g = 15 - hue % 16))
((b = 15))
;;
4) ((r = hue % 16))
((g = 0))
((b = 15))
;;
*) ((r = 15))
((g = 0))
((b = 15 - hue % 16))
;;
esac;
((r = r * 16))
((g = g * 16))
((b = b * 16))
printf "#%02X%02X%02X" $r $g $b
}
function rainbowz() {
local text="$1"
local len=${#text}
local i
for i in $(seq 0 $len); do
(( x = i * 100 / len ))
local color="$(rainbow_color $x)"
echo -n "%{%F{$color}%}${text[$i+1]}"
done
echo -n "%{%f%}"
}
function git_prompt() {
if [[ $(is_git) -eq 1 ]]; then
GIT_PS1="#$(git_prompt_current_branch)$(git_prompt_changes)";
GIT_PS1=$(rainbowz "$GIT_PS1 ")
else
GIT_PS1='';
fi
export PS1="[%{%F{#0ff}%}%n%{%f%}@%{%F{#f0f}%}%m%{%f%}] %1~ $GIT_PS1%(?.🤓.😢)%# "
}
precmd() { git_prompt }