-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
148 lines (114 loc) · 3.74 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
autoload -Uz compinit colors vcs_info
colors
typeset -i updated_at=$(date +'%j' -r ~/.zcompdump 2>/dev/null || stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)
if [ $(date +'%j') != $updated_at ]; then
compinit -i
else
compinit -C -i
fi
zmodload -i zsh/complist
REPORTTIME=3
HISTFILE=$HOME/.zsh_history
HISTSIZE=100000
SAVEHIST=$HISTSIZE
setopt inc_append_history
setopt extended_history
setopt hist_ignore_all_dups
setopt hist_reduce_blanks
setopt hist_ignore_space
setopt share_history
setopt auto_cd
unsetopt correct_all
setopt correct
setopt auto_list
setopt auto_menu
setopt always_to_end
setopt prompt_subst
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git*' formats "%F{yellow}%b%f %m%u%c"
zstyle ':vcs_info:git*' actionformats "%F{yellow}%b%f %F{red}•%a%f %m%u%c"
zstyle ':vcs_info:*' unstagedstr '%F{yellow}!%f'
zstyle ':vcs_info:*' stagedstr '%F{green}+%f'
zstyle ':vcs_info:git*+set-message:*' hooks clear-misc git-st git-untracked
+vi-clear-misc() {
hook_com[misc]=""
}
+vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
git status --porcelain | grep '??' &> /dev/null ; then
hook_com[misc]+='%F{red}?%f'
fi
}
+vi-git-st() {
local ahead behind ahead_fmt behind_fmt
local -a gitstatus
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l | tr -d ' ')
(( $ahead )) && ahead_fmt=$(echo "${ahead}" | sed 's/1/¹/g; s/2/²/g; s/3/³/g; s/4/⁴/g; s/5/⁵/g; s/6/⁶/g; s/7/⁷/g; s/8/⁸/g; s/9/⁹/g; s/0/⁰/g;') && gitstatus+=( "%F{magenta}↥${ahead_fmt}%f " )
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l | tr -d ' ')
(( $behind )) && behind_fmt=$(echo "${behind}" | sed 's/1/₁/g; s/2/₂/g; s/3/₃/g; s/4/₄/g; s/5/₅/g; s/6/₆/g; s/7/₇/g; s/8/₈/g; s/9/₉/g; s/0/₀/g;') && gitstatus+=( "%F{blue}↧${behind_fmt}%f " )
hook_com[misc]+="${gitstatus}"
}
precmd () {
vcs_info
}
function ssh_prompt () {
if [[ -n $SSH_CONNECTION ]]; then
echo '%F{blue}⌈ssh⌋%f '
fi
}
function user_host_prompt () {
if [[ -n $SSH_CONNECTION ]]; then
local fqdn
fqdn=$(hostname -f)
if [[ $UID -eq 0 ]]; then
echo "%B%F{red}%n%f%F{white}@%f%F{red}${fqdn}%f%b "
else
echo "%B%F{white}%n%f%F{red}@%f%F{white}${fqdn}%f%b "
fi
else
if [[ $UID -eq 0 ]]; then
echo '%B%F{red}%n%f '
fi
fi
}
function pwd_prompt () {
echo '%B%F{cyan}%(4~|…/%3~|%~)%f%b '
}
function chpwd () {
if [ -d "$OLDPWD" ] && [ -r "$OLDPWD/.zsh-leave" ]; then
source "$OLDPWD/.zsh-leave"
fi
if [ -r "$PWD/.zsh-enter" ]; then
source "$PWD/.zsh-enter"
fi
}
PROMPT=$'$(ssh_prompt)$(user_host_prompt)$(pwd_prompt)${vcs_info_msg_0_}%E\n%B%(?.%F{green}.%F{red})⮞%f%b%E '
# user-friendly command output
export CLICOLOR=1
ls --color=auto &> /dev/null && alias ls='ls --color=auto'
alias l='ls -a -l -F -h'
export EDITOR=vim
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'
alias ......='cd ../../../../../'
UPDATED_PATH="$PATH"
if [ -d "$HOME/.rd/bin" ]; then
UPDATED_PATH="$UPDATED_PATH:$HOME/.rd/bin"
fi
if command -v pyenv &> /dev/null; then
UPDATED_PATH="$(pyenv root)/shims:$UPDATED_PATH"
eval "$(pyenv init -)"
fi
export PATH="$UPDATED_PATH"
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK="$HOME/.ssh/agent"
if [ -s "/opt/homebrew/bin/brew" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
export HOMEBREW_NO_AUTO_UPDATE="1"
fi
[ -d "/opt/homebrew/opt/nvm" ] && export NVM_DIR="$HOME/.nvm"
[ -s "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" ] && \. "$HOMEBREW_PREFIX/opt/nvm/nvm.sh"