forked from tjhop/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
124 lines (101 loc) · 3.23 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
# load extension systems
# (prompt, completion, version control systems, history prediction, command line editing)
autoload -Uz promptinit
autoload -Uz compinit
autoload -Uz vcs_info
autoload predict-on
autoload -U edit-command-line
# initialize extension systems
promptinit
compinit
# syntax highlighting, etc
case "$OSTYPE" in
linux*)
source /usr/share/**/zsh-syntax-highlighting.zsh
source /usr/share/**/zsh-autosuggestions.zsh
;;
darwin*)
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
;;
esac
# still use emacs style keybinds on shell command line
bindkey -e
# allow reverse menu completions
bindkey '^[[Z' reverse-menu-complete
# accept current autosuggestion
bindkey '^ ' autosuggest-accept
# allow editing command line in editor (ie, vim)
export EDITOR='vim'
zle -N edit-command-line
bindkey '^xe' edit-command-line
bindkey '^x^e' edit-command-line
# setup git status prompt info
setopt prompt_subst
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
# build prompt
PROMPT="%F{cyan}%~%f %F{green}\$vcs_info_msg_0_%(!.=>.->)%f "
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' actionformats '%F{blue}(%b | %a [ %c%u ])%f '
zstyle ':vcs_info:*' formats '%F{blue}(%b [ %c%u ])%f '
# zstyle ':vcs_info:git:*' formats '%b'
# set history
HISTFILE="$HOME/.history"
HISTSIZE=10000
SAVEHIST=10000
setopt INC_APPEND_HISTORY HIST_IGNORE_DUPS HIST_EXPIRE_DUPS_FIRST HIST_FIND_NO_DUPS
# if local shell configs file is found for shell configs specific to this system, source them too
if [[ -f "$HOME/.zshrc.local" ]]; then
source "$HOME/.zshrc.local"
fi
# source main alias file
if [[ -f "$HOME/.aliases" ]]; then
source "$HOME/.aliases"
fi
# if local aliases file is found for aliases specific to this machine, source them too
if [[ -f "$HOME/.aliases.local" ]]; then
source "$HOME/.aliases.local"
fi
# source environment variables file
if [[ -f "$HOME/.env_vars" ]]; then
source "$HOME/.env_vars"
fi
# if local env_vars file is found for env_vars specific to this machine, source them too
if [[ -f "$HOME/.env_vars.local" ]]; then
source "$HOME/.env_vars.local"
fi
# if there's a ~/bin directory, add it to path
if [[ -d "$HOME/bin" ]]; then
export PATH="$HOME/bin:$PATH"
fi
# add XDG spec bin dir
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
if [[ -d "$HOME/.local/bin" ]]; then
export PATH="$HOME/.local/bin:$PATH"
fi
# if there's a Rust Cargo bin directory, add it to path
if [[ -d "$HOME/.cargo/bin" ]]; then
export PATH="$HOME/.cargo/bin:$PATH"
fi
# export work scripts to path
if [ -d $HOME/work/scripts ]; then
export PATH=$PATH:$HOME/work/scripts
fi
# if z script is installed, source it
if [ -f "$HOME/github/z/z.sh" ]; then
source "$HOME/github/z/z.sh"
fi
# if asdf installed, source it
ASDF="$HOME/github/asdf/asdf.sh"
if [ -f $ASDF ]; then
source $ASDF
fi
eval "$(direnv hook zsh)"
# ensure tmux session is spawned and attached
TMUX_SESSION_NAME="$(whoami)"
if [ ! -n "${TMUX+set}" ]; then
tmux attach -t ${TMUX_SESSION_NAME} 2>/dev/null || \
tmux new-session -s ${TMUX_SESSION_NAME}
fi