-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc
152 lines (122 loc) · 3.61 KB
/
dot_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
148
149
150
151
152
# ex: ts=4 sw=4 et filetype=sh
zi_home="${HOME}/.zi" && mkdir -p $zi_home
ZSH_CACHE_DIR="${HOME}/.zsh_cache" && mkdir -p $ZSH_CACHE_DIR
if [ ! -d "${zi_home}/bin" ]; then
git clone git@github.com:z-shell/zi.git "${zi_home}/bin"
fi
source "${zi_home}/bin/zi.zsh"
autoload -Uz _zi
(( ${+_comps} )) && _comps[zi]=_zi
zi snippet https://github.com/caiogondim/bullet-train.zsh/blob/master/bullet-train.zsh-theme
zi snippet OMZ::lib/git.zsh
zi snippet OMZ::plugins/git/git.plugin.zsh
zi snippet OMZ::plugins/minikube/minikube.plugin.zsh
zi light zsh-users/zsh-completions
zi light zdharma/fast-syntax-highlighting
BULLETTRAIN_DIR_EXTENDED=2
BULLETTRAIN_PROMPT_CHAR=%#
BULLETTRAIN_PROMPT_ORDER=(
status
context
dir
git
)
REPORTTIME=5
HISTFILE=~/.zsh_history
SAVEHIST=10000
HISTSIZE=10000
WORDCHARS=${WORDCHARS//[&=\/;\!#%\{]}
export EDITOR=nvim
export VEDITOR=code
export GOPATH=~/src/go
export PATH="$GOPATH/bin:$PATH"
# search history with fzf if installed
if [ -d /usr/local/opt/fzf/shell ]; then
. /usr/local/opt/fzf/shell/key-bindings.zsh
elif [ -d /usr/share/fzf ]; then
. /usr/share/fzf/key-bindings.zsh
fi
if [ -f $HOME/.private_profile ]; then
. $HOME/.private_profile
fi
autoload -Uz colors && colors
autoload -Uz compinit compdef && compinit
autoload -Uz promptinit && promptinit
autoload -Uz bashcompinit && bashcompinit
zi cdreplay >/dev/null
setopt promptsubst
setopt hist_ignore_dups
setopt share_history
setopt HIST_IGNORE_SPACE
setopt APPEND_HISTORY
setopt EXTENDED_HISTORY
bindkey -e
if [[ "$OSTYPE" =~ ^darwin ]]; then
PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH
fi
if [ -x "$(command -v pyenv)" ]; then
eval "$(pyenv init -)"
fi
if [ -x "$(command -v rbenv)" ]; then
eval "$(rbenv init -)"
fi
if [ -x "$(command -v aws_completer)" ]; then
complete -C aws_completer aws
fi
ssh_agent_pid=$(pidof ssh-agent | awk '{print $NF}')
if [[ -z $ssh_agent_pid ]] ; then
eval $(ssh-agent)
else
export SSH_AUTH_SOCK=$(find ${TMPDIR:-/tmp} -path "*ssh*" -type s -iname agent.\* -uid $(id -u) -print 2>/dev/null)
fi
alias ls="ls -G --color"
alias ll="ls -laGh"
alias gs="git status"
alias gd="git diff"
alias sudo="sudo -E"
function take {
mkdir -p $1
cd $1
}
function extract {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
function scratch {
local parent="$HOME/tmp/scratch"
local latest="$parent/latest"
local scratch="$parent/scratch-`date +'%s'`"
mkdir -p $scratch
ln -nfs $scratch $latest
cd $latest
echo "Created $scratch"
}
function brew-cask-upgrade {
(set -x; brew update;)
(set -x; brew cleanup;)
(set -x; brew cask cleanup;)
while read pkg_ver; do
pkg=$(echo ${pkg_ver} | cut -d" " -f1)
brew cask info ${pkg} | head -n1 | tr -d ":" | grep -vqF "${pkg_ver}" \
&& (set -x; brew cask uninstall ${pkg} --force) \
&& (set -x; brew cask install ${pkg} --force)
done < <(brew cask list --versions)
(set -x; brew cleanup;)
(set -x; brew cask cleanup;)
}