-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
172 lines (144 loc) · 3.9 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
path=("/usr/local/bin" $path)
path+=("/Library/PostgreSQL/12/bin/")
path+=("/usr/local/mysql/bin")
path+=("$HOME/Library/Python/3.8/bin")
path+=("$HOME/Library/Python/3.11/bin")
path+=("$HOME/google-cloud-sdk/bin")
path+=("/usr/local/go/bin")
export PATH
export GOPATH=/usr/local/go/bin
export EDITOR=vim
export JAVA_HOME=`/usr/libexec/java_home`
# prevent path from expanding/duplicating
# when zshrc is sourced
typeset -U PATH path
# zsh
# don't highlight pasted text
zle_highlight+=(paste:none)
# use modern completion system (highlight tab completion)
zstyle ':completion:*' menu select
autoload -Uz compinit && compinit
# removed '-' '/' '_' '?' '.'
export WORDCHARS='*[]~=&;!#$%^(){}<>'
# misc
alias c='clear'
alias resetaudio='sudo kextunload /System/Library/Extensions/AppleHDA.kext && sudo kextload /System/Library/Extensions/AppleHDA.kext'
alias tf='terraform'
# history
HISTFILE=~/.history
HISTSIZE=100000
SAVEHIST=$HISTSIZE
# share history between tabs/sessions
setopt share_history
# zshrc
alias zshrc='vim ~/.zshrc'
alias rzshrc='vim ~/dev/dotfiles/zshrc'
alias rfrsh='source ~/.zshrc'
alias cddev='cd ~/dev'
alias cddf='cd ~/dev/dotfiles'
# child support
export cs="$HOME/dev/something-useful"
alias csa="cd $cs/childsupport-app"
alias css="cd $cs/childsupport-server"
alias csdeploy="git push heroku main"
alias cslog="heroku log --tail --force-colors"
# git
alias ga='git add'
alias gaa='git add -A'
alias gaap='git add -A --patch'
alias gap='git add --patch'
alias gau='git add -u'
alias gc='git commit'
alias gca='git commit -a'
alias gcaa='git commit -a --amend'
alias gd='git diff'
alias gdel='git branch | grep -v main | xargs git branch -D'
alias gds='git diff --staged'
alias gp='git push'
alias gpf='git push --force-with-lease'
alias gpm='git co main && git pull'
alias gpr='git pull origin main --rebase'
alias gst='git status'
alias gr='git restore'
alias grim='git rebase -i main'
alias grs='git restore --staged'
alias gundo='git reset HEAD~'
alias gti='git'
get_git_branch() {
git rev-parse --abbrev-ref HEAD 2> /dev/null
}
gg() {
if [[ $# -lt 1 ]]; then
echo "Usage: 'gg foo bar baz' searches for 'foo' and excludes dirs/files 'bar' and 'baz'"
return
fi
exclude="-- ."
for arg in "${@:2}"; do
exclude="$exclude ':!$arg'"
done
eval "git grep --break --heading --line-number $1 $exclude"
}
gfix() {
if [[ $# -lt 1 ]]; then
echo "Usage: gfix <commit hash>"
return
fi
base=$2
if [[ -z "$base" ]]; then
base=main
fi
git add -A
git commit --fixup $1
GIT_EDITOR=true git rebase --interactive --autosquash $base
}
gco() {
if [[ $# -lt 1 ]]; then
echo "Usage: gco <branch suffix>"
return
fi
branch=""
if [[ $1 != "main" ]]; then
branch="ilya/"
fi
git co "$branch$1"
}
gcob() {
if [[ $# -lt 1 ]]; then
echo "Usage: gcob <branch suffix>"
return
fi
git co -b "$1"
}
# Git rebase main: Set `main` as the base branch.
grm() {
if [[ $# -lt 1 ]]; then
echo "Usage: grm <old branch>"
return
fi
git rebase --onto main $1 $(get_git_branch)
}
# propel
source ~/dev/dotfiles/propelrc
# child support
source ~/dev/dotfiles/childsupportrc
# misc
source ~/.secrets
function activate() {
source "$HOME/.virtualenvs/$1/bin/activate"
}
# alias resetting color in prompt for readability
eval R='%{$reset_color%}'
# perform parameter expansion, command substitution and arithmetic expansion in prompts
setopt PROMPT_SUBST
# custom prompt
export PROMPT='%n %F{magenta}%0~%f %F{yellow}%*%f %F{cyan}($(get_git_branch))%f $ '
# include the hostname if this is a remote host
test -n "$SSH_CLIENT" && PROMPT="%m:$PROMPT"
# fuzzy finder (https://github.com/junegunn/fzf)
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
# pipx
autoload -U bashcompinit
bashcompinit
eval "$(register-python-argcomplete pipx)"