zshrc - dotfiles - configuration files for various applications

index : dotfiles
configuration files for various applications anrxc
summary refs log tree commit diff
path: root/zshrc
blob: a151e25f2b92168e35d7948a861b3b31f5b0543b (plain)
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# -*- shell-script -*-
# 
# anrxc's init file for Z-SHELL 4.3.10 on Arch GNU/Linux.
# {{{ User settings
# {{{ Environment
#umask 022
export PATH="${PATH}:${HOME}/code/bin"
export HISTFILE="${HOME}/.zsh_history"
export HISTSIZE=10000
export SAVEHIST=10000
export LESSHISTFILE="-"
export PAGER="less"
export READNULLCMD="${PAGER}"
export VISUAL="emacsclient"
export EDITOR="${VISUAL}"
export BROWSER="firefox"
export XTERM="urxvt"
export GIT_CEILING_DIRECTORIES=/home
# }}}
# {{{ Mail settings
#export MAIL="~/mail/INBOX"
#export MAILCHECK=300
export GPGKEY="0x0000000000000000"
# }}}
# {{{ Dircolors
# - with rxvt-256color support
eval `dircolors -b "${HOME}/.dir_colors"`
# }}}
# {{{ Manual pages
# - colorize, since man-db fails to do so
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;31m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
export LESS_TERMCAP_so=$'\E[1;33;40m' # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m' # end underline
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
# }}}
# {{{ Aliases
# {{{ Main
alias ..="cd .."
alias ...="cd ../.."
alias ls="ls -aF --color=always"
alias ll="ls -l"
alias lfi="ls -l | egrep -v '^d'"
alias ldi="ls -l | egrep '^d'"
alias lti="ls -lt | grep -E -v '^d'"
alias lst="ls -htl | grep `date +%Y-%m-%d`"
alias grep="grep --color=always"
alias cp="cp -ia"
alias mv="mv -i"
alias rm="rm -i"
alias shred="shred -uz"
alias cls="clear"
alias upmem="ps -eo pmem,pcpu,rss,vsize,args | sort -k 1"
alias top="htop"
alias psg="ps auxw | grep -i "
alias psptree="ps auxwwwf"
alias df="df -hT"
alias du="du -hc"
alias dus="du -S | sort -n"
alias free="free -m"
alias su="su - "
alias x="startx &! logout"
alias rehash="hash -r"
alias eject="eject -v /dev/sr0 "
alias retract="eject -t -v /dev/sr0 "
alias vuser="fuser -v "
alias ping="ping -c 5"
alias more="less"
alias mc=". /usr/lib/mc/mc-wrapper.sh -x"
alias links="links ${HOME}/.links/startpage.html"
alias play="play -v"
alias xtr="extract"
alias last='last -adn 10'
alias screen="screen -U -l"
alias scr="screen -r"
alias scd="screen -rd"
alias sat="date +%R"
alias bat="acpitool -b"
#alias bat="upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep 'percent\|state'"
alias calc="bc -l <<<"
alias iodrag="ionice -c3 nice -n19"
alias spell="aspell -a <<< "
alias ec="emacsclient -a emacs -n "
alias ect="emacsclient -a emacs -t "
alias gpgd="gpg2 -dq"
alias gpge="gpg2 -ear $GPGKEY"
alias passgen="< /dev/urandom tr -cd \[:graph:\] | fold -w 32 | head -n 5"
alias keyshare="synergys -f --config /etc/synergy.conf"
alias keysharex2x='ssh -X SERVER x2x -noscale -west -to :1'
alias xpop="xprop | grep --color=none 'WM_CLASS\|^WM_NAME' | xmessage -file -"
alias urldecode='python3 -c "import sys; from urllib.parse import unquote; print(unquote(sys.stdin.read()));"'
alias mimedecode='python3 -c "import sys; from email.header import decode_header, make_header; print(make_header(decode_header(sys.stdin.read())));"'
alias dmesg="\dmesg -T"
# }}}
# {{{ Pacman
alias pacsy="sudo pacman -Sy" # Sync & Update
alias pacup="sudo pacman -Syu" # Sync, Update & Upgrade
alias pacdg="sudo pacman -Syuu" # Sync, Update & Downgrade
alias paclu="pacman -Qu" # List upgradeable
alias pacin="sudo pacman -S" # Install a specific package
alias pacnd="sudo pacman -Sdd" # Install a package but ignore deps
alias pacrm="sudo pacman -Rns" # Remove a specific package
alias pacrd="sudo pacman -Rdd" # Remove a package but ignore deps
alias pacss="pacman -Ss" # Search for a package
alias pacsl="pacman -Qs" # Search for a package localy
alias pacsi="pacman -Si" # Package info
alias pacqi="pacman -Qi" # Package local info
alias pacls="pacman -Ql" # List files in a package
alias pacui="pacman -Qm" # List localy built packages
alias pacfi="pacman -Qo" # Which package file belongs to
alias paccl="sudo pacman -Scc" # Fully clean the package cache
alias pacdl="sudo pacman -Swdd" # Download a package without installing
alias paclo="pacman -Qdt" # List package orphans
alias paclog="pacman -Qc" # Package changelog
# }}}
# {{{ Slurpy
alias aurup="slurpy -c -u -d" # Sync, Update & Download
alias aurlu="slurpy -c -u" # Update & List upgradeable
alias aurss="slurpy -c -s" # Search for a package
alias aursi="slurpy -c -i" # Package info
alias aurgo="slurpy -c -g" # Visit AUR page
alias aurdl="slurpy -c -d" # Download a package without installing
# }}}
# {{{ Swaret
alias swup="sudo swaret --update --upgrade" # Sync, Update & Upgrade
alias swsy="sudo swaret --update" # Sync & Update
alias swlu="sudo swaret --list -u" # List upgradeable
alias swin="sudo swaret --install" # Install a specific package
alias swrm="sudo swaret --remove" # Remove a specific package
alias swss="sudo swaret --search" # Search for a package
swsl() { sudo swaret --search "1ドル" -i } # Search for a package localy
swsi() { sudo swaret --show "1ドル" -p } # Package info
swqi() { sudo swaret --show "1ドル" -i } # Package local info
swls() { less `locate /var/log/packages/"1ドル"` } # List files in a package
swfi() { grep "1ドル" /var/log/packages/* } # Which package file belongs to
alias swui="sudo swaret --search aic -i" # List localy built packages
alias swcl="sudo swaret --purge" # Fully clean the package cache
alias swdl="sudo swaret --get" # Download a package without installing
alias swlog="sudo swaret --changelog" # Package changelog
# }}}
# {{{ apt-get
alias aptup="sudo apt-get update" # Sync and Update
alias aptlu="sudo apt-get upgrade" # Update & List upgradeable
alias aptss="sudo apt-cache search" # Search for a package
alias aptsi="sudo apt-cache showpkg" # Package info
alias aptsii="sudo apt-cache depends" # Package dependencies
alias aptqi="sudo apt-cache rdepends" # Reverse dependencies
alias aptsl="dpkg -l | grep" # Search for a package locally
alias aptls="dpkg -L" # List files in a package
alias aptdl="sudo apt-get install --download-only" # Download a package without installing
alias aptlo="deborphan" # List orphans
alias aptlor="deborphan" # List orphans
alias aptlob="sudo apt-get --dry-run autoremove" # List obsolete dependency packages
alias aptfi="dpkg -S" # Which package file belongs to
alias aptcl="sudo apt-get clean" # Fully clean the package cache
# }}}
# }}}
# {{{ Completion
compctl -k "(add delete draft edit list import preview publish update)" nb
# }}}
# }}}
# {{{ ZSH settings
setopt emacs
setopt nohup
setopt autocd
#setopt cdablevars
setopt ignoreeof
setopt nobgnice
setopt nobanghist
setopt clobber
setopt shwordsplit
setopt interactivecomments
setopt autopushd pushdminus pushdsilent pushdtohome
setopt histreduceblanks histignorespace inc_append_history
# Prompt requirements
setopt extended_glob prompt_subst
autoload colors zsh/terminfo
# New style completion system
autoload -U compinit; compinit
# * List of completers to use
zstyle ":completion:*" completer _complete _match _approximate
# * Allow approximate
zstyle ":completion:*:match:*" original only
zstyle ":completion:*:approximate:*" max-errors 1 numeric
# * Selection prompt as menu
zstyle ":completion:*" menu select=1
# * Menu selection for PID completion
zstyle ":completion:*:*:kill:*" menu yes select
zstyle ":completion:*:kill:*" force-list always
zstyle ":completion:*:processes" command "ps -au$USER"
zstyle ":completion:*:*:kill:*:processes" list-colors "=(#b) #([0-9]#)*=0=01;32"
# * Don't select parent dir on cd
zstyle ":completion:*:cd:*" ignore-parents parent pwd
# * Complete with colors
zstyle ":completion:*" list-colors ""
# }}}
# {{{ Functions
function web () { "${BROWSER}" "http://yubnub.org/parser/parse?command=${*}" }
function utime() { perl -e "print scalar gmtime 1ドル" }
function pmem () { ps -o rss,comm -p `pgrep "1ドル"` }
function dsync () { rsync -lprt --progress --stats --delete "1ドル/" "2ドル/" }
function ssnap () {
 [ "1ドル" ] && fname="1ドル" || fname="snapshot"
 [ "2ドル" ] && tmout="2ドル" || tmout=5
 [ "3ドル" ] && format="3ドル" || format=png
 fname="${HOME}/${fname}-$(date '+%d%m%y-%H%M')"
 echo -n "Snapshot in "
 for ((i=${tmout}; i>=1; i--)); do echo -n "${i}.. "; sleep 1; done
 import -window root -quality 100 "${fname}.${format}"
 #convert -resize "15%" "${fname}.${format}" "${fname}.th.${format}" # Legacy
 magick "${fname}.${format}" -resize "15%" "${fname}.th.${format}" # Modern (archlinux)
 #convert-im6.q16 "${fname}.${format}" -resize "15%" "${fname}.th.${format}" # Modern (debianlinux)
 echo ": ${fname}.${format}"
}
function extract () {
 if [[ -f "1ドル" ]]; then
 case "1ドル" in
 *.tbz2 | *.tar.bz2) tar -xvjf "1ドル" ;;
 *.txz | *.tar.xz) tar -xvJf "1ドル" ;;
 *.tgz | *.tar.gz) tar -xvzf "1ドル" ;;
 *.tzst | *.tar.zst) tar --use-compress-program=unzstd -xvf "1ドル" ;;
 *.tar | *.cbt) tar -xvf "1ドル" ;;
 *.zip | *.cbz) unzip "1ドル" ;;
 *.rar | *.cbr) unrar x "1ドル" ;;
 *.arj) unarj x "1ドル" ;;
 *.ace) unace x "1ドル" ;;
 *.bz2) bunzip2 "1ドル" ;;
 *.xz) unxz "1ドル" ;;
 *.gz) gunzip "1ドル" ;;
 *.7z) 7z x "1ドル" ;;
 *.Z) uncompress "1ドル" ;;
 *.gpg) gpg2 -d "1ドル" | tar -xvzf - ;;
 *) echo "Error: failed to extract '1ドル'" ;;
 esac
 else
 echo "Error: '1ドル' is not a valid file for extraction"
 fi
}
# {{{ Terminal and prompt
function precmd {
 # Terminal width = width - 1 (for lineup)
 local TERMWIDTH
 ((TERMWIDTH=${COLUMNS} - 1))
 # Truncate long paths
 PR_FILLBAR=""
 PR_PWDLEN=""
 local PROMPTSIZE="${#${(%):---(%n@%m:%l)---()--}}"
 local PWDSIZE="${#${(%):-%~}}"
 if [[ "${PROMPTSIZE} + ${PWDSIZE}" -gt ${TERMWIDTH} ]]; then
	((PR_PWDLEN=${TERMWIDTH} - ${PROMPTSIZE}))
 else
 PR_FILLBAR="\${(l.((${TERMWIDTH} - (${PROMPTSIZE} + ${PWDSIZE})))..${PR_HBAR}.)}"
 fi
}
function preexec () {
 # Screen window titles as currently running programs
 if [[ "${TERM}" == "screen-256color" ]]; then
 local CMD="${1[(wr)^(*=*|sudo|-*)]}"
 echo -n "\ek$CMD\e\\"
 fi
}
function setprompt () {
 if [[ "${terminfo[colors]}" -ge 8 ]]; then
 colors
 fi
 for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
	eval PR_"${color}"="%{${terminfo[bold]}$fg[${(L)color}]%}"
	eval PR_LIGHT_"${color}"="%{$fg[${(L)color}]%}"
 done
 PR_NO_COLOUR="%{${terminfo[sgr0]}%}"
 # Try to use extended characters to look nicer
 typeset -A altchar
 set -A altchar ${(s..)terminfo[acsc]}
 PR_SET_CHARSET="%{${terminfo[enacs]}%}"
 PR_SHIFT_IN="%{${terminfo[smacs]}%}"
 PR_SHIFT_OUT="%{${terminfo[rmacs]}%}"
 PR_HBAR="${altchar[q]:--}"
 PR_ULCORNER="${altchar[l]:--}"
 PR_LLCORNER="${altchar[m]:--}"
 PR_LRCORNER="${altchar[j]:--}"
 PR_URCORNER="${altchar[k]:--}"
 # Terminal prompt settings
 case "${TERM}" in
 dumb) # Simple prompt for dumb terminals
 unsetopt zle
 PROMPT='%n@%m:%~%% '
 ;;
 linux) # Simple prompt with Zenburn colors for the console
 echo -en "\e]P01e2320" # zenburn black (normal black)
 echo -en "\e]P8709080" # bright-black (darkgrey)
 echo -en "\e]P1705050" # red (darkred)
 echo -en "\e]P9dca3a3" # bright-red (red)
 echo -en "\e]P260b48a" # green (darkgreen)
 echo -en "\e]PAc3bf9f" # bright-green (green)
 echo -en "\e]P3dfaf8f" # yellow (brown)
 echo -en "\e]PBf0dfaf" # bright-yellow (yellow)
 echo -en "\e]P4506070" # blue (darkblue)
 echo -en "\e]PC94bff3" # bright-blue (blue)
 echo -en "\e]P5dc8cc3" # purple (darkmagenta)
 echo -en "\e]PDec93d3" # bright-purple (magenta)
 echo -en "\e]P68cd0d3" # cyan (darkcyan)
 echo -en "\e]PE93e0e3" # bright-cyan (cyan)
 echo -en "\e]P7dcdccc" # white (lightgrey)
 echo -en "\e]PFffffff" # bright-white (white)
 PROMPT='$PR_GREEN%n@%m$PR_WHITE:$PR_YELLOW%l$PR_WHITE:$PR_RED%~$PR_YELLOW%%$PR_NO_COLOUR '
 ;;
# rxvt-unicode-256color)
# PROMPT='$PR_SET_CHARSET$PR_GREEN$PR_SHIFT_IN$PR_ULCORNER$PR_GREEN$PR_HBAR\
#$PR_SHIFT_OUT($PR_YELLOW%n@%m$PR_WHITE:$PR_GREEN%l)$PR_SHIFT_IN$PR_HBAR$PR_GREEN$PR_HBAR\
#${(e)PR_FILLBAR}$PR_GREEN$PR_HBAR$PR_SHIFT_OUT($PR_RED%$PR_PWDLEN<...<%~%<<$PR_GREEN)\
#$PR_SHIFT_IN$PR_HBAR$PR_HBAR$PR_GREEN$PR_URCORNER$PR_SHIFT_OUT\
#
#$PR_GREEN$PR_SHIFT_IN$PR_LLCORNER$PR_GREEN$PR_HBAR$PR_SHIFT_OUT(%(?..$PR_RED%?$PR_WHITE:)\
#%(!.$PR_RED.$PR_YELLOW)%#$PR_GREEN)$PR_NO_COLOUR '
#
# RPROMPT=' $PR_GREEN$PR_SHIFT_IN$PR_HBAR$PR_GREEN$PR_LRCORNER$PR_SHIFT_OUT$PR_NO_COLOUR'
# ;;
 *) # Main prompt
 # - double $PR_HBAR$PR_HBAR not needed in screen and
 # xterm, rxvt-unicode broke in 2023 for some reason
 # after all these years
 # - in 2024 on ubuntu-24 it's fixed once again, commented rxvt case above
 PROMPT='$PR_SET_CHARSET$PR_GREEN$PR_SHIFT_IN$PR_ULCORNER$PR_GREEN$PR_HBAR\
$PR_SHIFT_OUT($PR_YELLOW%n@%m$PR_WHITE:$PR_GREEN%l)$PR_SHIFT_IN$PR_HBAR$PR_GREEN$PR_HBAR\
${(e)PR_FILLBAR}$PR_GREEN$PR_HBAR$PR_SHIFT_OUT($PR_RED%$PR_PWDLEN<...<%~%<<$PR_GREEN)\
$PR_SHIFT_IN$PR_HBAR$PR_GREEN$PR_URCORNER$PR_SHIFT_OUT\
$PR_GREEN$PR_SHIFT_IN$PR_LLCORNER$PR_GREEN$PR_HBAR$PR_SHIFT_OUT(%(?..$PR_RED%?$PR_WHITE:)\
%(!.$PR_RED.$PR_YELLOW)%#$PR_GREEN)$PR_NO_COLOUR '
 RPROMPT=' $PR_GREEN$PR_SHIFT_IN$PR_HBAR$PR_GREEN$PR_LRCORNER$PR_SHIFT_OUT$PR_NO_COLOUR'
 ;;
 esac
}
# Prompt init
setprompt
# }}}
# }}}
# {{{ SSH client init
if [[ -n $SSH_CONNECTION ]] ; then
 alias ec="emacsclient -a emacs -t "
 alias emacs="emacs -nw"
 export EDITOR="emacs -nw"
 export VISUAL="emacs -nw"
fi
# }}}
sysphere dot org

AltStyle によって変換されたページ (->オリジナル) /