-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
201 lines (130 loc) · 4.28 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
export ZSH=~/.oh-my-zsh
ZSH_THEME="xiong-chiamiov-plus"
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
#ZSH_THEME="bullet-train"
###### Completion
ENABLE_CORRECTION="false"
COMPLETION_WAITING_DOTS="true"
autoload -U bashcompinit
autoload -U incremental-complete-word
autoload -U compinit
bashcompinit
compinit -C
zmodload zsh/complist
###### Plugins
plugins=(git common-aliases gradle alias-tips gitignore zsh-autosuggestions yarn zsh-syntax-highlighting)
###### Utils
# Add file to path if the folder exists
pathIfExists() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1"
fi
}
# Same, but add it before the path
prePathIfExists() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1:${PATH}"
fi
}
# Source a file if it exists
sourceIfExists() {
[ -f $1 ] && source $1
}
###### Exports
export EDITOR="nvim"
export VISUAL="nvim"
export ZSH_PLUGINS_ALIAS_TIPS_EXCLUDES="_"
export ZSH_PLUGINS_ALIAS_TIPS_EXPAND=1
export GOPATH=/home/${USER}/go
export PATH=${PATH}
prePathIfExists "/usr/local/bin/"
prePathIfExists "/home/${USER}/scripts"
prePathIfExists "/home/${USER}/bin"
pathIfExists "/home/${USER}/.yarn/bin"
pathIfExists "/home/${USER}/.config/yarn/global/node_modules/.bin/"
pathIfExists "/home/${USER}/.local/bin"
pathIfExists "${GOPATH}/bin"
prePathIfExists "/home/${USER}/.local/share/JetBrains/Toolbox/scripts"
pathIfExists "/home/${USER}/nativefier/bins"
export VOLTA_HOME="$HOME/.volta"
prePathIfExists "$VOLTA_HOME/bin"
export BROWSER=/usr/bin/google-chrome-stable
export BAT_THEME=ansi
###### Alias
## Better standards
alias vi="nvim"
alias vim="nvim"
alias ls="lsd"
alias cat="bat"
## Shortcuts
alias wifiTerm='nmtui'
alias ys='yarn start'
alias fixit='sudo rm -f /var/lib/pacman/db.lck && sudo pacman -Syyuu && sudo pacman -Suu'
alias fixkeys='sudo pacman-key --populate archlinux antergos && sudo pacman-key --refresh-keys'
alias sound="amixer sset 'Master' "
alias tb="nc termbin.com 9999"
alias -g C="| xclip -selection c"
# conflicts with the fd command
#unalias fd
###### Scripts
showcolors() { for code in {0..255}; do echo -e "\e[38;05;${code}m $code: Test"; done }
function changeMac() {
local mac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
sudo ifconfig wlp59s0 ether $mac
sudo ifconfig wlp59s0 down
sudo ifconfig wlp59s0 up
echo "Your new physical address is $mac"
}
###### fzf utils
# fkill - kill processes - list only the ones you can kill.
fkill() {
local pid
if [ "$UID" != "0" ]; then
pid=$(ps -f -u $UID | sed 1d | fzf -m | awk '{print $2}')
else
pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
fi
if [ "x$pid" != "x" ]
then
echo $pid | xargs kill -${1:-9}
fi
}
## Git aliases
# Delete multiple branches in bulk
alias fgitDeleteBranch="git branch --no-color | fzf -m | xargs -I {} git branch -D '{}'"
# Checkout a branch based on the lattest commited
alias fgitCheckout="git branch --sort=-committerdate | fzf | tr -d '[:space:]' | xargs -I {} git checkout '{}'"
## Docker aliases
# mark all docker container to unless-stopped
alias dockerSetAllUnlessStopped="docker update --restart=unless-stopped $(docker ps -qa)"
# stop docker container by fuzzy search
alias fdockerStop="docker ps --format "{{.Names}}" | fzf -m | xargs -I {} docker stop '{}'"
# rm docker container by fussy search
alias fdockerRm="docker ps --format "{{.Names}}" -a | fzf -m | xargs -I {} docker rm '{}'"
###### Setups
if [ -d ~/.zsh.d ]; then
for i in ~/.zsh.d/*; do
[ -f "${i}" ] && source "${i}"
done
fi
sourceIfExists "${ZSH_CUSTOM1:-$ZSH/custom}/plugins/enhancd/init.sh"
ENHANCD_FILTER=fzf; export ENHANCD_FILTER
source $ZSH/oh-my-zsh.sh
# Load nvm init script
#[ -f /usr/share/nvm/init-nvm.sh ] && source /usr/share/nvm/init-nvm.sh
# added by travis gem
sourceIfExists /home/beaussan/.travis/travis.sh
# Load FZF awesome sauce
sourceIfExists /usr/share/fzf/key-bindings.zsh
sourceIfExists /usr/share/fzf/completion.zsh
# Load git flow completion
sourceIfExists /usr/share/zsh/site-functions/git-flow-completion.zsh
# Force load autocompletions
fpath=(/usr/local/share/zsh-completions $fpath)
eval "$(starship init zsh)"
###### Overides
alias ls="lsd"
alias la="ls -alh"
alias vi="nvim"
alias vim="nvim"
alias cat="bat"