/
.zshrc
214 lines (185 loc) · 7.1 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
## Terminal
# Disable Ctrl+S and Ctrl+Q
stty -ixon
# Use hard tabs
stty tab0
# Set tab width
tabs -4
# vi mode
bindkey -v
## ZSH
autoload -Uz promptinit colors vcs_info compinit history-search-end
# Prompt
promptinit
colors
setopt INTERACTIVE_COMMENTS
setopt PROMPT_SUBST
precmd() {
vcs_info
print -Pn "\e]0;%n@%m %~\a"
}
# ZSH parameters
USR_HOST="%F{cyan}%n%f@%F{cyan}%m%f"
DIRECTORY="%F{green}%~%f"
ARROW="%(?..%F{red})➤%f"
PROMPT='╭─${USR_HOST} ${DIRECTORY} ${vcs_info_msg_0_}
╰─${ARROW} '
RPROMPT='%t'
TIMEFMT=$'\nreal\t%*Es\nuser\t%*Us\nsys\t%*Ss'
# Git
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr "%F{green}A%f"
zstyle ':vcs_info:*' unstagedstr "%F{red}M%f"
zstyle ':vcs_info:*' formats '%F{cyan}(%F{red}%b%F{cyan})%f %c%u'
# Autocompletion
compinit -d "$XDG_CACHE_HOME/zsh/zcompdump"
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
zstyle ':completion:*:options' auto-description '%d'
zstyle ':completion:*:default' list-colors ''
zstyle ':completion:*:default' list-prompt ''
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' menu select
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-dirs-first true
zstyle ':completion:*' verbose yes
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*:options' description 'yes'
# Completion formatting
zstyle ':completion:*' format ' %F{yellow}-- %d --%f'
zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f'
zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f'
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
# Bind keys
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey '\eOc' forward-word # ctrl-right
bindkey '\eOd' backward-word # ctrl-left
bindkey '\e[3~' delete-char # del
bindkey '\e[7~' beginning-of-line # home
bindkey '\e[8~' end-of-line # end
bindkey '\e[A' history-beginning-search-backward-end # up
bindkey '\e[B' history-beginning-search-forward-end # down
bindkey '\e[Z' reverse-menu-complete # shift-tab
bindkey '\eh' kill-whole-line # meta-h
bindkey '\ej' history-beginning-search-forward-end # meta-j
bindkey '\ek' history-beginning-search-backward-end # meta-k
bindkey '\el' accept-line # meta-l
bindkey '^R' history-incremental-pattern-search-backward # ctrl-r
# History
setopt APPEND_HISTORY
setopt EXTENDED_HISTORY
setopt HIST_FIND_NO_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_DUPS
setopt HIST_REDUCE_BLANKS
setopt HIST_SAVE_NO_DUPS
HISTFILE="$XDG_CACHE_HOME/zsh/zsh_history"
HISTSIZE=10000
SAVEHIST=10000
## Aliases
# General
alias ..="cd .."
alias ...="cd ../.."
alias ..2="cd ../.."
alias ..3="cd ../../.."
alias ..4="cd ../../../.."
alias cp='cp -i'
alias df="df -h"
alias diff="diff --color"
alias du="du -h"
alias e="aliases emacs"
alias emacs="aliases emacs"
alias fuck='sudo $(fc -ln -1)'
alias grep="grep --color=always"
alias ip="ip --color"
alias ipb="ip --color --brief a"
alias l.="\ls -lAGh --color --group-directories-first --hyperlink | awk '{ if (\$NF ~ /^(.*m)?\./) print }'"
alias la="\ls -lAGh --color --group-directories-first --hyperlink"
alias less="less -x 4"
alias ls="ls --color --group-directories-first --hyperlink"
alias mkdir="mkdir -pv"
alias mv='mv -i'
alias pkill="pkill -9"
alias q="exit"
alias rm="rm -i"
alias se="sudoedit"
alias semacs="sudoedit"
alias ss="sudo systemctl"
alias v="vim --servername VIM"
alias vim="vim --servername VIM"
# Config
alias c="config"
alias zshrc="$EDITOR $ZDOTDIR/.zshrc && source $ZDOTDIR/.zshrc"
alias lxrdb="xrdb $XDG_CONFIG_HOME/xorg/Xresources"
alias lzshrc="source $ZDOTDIR/.zshrc"
# Pacman
alias cache="sudo paccache -r -k 2"
alias clean='sudo pacman -Rns $(pacman -Qtdq)'
alias depend="aliases depend"
alias download="sudo pacman -Syuw --noconfirm"
alias install="sudo pacman -S --needed"
alias remove="sudo pacman -Rns"
alias search="aliases pacman_search"
alias update="sudo pacman -Syyu"
alias update-all="trizen -Syyu --devel --needed"
alias update-mirrorlist="aliases update_mirrorlist"
# Programming
alias jdoc="aliases java_doc"
alias jr="aliases java_run"
alias raspbian="aliases raspbian"
alias ser="pio device monitor -b 9600"
alias upl="pio run -t upload"
alias qmake="qmake -makefile ../ && make"
# Git
alias g="git"
alias ga="git add"
alias gap="git add -p"
alias gb="git branch"
alias gc="git commit"
alias gch="git checkout"
alias gd="git diff"
alias gdc="git diff --cached"
alias gds="git diff --staged"
alias gf="git fetch"
alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%ai%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d %C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
alias gle="git log --graph --stat --format=format:'%C(bold blue)commit %H%C(reset)%C(bold yellow)%d %C(reset)%nAuthor: %C(dim white)%an <%ae>%C(reset)%nDate: %C(bold cyan)%ai%C(reset) %C(bold green)(%ar)%C(reset)%n%n%w(64,4,4)%B'"
alias gm="git merge"
alias gp="git pull"
alias gps='git push || git push origin $(git branch --show-current)'
alias gpsa='git remote | xargs -I remotes git push remotes $(git branch --show-current)'
alias gpsaf='git remote | xargs -I remotes git push --force remotes $(git branch --show-current)'
alias gr="git reset"
alias gs="git status"
alias gsh="git show --format=format:'%C(bold blue)commit %H%C(reset) %C(bold yellow)%d %C(reset)%nAuthor: %C(dim white)%an <%ae>%C(reset)%nDate: %C(bold cyan)%ai%C(reset) %C(bold green)(%ar)%C(reset)%n%n%w(64,4,4)%B'"
alias gt='git ls-tree -r --name-only $(git branch --show-current) .'
# Scripts
alias nc="netictl"
alias vc="volctl"
alias vp="vimplugin"
# Other
alias crypto="curl 'https://rate.sx/?qF'"
alias IP="curl https://ifconfig.me"
alias len="xclip -o | wc -m"
alias length="rofi -dmenu -i -p 'String length' -lines 0 | tr -d '\n' | wc -m"
alias p="aliases pastebin"
alias screencast="aliases screencast"
alias stream="aliases stream"
alias temp="watch -n 2 sensors"
alias u="setsid -f urxvt -cd $PWD"
alias weather="curl -s 'https://wttr.in/dordrecht?q&n&p' | head -n -3"
alias webmconvert="aliases webmconvert"
alias windowname="xprop | grep -e WM_CLASS -e WM_NAME"
alias workbench="GDK_SCALE=1 GDK_DPI_SCALE=1 setsid -f -- mysql-workbench > /dev/null 2>&1"
mkcd() { mkdir -pv -- "$1" && cd -P -- "$1" || exit; }
highlighting="/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
if [ -f "$highlighting" ]; then
source "$highlighting";
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
ZSH_HIGHLIGHT_STYLES[path]="fg=12,underline"
fi
unset highlighting
[ -f "$ZDOTDIR/.zshrc_extended" ] && source "$ZDOTDIR/.zshrc_extended"