blob: 8aa9f5ece0ad5a7f5f1064446e189c69f5ea38e6 (
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
|
#!/bin/zsh
# zmodload zsh/zprof
if [ "$(id -u)" -ne 0 ]
then
[ "${TTY%%tty*}" = '/dev/' ] && clear
case "${TTY#/dev/tty}" in
1) exec startx > /dev/null 2>&1 ;;
2) exec startdwl > /dev/null 2>&1 ;;
3) exec startw > /dev/null 2>&1 ;;
*) false ;;
esac && exit
fi
autoload -U select-word-style
autoload -z edit-command-line
zle -N edit-command-line
### Source files
. $XDG_CONFIG_HOME/zsh/comp.zsh
. $XDG_CONFIG_HOME/shell/functions.sh
. $XDG_CONFIG_HOME/shell/aliases.sh
. $XDG_CONFIG_HOME/zsh/widgets.zsh
# . $XDG_CONFIG_HOME/zsh/prompt.zsh
# . $XDG_CONFIG_HOME/zsh/plugins.zsh
### Programs
eval "$(starship init zsh)"
eval "$(zoxide init zsh)"
### Plugins
[ -f "$HOME/.local/share/zap/zap.zsh" ] && source "$HOME/.local/share/zap/zap.zsh"
plug "chivalryq/git-alias"
# plug "marlonrichert/zsh-autocomplete"
plug "zap-zsh/fzf"
plug "zdharma-continuum/fast-syntax-highlighting"
plug "zsh-users/zsh-autosuggestions"
plug "zsh-users/zsh-completions"
plug "MichaelAquilina/zsh-auto-notify"
export AUTO_NOTIFY_TITLE="zsh"
export AUTO_NOTIFY_BODY="%command [%exit_code]"
AUTO_NOTIFY_IGNORE+=("gurk" "ttyper" "pulsemixer" "tmux" "btop" "vis" "clock")
# Substring search settings
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="bg=blue,fg=black,bold"
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=black,bold'
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
# Zsh System keyboard settings
if [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then
ZSH_SYSTEM_CLIPBOARD_METHOD="xsc"
else
ZSH_SYSTEM_CLIPBOARD_METHOD="wlc"
fi
# Add nnn shell level to prompt
[ -n "$NNNLVL" ] && PS1="N$NNNLVL$PS1"
# cd on nnn quiting
nnn_cd ()
{
if ! [ -z "$NNN_PIPE" ]; then
printf "%s\0" "0c${PWD}" > "${NNN_PIPE}" !&
fi
}
trap nnn_cd EXIT
# Check if in tmux and if a venv directory exists activate the python environment
if [ ! -z "$TMUX" ] && [ -d "./env" ]; then
. ./env/bin/activate
fi
### Keybinds
bindkey -v
bindkey -M visual S add-surround
bindkey "^A" beginning-of-line
bindkey "^E" end-of-line
bindkey '^I' expand-or-complete-prefix # necessary for completeinword
bindkey '^Y' autosuggest-accept
bindkey "^K" kill-line
bindkey "^P" up-line-or-history
bindkey "^N" down-line-or-history
bindkey "^V" quoted-insert
bindkey "^Xa" _expand_alias
bindkey "^Xe" edit-command-line
bindkey "^[." insert-last-word
bindkey "^['" quote-line
bindkey '\ea' autosuggest-toggle
bindkey '^Xp' push-input
## Move around using h j k l in completion menu
zmodload zsh/complist
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect '^xg' clear-screen
## interactive mode
bindkey -M menuselect '^xi' vi-insert
bindkey -M menuselect '^xh' accept-and-hold # Hold
bindkey -M menuselect '^xn' accept-and-infer-next-history # Next
bindkey -M menuselect '^xu' undo # Undo
## window title hooks
add-zsh-hook -Uz preexec () { print -n "\e]0;$1\a\033[0m"; }
add-zsh-hook -Uz precmd set_wt (){ print -Pn "\e]0;%n@%m on %~\a"; }
## automatic ls after cd
add-zsh-hook -Uz chpwd (){ [ "$PWD" = "$HOME" ] || ls -A; }
### Variables
## Run menuscripts with fzf
export MENUCMD='fzf'
## vi mode escape fix
export KEYTIMEOUT=1
### Options
setopt correct
setopt nonomatch
setopt autocd
setopt completeinword
setopt extendedglob
setopt histignorealldups
setopt histreduceblanks
setopt interactivecomments
setopt notify
setopt cdablevars
# zprof
|