summaryrefslogtreecommitdiff
path: root/dot_config/zsh/zshrc
blob: 72452e92202dfd974cc1957b09ec8d91c9e8c96d (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
# vim: ft=zsh

xzsource zshrc.pre

xzsource zshrc.{options,style}

### Bindings
bindkey -e

### Functions, Aliases
## Command replacements
[[ -x =bat ]]       && alias cat=bat c='bat -pp'
[[ -x =bfs ]]       && alias find=bfs
[[ -x =bsdtar ]]    && alias tar=bsdtar
[[ -x =colordiff ]] && alias diff=colordiff dif='colordiff -u'
[[ -x =jaq ]]       && alias jq=jaq
[[ -x =podman ]]    && alias docker=podman
if     [[ -x =eza ]] { alias ls=eza tree='ls -T'
} elif [[ -x =exa ]] { alias ls=exa tree='ls -T'
} elif [[ -x =lsd ]] { alias ls=lsd lh='ls --hyperlink=auto' tree='lh --tree' }
alias l='ls -l' ll='ls -l' la='ls -a' lla='ls -la'
[[ -x =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 [[ -x =luarocks ]] {
	typeset -T LUA_CPATH=$(luarocks path --lr-cpath) lua_cpath
	typeset -T LUA_PATH="$(luarocks path --lr-path);/?.lua" lua_path
}

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

# you may want to:
# set up jump/zoxide/etc
# zstyle :completion:*:hosts list of hosts
# hash -d short=directory
xzsource zshrc.{local,post}

# if compinit hasn't ran, run it now
# this way there's at least some minimum compatibility with /etc/zshrc
if (( ! ${+_comps} )) {
	autoload -Uz compinit
	compinit -i
}

# if promptinit hasn't ran, run it now, and set a default prompt
if (( ! ${+functions[prompt]} )) {
	autoload -Uz promptinit
	promptinit
	prompt fish
}