-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathzshrc
206 lines (166 loc) · 5.95 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
202
203
204
205
206
# !NOTE! if you VIM is running slow, always check if the ~/.zshenv is messing it up
# ZSH Performance debug helpers --- {{{
# Uncomment this & run zprof on the shell to debug time taken by plugins
# More: https://blog.mattclemente.com/2020/06/26/oh-my-zsh-slow-to-load/
# zmodload zsh/zprof
# Uncomment this & run 'timezsh' to track overall zsh load time
# timezsh() {
# shell=${1-$SHELL}
# for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done
# }
#
# }}}
# Path to your oh-my-zsh installation.
export ZSH=~/.oh-my-zsh
# Informs when a command has finished by bell
precmd () {
echo -n -e "\a"
}
# Set name of the theme to load.
ZSH_THEME="clean-minimal"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git z docker docker-compose zsh-autosuggestions)
# zsh-autosuggestions - c-e to accept a suggestion
# User configuration
export PATH="$PATH:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
# ZSH displays error with /usr/local permissions
ZSH_DISABLE_COMPFIX="true"
source $ZSH/oh-my-zsh.sh
# Make VI mode as default for zsh {
# https://dougblack.io/words/zsh-vi-mode.html
bindkey -v
function zle-line-init zle-keymap-select {
VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}"
RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1"
zle reset-prompt
}
# Register the widget to zle
zle -N zle-line-init
zle -N zle-keymap-select
# Persist normal non-vi behaviour
# Reference to key & values:
# https://betterprogramming.pub/master-mac-linux-terminal-shortcuts-like-a-ninja-7a36f32752a6
bindkey '^P' up-history
bindkey '^N' down-history
bindkey '^w' backward-kill-word
bindkey '^r' fzf
bindkey '^e' end-of-line
bindkey '^a' beginning-of-line
bindkey "^?" backward-delete-char
bindkey "^u" backward-kill-line
bindkey "^y" yank
# Make mode change lag go away
export KEYTIMEOUT=1
# }
# Sourcing should be after zle reverse search is registered
source <(fzf --zsh)
######### ALIAS
# to use mysql command from terminal
export PATH="/usr/local/mysql/bin:$PATH"
# launch chrome without web security
alias chromews='open -a Google\ Chrome --args --disable-web-security'
alias vus='cd ~/1conf;vagrant up;vagrant ssh'
alias vs='cd ~/1conf;vagrant ssh'
alias sf='echo "Connecting to sfctrl.practodev.com..." && ssh ubuntu@13.235.52.247'
alias glb="git for-each-ref --count=7 --sort=-committerdate refs/heads/ --format='%(refname:short)' | tac"
# Symfony aliases
alias cc="app/console cache:clear"
alias adump="app/console assetic:dump"
alias cinstall="composer install"
# Base16 Shell (Needed for correct colors in base16 material theme)
# BASE16_SHELL="$HOME/.config/base16-shell/base16-material.dark.sh"
# BASE16_SHELL="$HOME/.config/oceanic-next-shell/oceanic-next.dark.sh"
# [[ -s $BASE16_SHELL ]] && source $BASE16_SHELL
# Bind ctrl-z to switch between vim & terminal
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER="fg"
zle accept-line
else
zle push-input
zle clear-screen
fi
}
zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z
# Use Neovim instead of Vim or Vi
# alias vim=nvim
# Uses Neovom from the binary downloaded if the brew installation doesn't work
export PATH="$HOME/Downloads/nvim-macos/bin:$PATH"
alias vi='exec_scmb_expand_args nvim'
alias rc='vi ~/.vimrc'
# Use Neovim as "preferred editor"
export VISUAL=nvim
export EDITOR="$VISUAL"
alias tx=tmuxinator
# fix terminals to send ctrl-h to neovim correctly
[[ -f "~/.$TERM.ti" ]] && tic ~/.$TERM.ti
# to run cpp program
makeAndRunCpp() {
make $1 > /dev/null
./$1
}
alias run=makeAndRunCpp
alias composer="php /usr/local/bin/composer.phar"
# Git grep alias
runGitGrep() {
git grep -i "$1"
}
alias gg=runGitGrep
# Not sourcing nvm but loading on demand when it's used for the first time
# as it adds up 40ms to shell load time
# http://broken-by.me/lazy-load-nvm/
# Old code:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use # This loads nvm
# nvm() {
# unset -f nvm
# export NVM_DIR=~/.nvm
# [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" --no-use # This loads nvm
# nvm "$@"
# }
# node() {
# unset -f node
# export NVM_DIR=~/.nvm
# [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" --no-use # This loads nvm
# node "$@"
# }
# npm() {
# unset -f npm
# export NVM_DIR=~/.nvm
# [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" --no-use # This loads nvm
# npm "$@"
# }
# Make globally installed packages accessible to zsh
# export PATH=$HOME/.nvm/versions/node/v10.11.0/lib/node_modules:$PATH
# to use brew command [linuxbrew]
export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
# Export colors for tmux
export TERM=xterm-256color
export PATH="/usr/local/sbin:$PATH"
# For udemy clas on data structures
export CLASSPATH=$CLASSPATH:~/Downloads/algs4.jar
# Fixes https://discourse.brew.sh/t/failed-to-set-locale-category-lc-numeric-to-en-ru/5092/6
# which occurs when launching VIM. Root cause - unknown
export LC_ALL=en_US.UTF-8
# Takes ~100ms
# Load rbenv automatically by appending
# the following to ~/.zshrc:
eval "$(rbenv init -)"
# Needed for scm breeze
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
# for scm breeze (git shortcuts plugin)
[ -s "/Users/$USER/.scm_breeze/scm_breeze.sh" ] && source "/Users/$USER/.scm_breeze/scm_breeze.sh"
export PATH="/usr/local/bin:$PATH"
export PATH="/usr/bin:$PATH"
export PATH="$PATH:/Users/$USER/Library/Python/2.7/bin"
export PATH="$PATH:/Users/$USER/Library/Python/3.7/bin"
## For yarn
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion