about summary refs log tree commit diff
path: root/.config/zsh/.zshrc
blob: 09ae41fa7fe834499ac2e6a299c02f2ac2cadb2e (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
# set ZPROF to measure startup time
[[ -v ZPROF ]] && zmodload zsh/zprof

# colors in virtual console
# Tomorrow's Stars theme, lightly adapted from Tomorrow <https://github.com/chriskempson/tomorrow-theme>
if [ "$TERM" = 'linux' ]; then
	echo -ne "\e]P01d1f21"
	echo -ne "\e]P1d54e53"
	echo -ne "\e]P2b9ca4a"
	echo -ne "\e]P3e7ba47"
	echo -ne "\e]P47aa6da"
	echo -ne "\e]P5c397d8"
	echo -ne "\e]P670c0b1"
	echo -ne "\e]P7969896"
	echo -ne "\e]P8373b41"
	echo -ne "\e]P9cc6666"
	echo -ne "\e]PAb5bd68"
	echo -ne "\e]PBf0c674"
	echo -ne "\e]PC81a2be"
	echo -ne "\e]PDb294bb"
	echo -ne "\e]PE8abeb7"
	echo -ne "\e]PFc5c8c6"
	clear
fi

# plugin - fzf
# arch puts these here
if [[ -a /usr/share/fzf/key-bindings.zsh ]] && [[ -a /usr/share/fzf/completion.zsh ]]; then
	export FZF_DEFAULT_OPTS='--no-height --no-reverse'
	source /usr/share/fzf/key-bindings.zsh
	source /usr/share/fzf/completion.zsh
fi

# magic navigation
setopt autocd
export CDPATH=".:$HOME:$HOME/devil:$HOME/src"
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'

# a bit nicer life when copy/pasting commands from docs
setopt interactive_comments

# aliases
alias cls=clear
alias config='git --git-dir=$HOME/.dotfiles --work-tree=$HOME'

# collapse spaces into tabs in-place
# spacetotab <FILE> [WIDTH=4]
function spacetotab () {
	unexpand --tabs=${2:-4} --first-only "$1" > "$1.tmp"
	mv "$1.tmp" "$1"
}

# load remaining config
for conf in "$ZDOTDIR/"*.zsh; do
	source "${conf}"
done
unset conf

# display a fortune when opening an interactive terminal
tty -s && fortune $HOME/fortunes 2>/dev/null ||:

# set ZPROF to profile startup time
[[ -v ZPROF ]] && zprof

# startx if not already running an x server (e.g. via display manager) and only on tty1
if (command -v startx &>/dev/null) && [ -z "${DISPLAY}" ] && [ "$(tty)" = "/dev/tty1" ]; then
	exec startx
fi