summaryrefslogtreecommitdiff
path: root/dot_config/zsh/zshrc
blob: a959e2bf142862cfb611fca15a52542b60460cc9 (plain) (blame)
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
setopt autocd noautopushd nocdablevars
setopt pushdignoredups pushdtohome
setopt globstarshort nullglob rematchpcre
setopt appendhistory histfindnodups histignoredups histignorespace histlexwords
setopt interactivecomments hashexecutablesonly pathdirs
setopt printexitvalue rcquotes shortloops
setopt hup
setopt promptpercent transientrprompt
setopt cbases functionargzero multios pipefail

bindkey -e

# grml did not run, source zshrc.pre and zshrc.local ourselves
if [ -z "$GRML_OSTYPE" ]; then
	xsource() {
		local i
		for i in "$@"; do
			[ -r "$i" ] && source "$i"
		done
	}
	xsource "${ZDOTDIR:-~}/.zshrc.local"
	autoload compinit
	compinit -C
fi
# remove stale: 14 days
find "${ZDOTDIR:-~}" -name .zcompdump -mtime 14 -exec rm '{}' ';'

hascmd() { (( ${+commands[$1]} )) }
# command replacements
hascmd bat && alias cat=bat c='bat -pp'
hascmd bfs && alias find=bfs
hascmd bsdtar && alias tar=bsdtar
hascmd colordiff && alias diff=colordiff dif='colordiff -u'
hascmd jaq && alias jq=jaq
hascmd podman && alias docker=podman
(hascmd eza && alias ls=eza tree='ls -T') ||
	(hascmd exa && alias ls=exa tree='ls -T') ||
	(hascmd lsd && alias ls=lsd lh='ls --hyperlink=auto' tree='lh --tree')
alias l='ls -l' ll='ls -l' la='ls -a' lla='ls -la'
hascmd ugrep && alias grep='ugrep -G -.' xdump='ugrep -X ""'
alias uq='ug -Q' ux='ug -UX' uz='ug -z' g='ug -G -.'

# convenience aliases
alias e='emacsclient -c -nw' E='emacsclient -c' m=micro n=nvim
alias ip='ip -c=auto'
alias dit='docker run -it --rm' drun='dit -v "$(pwd)":/pwd:Z -w /pwd'
alias ossh='ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=Error'
alias x='xh -b'

# program configuration
alias chafa='chafa -f sixel'
alias ffmpeg='ffmpeg -hide_banner'
alias ffprobe='ffprobe -hide_banner'
[ -f ~/.config/ripgrep.conf ] && export RIPGREP_CONFIG_PATH=~/.config/ripgrep.conf
export SKIM_DEFAULT_COMMAND='fd -t f || rg --files || find .'
if hascmd luarocks; then
	typeset -T LUA_CPATH=$(luarocks path --lr-cpath) lua_cpath
	typeset -T LUA_PATH="$(luarocks path --lr-path);/?.lua" lua_path
fi

t() {
	mkdir -p /tmp/t
	cd /tmp/t
}
tt() {
	local dir=$(mktemp -d)
	[ -d "$dir" ] || return 1
	cd "$dir"
	trap "rm -rf '$dir'" EXIT
}

# jump/zoxide/etc should be in zshrc.local or similar

# source zshrc.post
xsource "${ZDOTDIR:-~}/.zshrc.post"