-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
104 lines (83 loc) · 1.98 KB
/
.zshrc
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
# ========================================
# GENERAL CONFIG
# ========================================
# Adds tab completion for git
if [ -f $HOME/.git-completion.zsh ]; then
. $HOME/.git-completion.zsh
fi
# Vim keybindings in bash
set -o vi
# Aliases
alias weather="curl wttr.in"
alias vim="nvim"
# Start rbenv
eval "$(rbenv init -)"
# Magic enter
MAGIC_ENTER_MARGIN=" "
function magic_base {
printf "└── "
dirs
echo ""
git -c color.status=always status -sb 2> /dev/null
}
function wrap_output {
local output="$1"
local output_len="$(echo "$output" | sed -n '$=')"
if [ -n "$output" ]; then
if [ "$output_len" -gt "$((LINES - 2))" -a -n "$PAGER" ]; then
printf "$output\n" | "$PAGER" -R
else
printf "$output\n" | sed "s/^/$MAGIC_ENTER_MARGIN/"
fi
fi
}
function magic_enter {
if [ -z $BUFFER ]; then
echo ""
wrap_output "$(magic_base)"
zle redisplay
else
zle accept-line
fi
}
zle -N magic_enter
bindkey "^M" magic_enter
# ========================================
# PROMPT
# ========================================
ICO_DIRTY="*"
ICO_AHEAD="↑"
ICO_BEHIND="↓"
ICO_DIVERGED="⥮"
# Allow functions in the prompt
setopt PROMPT_SUBST
autoload -Uz colors && colors
# Git prompt
function fg_color {
local is_git_repo=$(git rev-parse --is-inside-work-tree 2> /dev/null)
if [ ! "$is_git_repo" ]; then
echo 007 # bright white
else
if ! git diff-files --quiet; then
echo 009 # bright red
elif ! git diff-index --quiet --cached $(git write-tree) --; then
echo 011 # bright yellow
else
echo 010 # bright green
fi
fi
}
PROMPT='%F{$(fg_color)} $ %f%k'
# ========================================
# PLUGINS
# ========================================
. ~/.zplug/init.zsh
zplug "zsh-users/zsh-autosuggestions"
# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
zplug load