-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzshrc
154 lines (122 loc) · 4.25 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
# To profile startup time, uncomment this line and the corresponding line at the bottom
# zmodload zsh/zprof
# Add ruby Binstubs to our path (must have priority over the rbenv shims!)
export PATH=./bin:$PATH
# add personal bins to path
export PATH=~/bin:$PATH
# add the postgres.app CLI tools
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
# history settings
export HISTFILE=~/.zhistory
export HISTFILESIZE=1000000000
export HISTSIZE=1000000000
setopt INC_APPEND_HISTORY
export HISTTIMEFORMAT="[%F %T] "
setopt EXTENDED_HISTORY
setopt HIST_FIND_NO_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_SAVE_NO_DUPS
# Enable Ctrl-x-e to edit command line
autoload -U edit-command-line
# Emacs style
zle -N edit-command-line
bindkey '^xe' edit-command-line
bindkey '^x^e' edit-command-line
# Vi style:
bindkey -M vicmd v edit-command-line
export EDITOR=nvim
export VISUAL=nvim
[[ -f /opt/homebrew/bin/rbenv ]] && eval "$(rbenv init - zsh)"
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
# FZF Stuff
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
# Use the pspg pager for psql, if installed
if [[ -s /opt/homebrew/bin/pspg ]]
then
export PSQL_PAGER="pspg --style=17"
fi
# on linux
[ -f /usr/share/doc/fzf/examples/key-bindings.zsh ] && source /usr/share/doc/fzf/examples/key-bindings.zsh
[ -f /usr/share/doc/fzf/examples/completion.zsh ] && source /usr/share/doc/fzf/examples/completion.zsh
# on my mac...
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
[ -f /opt/homebrew/etc/profile.d/autojump.sh ] && . /opt/homebrew/etc/profile.d/autojump.sh
[ -f /usr/share/autojump/autojump.sh ] && . /usr/share/autojump/autojump.sh
# FZF integration with autojump
j() {
if [[ "$#" -ne 0 ]]; then
cd $(autojump $@)
return
fi
cd "$(autojump -s | sort -k1gr | awk '$1 ~ /[0-9]:/ && $2 ~ /^\// { for (i=2; i<=NF; i++) { print $(i) } }' | fzf --height 40% --reverse --inline-info)"
}
# expand-and-accept-alias() {
# zle expand-word # Expand the current word (alias)
# zle self-insert # Insert a space
# }
# zle -N expand-and-accept-alias
# bindkey ' ' expand-and-accept-alias
alias ll='ls -lh'
alias lt='ls -ltrha'
alias la='ls -a'
alias x='exa --long --grid'
alias xl='exa --long' # don't use the grid here as it hides link destination
alias xa='exa --long --grid -a'
alias xt='exa --long --sort newest -a'
alias xg='exa --long --git'
# do this stuff only if we have the GNU coreutils installed
if [[ -s /opt/homebrew/bin/gls ]]
then
alias ls='/opt/homebrew/bin/gls --color -F'
fi
alias gs='git status'
alias gp='git push'
alias gc='git commit'
alias gd='git diff'
alias gl='git log --oneline --graph --parents -n 9'
alias gsm='git switch main'
alias be='bundle exec'
alias dcew='docker compose exec -it web'
# start a web server in current directory
alias server='ruby -run -e httpd . -p5000'
# Get the expected md5sum output from the OS X tool...
alias md5='md5 -r'
alias md5sum='md5 -r'
# We use neovim if available
if [[ -s /opt/homebrew/bin/nvim ]]
then
alias vim='/opt/homebrew/bin/nvim'
fi
# Only on MacOS, set an alias for tailscale
if [[ -f /Applications/Tailscale.app/Contents/MacOS/Tailscale ]]
then
alias tailscale=/Applications/Tailscale.app/Contents/MacOS/Tailscale
fi
# find procs
psg () {
ps axo pid,ppid,user,command | grep -i "$*"
}
# initialize zsh completions
# Allow for more flexibility with things like Case
zstyle ':completion:*' matcher-list '' '+m:{a-zA-Z}={A-Za-z}' '+r:|[._-]=* r:|=*' '+l:|=* r:|=*'
if type brew &>/dev/null
then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
FPATH="$(brew --prefix)/share/zsh-completions:$FPATH"
fi
# Set a fast prompt
PS1='%F{blue}%~ %(?.%F{green}.%F{red})%#%f '
# Set a more interesting prompt if available
[[ -f /opt/homebrew/bin/starship || /home/linuxbrew/.linuxbrew/bin/starship ]] && eval "$(starship init zsh)"
autoload -Uz compinit
compinit
if [[ -f /home/linuxbrew/.linuxbrew/bin/brew ]]
then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
# zprof