-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_zshrc
More file actions
133 lines (108 loc) · 3.58 KB
/
_zshrc
File metadata and controls
133 lines (108 loc) · 3.58 KB
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
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export ZSH="${HOME}/.oh-my-zsh"
export ZSH_CUSTOM="${HOME}/.oh-my-zsh-custom"
ZSH_THEME="powerlevel10k/powerlevel10k"
# Show dots when loading completition takes long time.
COMPLETION_WAITING_DOTS="true"
# Use a different history date format.
HIST_STAMPS="yyyy-mm-dd"
# Allow longer history
SAVEHIST=20000
# Share history between shells.
setopt share_history
# Autostart tmux.
ZSH_TMUX_AUTOSTART=false
ZSH_TMUX_AUTOQUIT=false
# Disable oh-my-zsh autoupdate.
DISABLE_AUTO_UPDATE=true
# Load plugins and oh-my-zsh.
plugins=(
git
sudo
tmux
vi-mode
systemd
zsh-autosuggestions
)
source "${ZSH}/oh-my-zsh.sh"
# Enable fzf
if hash fzf 2>/dev/null; then
source <(fzf --zsh)
fi
# Enable direnv
if hash direnv 2>/dev/null; then
eval "$(direnv hook zsh)"
fi
# Enable pyenv
if hash pyenv 2>/dev/null; then
eval "$(pyenv init - zsh)"
eval "$(pyenv virtualenv-init - zsh)"
fi
# Enable zoxide
if hash zoxide 2>/dev/null; then
eval "$(zoxide init zsh)"
fi
# Accept autosuggestions using Ctrl+Space
bindkey "^ " autosuggest-execute
# Enable aliases to pass through sudo.
alias sudo='sudo '
# Use neovim or vim with panels by default.
if hash nvim 2>/dev/null; then
alias vim='nvim -p'
else
alias vim='vim -p'
fi
# Move to trash instead of hard rm.
# if hash trash 2>/dev/null; then
# alias rm='trash'
# fi
# Fast jump to git root.
alias cgr='cd "$(git rev-parse --show-toplevel)"'
# Add an "alert" alias for long running commands. Example:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" \
"$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias for `du` sorted by size.
function du-sort() {
du -csBM "$@" | sort -n
}
# Set restricted umask for non-root users.
# if [[ $EUID -ne 0 ]]; then
# umask 007
# fi
# Find the right sequences of special keys.
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
key[CtrlLeft]="^[[1;5D"
key[CtrlRight]="^[[1;5C"
# Setup the keys accordingly.
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
[[ -n "${key[CtrlLeft]}" ]] && bindkey "${key[CtrlLeft]}" backward-word
[[ -n "${key[CtrlRight]}" ]] && bindkey "${key[CtrlRight]}" forward-word
# Load local zshrc.
if [ -f "${HOME}/.zshrc-local" ]; then
source "${HOME}/.zshrc-local"
fi
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh