summaryrefslogtreecommitdiff
path: root/.zshrc
blob: e3683a1c2eaa9c4d6efc6769f76588e43f8027b9 (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
if [[ -o login && -z $WAYLAND_DISPLAY && ${XDG_VTNR:-0} -eq 1 ]]; then
	export XDG_CURRENT_DESKTOP=sway
	exec dbus-run-session sway
fi

if [[ -o interactive && -z "$SSH_AUTH_SOCK" ]]; then
	eval "$(keychain --eval --quiet id_ed25519)"
fi

## Use vim mode
bindkey -v
# Yank to the system clipboard
function vi-yank-xclip {
	zle vi-yank
	print -rn -- "$CUTBUFFER" | wl-copy -n
}

zle -N vi-yank-xclip
bindkey -M vicmd 'y' vi-yank-xclip
export KEYTIMEOUT=1

# FZF integration
export FZF_DEFAULT_OPTS="
	--inline-info
	--preview-window=right:60%:wrap
	--bind=ctrl-u:preview-page-up,ctrl-d:preview-page-down
	--bind=ctrl-/:toggle-preview
	--bind 'ctrl-o:execute(nvim {})'
	--color=fg:#d0d0d0,bg:#121212,hl:#5fd7ff
	--color=fg+:#ffffff,bg+:#262626,hl+:#ffaf00
	--color=info:#87afff,prompt:#5fd7ff,pointer:#ff5f5f
	--color=marker:#ffaf00,spinner:#5fd7ff,header:#87afaf
	--preview '
	if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
		git diff --color=always {} | sed 1,200p
	elif [[ -d {} ]]; then
		tree -C {} | head -200
	else
		bat --style=numbers --color=always --line-range :500 {}
	fi
	'
"
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_OPTS="
	--preview 'tree -C {} | head -200'
"
export FZF_CTRL_R_OPTS="
	--preview 'echo {}'
	--preview-window=down:3:hidden:wrap
	--bind 'ctrl-/:toggle-preview'
	--bind 'ctrl-y:execute-silent(echo -n {2..} | wl-copy)+abort'
"
source <(fzf --zsh)

## Source other configs
### key_bindings should be before completion due to complist
source $HOME/.config/zsh/key_bindings.zsh
source $HOME/.config/zsh/completion.zsh
source $HOME/.config/zsh/prompt.zsh
source $HOME/.config/zsh/history_search.zsh
source $HOME/.config/zsh/aliases.zsh
source $HOME/.config/zsh/help_command.zsh