-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
170 lines (139 loc) · 4.19 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
#region functions
function command_exists {
type "$1" >/dev/null 2>&1
}
fzf_git_checkout() {
if [ $# -eq 0 ]; then
git branch --all | fzf | tr -d '[:space:]' | xargs git checkout
else
git checkout "$@"
fi
}
#endregion
#region homebrew provided stuff: zsh completions, libs
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
if [[ -f "$(brew --prefix asdf)/libexec/asdf.sh" ]]; then
# bind asdf
. $(brew --prefix asdf)/libexec/asdf.sh
# add asdf completions
fpath=(${ASDF_DIR}/completions $fpath)
fi
autoload -Uz compinit
compinit
export PATH="/usr/local/opt/libpq/bin:$PATH"
fi
#endregion
#region shell setup with sourcing and evals
source ~/.profile
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# setup starship
if command_exists starship; then
eval "$(starship init zsh)"
fi
# setup fzf
if command_exists fzf; then
eval "$(fzf --zsh)"
fi
# setup zoxide
if command_exists zoxide; then
eval "$(zoxide init zsh)"
fi
# setup zsh-autosuggestion
[ -f $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh ] && source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# source ~/.zshrc.local
if [ -f "$HOME/.zshrc.local" ]; then
source "$HOME/.zshrc.local"
fi
#endregion
#region aliases
#region# git related (some found in @holman's dotfiles)
alias glog="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
alias gb='git branch'
alias gc='git commit'
alias gco='fzf_git_checkout'
alias gd='git diff'
alias gs='git status'
alias gup="git pull --rebase --autostash"
alias gundo="git reset --soft HEAD~1"
alias lg="lazygit"
#endregion
#region# ruby & rails, node aliases
alias be='bundle exec'
alias berd='RAILS_ENV=${RAILS_ENV:-test} bundle exec rspec --format documentation'
alias ber='RAILS_ENV=${RAILS_ENV:-test} bundle exec rspec'
alias rdbm='bundle exec rake db:migrate'
alias rdbr='bundle exec rake db:rollback'
alias fs='overmind start'
alias rr='bundle exec rails routes | fzf'
alias rubocop-global="rubocop --require rubocop-rails --require rubocop-rspec --require rubocop-performance --require test_prof/rubocop --require rubocop-thread_safety -c .rubocop.yml"
alias yarn-upgrade='npx npm-check-updates -u && yarn install && npx yarn-deduplicate yarn.lock & yarn install'
#endregion
#region# start GUI applications
alias subl="open -a 'Sublime Text'"
alias marta="open -a Marta"
alias vsc="open -a 'Visual Studio Code'"
#endregion
#region# grepping code
alias todo="rg '(TODO|FIXME|XXX|NOTE|OPTIMIZE|HACK|REVIEW)'"
alias ag="rg"
#endregion
#region# pleasent path traversal
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
#endregion
#region# magic folder commands
alias pg="playground"
alias wiki="cd ~/versioned/gildesmarais/wiki && ~/.scripts/fuz"
#endregion
#region# better cat and "imagec" (icat)
if command_exists bat; then
# use bat for cat, and let it behave like cat
alias cat="bat --style=plain --paging=never"
fi
if command_exists wezterm; then
alias icat="wezterm imgcat"
fi
#endregion
#region# likewise powerful aliases beginning with 'l'
alias less="less -R"
if command_exists lsd; then
alias ls='lsd'
alias ll='lsd -l'
alias la='lsd -a'
alias lla='lsd -la'
fi
if [ "$(uname)" = "Darwin" ]; then
# we are on macosx
alias lsusb="system_profiler SPUSBDataType"
fi
#endregion
#region# powerful aliases beginning with 'p'
alias psgrep="ps aux | grep"
alias p8="ping 8.8.8.8"
alias p6="ping6 2606:4700:4700::1111"
alias pup="pup -c"
alias pw="pwgen -nyB1 $(shuf -i 46-64 -n 1) 1"
#endregion
#endregion
#region sweetened history (some things taken from https://www.soberkoder.com/better-zsh-history/ )
export HISTFILE=~/.zsh_history
export HISTFILESIZE=1000000000
export HISTSIZE=1000000000
setopt INC_APPEND_HISTORY
export HISTTIMEFORMAT="[%F %T] "
setopt EXTENDED_HISTORY
setopt HIST_FIND_NO_DUPS
alias hgrep="history | grep"
alias h="history | fzf"
#endregion
#region key bindings
# jumping words with Alt and left/right arrow
bindkey "^[^[[C" forward-word
bindkey "^[^[[D" backward-word
#endregion