-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.zshrc
256 lines (212 loc) · 7.52 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
PATH=$HOME/Library/Python/3.9/bin:/opt/homebrew/bin:$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/mongodb/bin:/brew/bin:/brew/sbin:/brew/share/npm/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH
export NODE_PATH=/brew/lib/node
export PYTHONPATH=$PYTHONPATH:$HOME/site
export PYTHONSTARTUP=$HOME/.pythonrc
# zsh vim mode
set -o vi
# vim text object support
#source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/.zsh/zsh-history-substring-search/zsh-history-substring-search.zsh
# import private aliases
if [ -f ~/.alias ]; then
source ~/.alias
fi
# other shared aliases
alias ll="ls -la"
alias cdd="cd -"
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias idk="printf \"¯\_(ツ)_/¯\" | pbcopy && echo '¯\_(ツ)_/¯'"
alias vi="vim"
alias ack="rg"
export LESS=FRSXQ
# Always open mutt in ~/Desktop so that downloaded mail attachments save there
function mutt() {
cd ~/Desktop && /opt/homebrew/bin/mutt "$@" && cd -
}
# CLI for 1Password. Requires the `1pass` Python package
function 1pass() { sudo -u $(whoami) /usr/bin/security find-generic-password -l 1pass -w | $WORKON_HOME/1pass/bin/1pass --no-prompt --fuzzy "$@" | tr -d '\012\015' | pbcopy }
alias 1p='1pass'
function branch() {
git symbolic-ref --short HEAD
}
function gh-diff() {
git config --get remote.origin.url | grep $1/$2.git > /dev/null 2>&1
if [ $? -ne 0 ]; then
mktmpenv
git clone https://github.com/$1/$2.git
cd $2
fi
curl https://github.com/$1/$2/pull/$3.diff | cdiff -s
}
function gh() {
if [ "$#" -eq 1 ]; then
echo "[email protected]:ryanpetrello/$1.git"
fi
if [ "$#" -eq 2 ]; then
echo "[email protected]:$1/$2.git"
fi
}
# ack-specific settings
export ACK_COLOR_MATCH='red'
# virtualenvwrapper settings
export WORKON_HOME=~/venvs
VIRTUALENVWRAPPER=/Users/rpetrello/Library/Python/3.9/bin/virtualenvwrapper.sh
export VIRTUAL_ENV_DISABLE_PROMPT=1
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
if [[ -f $VIRTUALENVWRAPPER ]]; then
function workon() {
unfunction "$0"
source $VIRTUALENVWRAPPER
$0 "$@"
}
function mkvirtualenv () {
unfunction "$0"
source $VIRTUALENVWRAPPER
$0 "$@"
}
function mktmpenv () {
unfunction "$0"
source $VIRTUALENVWRAPPER
$0 "$@"
}
fi
# history
HISTFILE=$HOME/.zsh_history
HISTSIZE=999999999
SAVEHIST=999999999
setopt SHARE_HISTORY
setopt APPEND_HISTORY
setopt hist_ignore_all_dups
bindkey '^R' history-incremental-search-backward
h() { if [ -z "$*" ]; then history 1; else history 1 | egrep "$@"; fi; }
# vim as default + launch settings
export EDITOR='vim'
export TERM='xterm-256color'
# colors
export CLICOLOR=1
export LSCOLORS=DxDxCxDxexexexaxaxaxax
export GREP_COLOR=32
alias grep='grep --color'
function speedtest() {
echo "`curl --progress-bar -w "%{speed_download}" http://speedtest.wdc01.softlayer.com/downloads/test100.zip -o /dev/null` / 131072" | bc | xargs -I {} echo {} mbps
}
function jgrep() {
NEEDLE=`echo $@ | sed "s/ /\|/g"`
cat | egrep -oh "\"($NEEDLE)\":\s?\"[^\"]*\"" | egrep --color $NEEDLE
}
function haystack() {
# call vim on a file (or glob) to perform a search and replace operation
# with confirmation. Does not save automagically. Example usage:
# vsed foo bar *.py
# Will search for 'foo' and replace it with 'bar' in all matching *.py files.
# It also supports globbing for recursive files:
# vsed foo bar **/*.py
search=$1
replace=$2
shift
shift
vim -c "bufdo! set eventignore-=Syntax| %s/$search/$replace/gce | update" $*
}
fg_lblue=%{$'\e[0;34m'%}
fg_lgreen=%{$'\e[1;32m'%}
fg_yellow=%{$'\e[1;33m'%}
fg_white=%{$'\e[1;37m'%}
# I wish py.test did this by default...
alias py.test="py.test --tb=short"
setopt auto_menu
setopt complete_in_word
setopt always_to_end
# version control info
autoload -Uz vcs_info
setopt prompt_subst
setopt globcomplete
zstyle ':vcs_info:*' stagedstr $'%F{green}●'
zstyle ':vcs_info:*' unstagedstr '%F{yellow}●'
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' enable git svn
precmd () {
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]] {
zstyle ':vcs_info:*' formats $'[%{\e[1;33m%}%b%F{foreground}:%c%u%F{foreground}] '
} else {
zstyle ':vcs_info:*' formats $'(%{\e[1;33m%}%b%F{foreground}:%c%u%F{white}●%F{foreground}) '
}
vcs_info
}
function get_cluster_short() {
echo "$1" | cut -d':' -f6-
}
local git='$vcs_info_msg_0_'
# Custom status line
PS1="[`hostname | sed 's/\..*//'`]${fg_lblue}%5v${fg_white} ${git}${fg_lblue}%~ ${fg_white}"
# Show a different cursor for different vim modes
function zle-keymap-select zle-line-init
{
case $KEYMAP in
vicmd) print -n -- "\E]50;CursorShape=0\C-G";; # block cursor
viins|main) print -n -- "\E]50;CursorShape=1\C-G";; # line cursor
esac
zle reset-prompt
zle -R
}
function zle-line-finish
{
print -n -- "\E]50;CursorShape=0\C-G"
}
zle -N zle-line-init
zle -N zle-line-finish
# # 10ms for key sequences
KEYTIMEOUT=1
# -----------------------------------------------
# Set up zsh-specifics
# -----------------------------------------------
# compinit initializes various advanced completions for zsh
fpath=($HOME/.zsh/completions $fpath)
autoload -U compinit && compinit
# case insensitive tab completion
unsetopt correctall
# General completion technique
zstyle ':completion:*' completer _complete _match _approximate
# Cache completions
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path $HOME/.zsh/cache
setopt auto_menu # show completion menu on succesive tab press
setopt complete_in_word
setopt always_to_end
setopt globcomplete
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
# disable named-directories autocompletion
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 2 numeric
zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
# Partial color matching on TAB
highlights='${PREFIX:+=(#bi)($PREFIX:t)(?)*==$color[blue]=00}':${(s.:.)LS_COLORS}}
zstyle -e ':completion:*' list-colors 'reply=( "'$highlights'" )'
zstyle -e ':completion:*:-command-:*:commands' list-colors 'reply=(
"'$highlights'" )'
unset highlights
source ~/.zsh/completions/pytest.plugin.zsh
# bind UP and DOWN arrow keys (compatibility fallback
# # for Ubuntu 12.04, Fedora 21, and MacOSX 10.9 users)
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND='rg --files --hidden --follow --glob "!.git/*"'
function nvm() {
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
nvm $@
}
export GPG_TTY=$(tty)
# curl -sS https://starship.rs/install.sh | sh
# eval "$(starship init zsh)"