-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
182 lines (155 loc) · 4.57 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
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
# Enable Powerlevel10k instant promptsource 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
# Setup zinit path
ZINIT_HOME="${XDG_CACHE_HOME:-${HOME}/.local/share}/zinit/zinit.git"
# Install Zinit
if [ ! -d "${ZINIT_HOME}" ]; then
mkdir -p "$(dirname $ZINIT_HOME)"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi
# Load Zinit
source "${ZINIT_HOME}/zinit.zsh"
# Install PowerLevel10k
zinit ice depth=1; zinit light romkatv/powerlevel10k
# Fundamental zsh plugins
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
# Load and style completion
autoload -U compinit && compinit # Load completions
eval "$(dircolors -b)" # setup LS_COLORS
zmodload zsh/complist # Load complist
autoload -U colors && colors # Colors
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} # Highlight files like ls --colors
zstyle ':completion:*' menu select # Highlight selected
zstyle ':completion:*' rehash true # To get new binaries into PATH
bindkey '^[[Z' reverse-menu-complete
# Word killing per separator
WORDCHARS=''
#WORDCHARS='*?_-.[]~=/&;!#$%^(){}<> '
bindkey '^W' backward-kill-word
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[3~" delete-char
# EMACS & quality-of-life binds
bindkey -e
bindkey '^@' autosuggest-accept
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward
bindkey -s '^[a' '^P^M'
bindkey -s '^[l' ' ls^J'
bindkey -s '^[L' ' ls -A^J'
bindkey -s '^[k' ' ls -T^J'
bindkey -s '^[K' ' ls -TA^J'
bindkey '^[[1;5D' backward-word
bindkey '^[[1;5C' forward-word
bindkey -s '^[h' ' history^J'
bindkey -s '^[t' 'tmux^J'
# FZF binds
if command -v fzf 2>&1 >/dev/null && [[ `uname` != *CYGWIN* ]]; then
source <(fzf --zsh)
bindkey "^R" fzf-history-widget
bindkey "^T" fzf-file-widget
bindkey "^[c" fzf-cd-widget
fi
# History up/down arrows
bindkey "^[[A" up-line-or-search
bindkey "^[[B" down-line-or-search
# History
HISTSIZE=25000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
setopt append_history
setopt share_history
setopt extended_history
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups
setopt hist_verify
setopt hist_expire_dups_first
# Dirs & cd
setopt auto_push_d
setopt auto_cd
setopt completeinword
setopt push_d_ignore_dups
# Dunoo, was in old one
setopt interactive
setopt monitor
# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# Fundamental aliases
alias reload='source ~/.zshrc'
alias now='date +"%d.%m.%Y %H:%M:%S"'
alias d='dirs -p'
alias .,='popd'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias mkdir='mkdir -p'
alias ls='ls -C --color' # ls-es
alias lsa='ls -A'
alias lsd='ls -d'
alias lss='ls -sh'
alias l='ls -1'
alias la='l -A'
alias ll='ls -lh'
alias llg='ll -g'
alias lla='ll -A'
alias llag='lla -g'
alias lld='ll -d'
alias lldg='lld -g'
# Setup file editor
EDITOR=$(
command -v nvim 2>/dev/null ||
command -v vim 2>/dev/null ||
command -v vi 2>/dev/null ||
command -v nano 2>/dev/null ||
command -v ed 2>/dev/null ||
echo "echo No editor found")
EDITOR=`basename $EDITOR`
alias ${EDITOR}rc="${EDITOR} ~/.${EDITOR}rc"
# Aliases for editing config files
alias zshrc="${EDITOR} ~/.zshrc"
# Load aliases, functions, exports, etc.
if [ -f ~/.zsh_functions ]; then
source ~/.zsh_functions
alias functions="${EDITOR} ~/.zsh_functions"
fi
if [ -f ~/.zsh_aliases ]; then
source ~/.zsh_aliases
alias aliases="${EDITOR} ~/.zsh_aliases"
fi
if [ -f ~/.zsh_exports ]; then
source ~/.zsh_exports
alias exports="${EDITOR} ~/.zsh_exports"
fi
# Load gitconfig if needed
if [ ! -f ~/.gitconfig ]; then
source ~/.files/gitconfig.sh
fi
alias gitconfig="${EDITOR} ~/.files/gitconfig.sh"
# Load cygwin workarounds if needed
if [[ `uname` == *CYGWIN* ]]; then
if [ -f ~/.zsh_cygwin ]; then
source ~/.zsh_cygwin
alias cygwin="${EDITOR} ~/.zsh_cygwin"
fi
fi
# Zoxide
export PATH=$PATH:${HOME}/.local/bin
eval "$(zoxide init --cmd cd zsh)"
# Zinit caching
zinit cdreplay -q
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
if [[ `uname` == *CYGWIN* ]]; then
cd - > /dev/null
fi