-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
106 lines (97 loc) · 3.06 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
#!/usr/bin/env zsh
### Zsh configuration
# usage: ln -fns $(pwd)/.zshrc ~/.zshrc
### options
# initial setup configured by zsh-newuser-install
# To re-run setup: autoload -U zsh-newuser-install; zsh-newuser-install -f
# See man zshoptions or http://zsh.sourceforge.net/Doc/Release/Options.html
HISTFILE=~/.zsh_history
HISTSIZE=10000
setopt autocd extendedglob globdots histignorespace noautomenu nullglob
### keybindings: based on https://github.com/romkatv/zsh4humans
bindkey -e
bindkey -s '^[[1~' '^[[H'
bindkey -s '^[[4~' '^[[F'
bindkey -s '^[[5~' ''
bindkey -s '^[[6~' ''
bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line
bindkey '^?' backward-delete-char
bindkey '^[[3~' delete-char
bindkey '^[[1;3C' forward-word
bindkey '^[[1;3D' backward-word
bindkey '^H' backward-kill-word
bindkey '^[[3;3~' kill-word
bindkey '^N' kill-buffer
### homebrew
if [[ -z $HOMEBREW_PREFIX ]]; then
case $(uname) in
Darwin)
if [[ $(uname -m) == 'arm64' ]]; then
HOMEBREW_PREFIX='/opt/homebrew'
elif [[ $(uname -m) == 'x86_64' ]]; then
HOMEBREW_PREFIX='/usr/local'
fi
;;
Linux)
if [[ -d '/home/linuxbrew/.linuxbrew' ]]; then
HOMEBREW_PREFIX='/home/linuxbrew/.linuxbrew'
elif [[ -d $HOME/.linuxbrew ]]; then
HOMEBREW_PREFIX=$HOME/.linuxbrew
fi
if [[ -d $HOMEBREW_PREFIX ]]; then
PATH=$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin:$PATH
fi
;;
esac
fi
if [[ -d $HOMEBREW_PREFIX ]]; then
eval $($HOMEBREW_PREFIX/bin/brew shellenv)
fi
### exports
if type micro &>/dev/null; then
editor='micro --wait'
elif type codium &>/dev/null; then
editor='codium --wait'
elif type code &>/dev/null; then
editor='code --wait'
elif type code-insiders &>/dev/null; then
editor='code-insiders --wait'
elif type code-exploration &>/dev/null; then
editor='code-exploration --wait'
else
editor='vim'
fi
TTY=$(tty)
GNU_COREUTILS_BIN_DIR=$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin
GNU_FINDUTILS_BIN_DIR=$HOMEBREW_PREFIX/opt/findutils/libexec/gnubin
GNU_GREP_BIN_DIR=$HOMEBREW_PREFIX/opt/grep/libexec/gnubin
GNU_SED_BIN_DIR=$HOMEBREW_PREFIX/opt/gsed/libexec/gnubin
GNU_TAR_BIN_DIR=$HOMEBREW_PREFIX/opt/gnu-tar/libexec/gnubin
export \
EDITOR=$editor \
GIT_EDITOR=$editor \
HOMEBREW_NO_ANALYTICS=1 \
PATH=$GNU_COREUTILS_BIN_DIR:$GNU_FINDUTILS_BIN_DIR:$GNU_GREP_BIN_DIR:$GNU_SED_BIN_DIR:$GNU_TAR_BIN_DIR:$PATH
### prompt: https://starship.rs
source <(starship init zsh)
### mise: https://mise.jdx.dev/
eval "$(mise activate zsh)"
### functions
# ensure .zfunc is symlinked to $HOME/.zfunc
typeset -U fpath
fpath+=($HOME/.zfunc)
autoload -Uz $HOME/.zfunc/*(:tX)
### completions
if type brew &>/dev/null && [[ -d $HOMEBREW_PREFIX ]]; then
fpath+=($HOMEBREW_PREFIX/share/zsh/site-functions)
fi
zstyle :compinstall filename $HOME/.zshrc
autoload -Uz compinit
compinit
### syntax highlighting
if [[ -d $HOMEBREW_PREFIX/share/zsh-syntax-highlighting ]]; then
. $HOMEBREW_PREFIX/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
elif [[ -d $HOME/.zsh/zsh-syntax-highlighting ]]; then
. $HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi