-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc
190 lines (155 loc) · 6.39 KB
/
dot_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
# stolen from: https://github.com/davidtwco/dotfiles
# ==================================================
# Functions
# =========
_has() {
which $1>/dev/null 2>&1
}
reddit() {
curl -s -A 'Reddit CLI' "https://www.reddit.com/r/$1/new.json?limit=20" | jq -r '.data.children| .[] | "\(.data.title)\t\(.data.url)"' | fzf --delimiter='\t' --with-nth=1 | cut -f2 | xargs kitty +kitten icat 2>/dev/null
}
rnimages() {
curl -s -A 'Reddit CLI' "https://www.reddit.com/r/$1/new.json?limit=20" | jq -r '.data.children| .[] | "\(.data.url)"' | xargs kitty +kitten icat 2>/dev/null
}
rtimages() {
curl -s -A 'Reddit CLI' "https://www.reddit.com/r/$1/top.json?limit=20" | jq -r '.data.children| .[] | "\(.data.url)"' | xargs kitty +kitten icat 2>/dev/null
}
# Bindings
# ========
# Use vim keybindings.
set -o vi
bindkey -v
# Environment
# ===========
# Set a cache dir.
export ZSH_CACHE_DIR=$HOME/.zsh/cache
# 10ms for key sequences
export KEYTIMEOUT=1
# Ensure editor is Vim
export EDITOR=nvim
# Ensure Vim and others use 256 colours.
if [[ "$TERM" != "screen"* && "$TERM" != "tmux"* ]]; then
export TERM=xterm-256color
fi
# Don't clear the screen when leaving man.
export MANPAGER='less -X'
export LYNX_CFG="$HOME/.config/lynx/lynx.cfg"
export LYNX_LSS="$HOME/.config/lynx/lynx.lss"
# Path
# ====
# In zsh, the $PATH variable is tied to the $path variable.
# This makes the $path variable act like a set.
typeset -U path
# Add our directories.
path=("$HOME/bin" $path)
path=("$HOME/.fzf/bin" $path)
path=("/usr/local/sbin" $path)
path=("/usr/local/bin" $path)
path=("$(brew --prefix)/opt/postgresql@15/bin" $path)
# Using the (N-/) glob qualifier we can remove paths that do not exist.
path=($^path(N-/))
# Android SDK stuff for React Native
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
# Postgresql
export LDFLAGS="-L$(brew --prefix)/opt/postgresql@15/lib"
export CPPFLAGS="-I$(brew --prefix)/opt/postgresql@15/include"
# Completion
# ==========
# Use modern completion system.
autoload -Uz compinit
# caching stolen from https://blog.callstack.io/supercharge-your-terminal-with-zsh-8b369d689770
typeset -i updated_at=$(date +'%j' -r ~/.zcompdump 2>/dev/null || stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)
if [ $(date +'%j') != $updated_at ]; then
compinit -i
else
compinit -C -i
fi
zmodload -i zsh/complist
setopt AUTO_LIST # automatically list choices on ambiguous completion
setopt AUTO_MENU # automatically use menu completion
setopt ALWAYS_TO_END # move cursor to end if word had one match
zstyle ':completion:*' menu select # select completions with arrow keys
zstyle ':completion:*' group-name '' # group results by category
zstyle ':completion:::::' completer _expand _complete _ignored _approximate # enable approximate matches for completion
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
# zstyle ':completion:*' menu select=2
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
# zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path $ZSH_CACHE_DIR
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# Conveniences
# =======
setopt AUTO_CD # cd by typing directory name if the name isn't a command
setopt CORRECT_ALL # autocorrect commands
# History
# =======
# Keep 10000000 lines of history within the shell and save it to ~/.zsh_history:
HISTFILE="$HOME/.zsh_history"
HISTSIZE=10000000
SAVEHIST=10000000
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
# Aliases
# =======
# Load our aliases.
if [ -f ~/.shell/.aliases ]; then
. ~/.shell/.aliases
fi
source $(brew --prefix)/opt/antidote/share/antidote/antidote.zsh
antidote load
# fzf
# ===
# fzf via Homebrew
if [ -e $(brew --prefix)/opt/fzf/shell/completion.zsh ]; then
source $(brew --prefix)/opt/fzf/shell/key-bindings.zsh
source $(brew --prefix)/opt/fzf/shell/completion.zsh
fi
# fzf via local installation
if [ -f ~/.fzf.zsh ]; then
source ~/.fzf.zsh
fi
# fzf + ag configuration
if _has fzf && _has ag; then
export FZF_DEFAULT_COMMAND='ag --nocolor -g ""'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS='
--color fg:242,bg:236,hl:65,fg+:15,bg+:239,hl+:108
--color info:108,prompt:109,spinner:108,pointer:168,marker:168
'
fi
# fzf + ripgrep configuration
if _has fzf && _has rg; then
export FZF_DEFAULT_COMMAND='rg --files --hidden --follow -g "!{.git}" 2>/dev/null'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS=''
fi
# stop homebrew from automatically upgrading everything
export HOMEBREW_NO_AUTO_UPDATE=1
eval "$(mise activate zsh)"
eval "$(starship init zsh)"