forked from maximbaz/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
146 lines (111 loc) · 5 KB
/
.zshrc
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
134
135
136
137
138
139
140
141
142
143
144
145
146
zstyle ':z4h:' auto-update no
zstyle ':z4h:' start-tmux no
zstyle ':z4h:' term-shell-integration yes
zstyle ':z4h:' propagate-cwd yes
zstyle ':z4h:*' channel stable
zstyle ':z4h:autosuggestions' forward-char accept
zstyle ':z4h:fzf-complete' fzf-command my-fzf
zstyle ':z4h:(fzf-complete|fzf-dir-history|fzf-history)' fzf-flags --no-exact --color=hl:14,hl+:14
zstyle ':z4h:(fzf-complete|fzf-dir-history)' fzf-bindings 'tab:repeat'
zstyle ':z4h:fzf-complete' find-flags '(' -name '.git' -o -name node_modules ')' -prune -print -o -print
zstyle ':z4h:ssh:*' enable no
zstyle ':z4h:ssh:*' ssh-command command ssh
zstyle ':z4h:ssh:*' term 'xterm-256color'
zstyle ':z4h:ssh:*' send-extra-files '~/.zsh-aliases'
zstyle ':zle:(up|down)-line-or-beginning-search' leave-cursor yes
zstyle ':z4h:term-title:ssh' preexec '%* | %n@%m: ${1//\%/%%}'
zstyle ':z4h:term-title:local' preexec '%* | ${1//\%/%%}'
zstyle ':z4h:direnv' enable yes
zstyle ':completion:*:ssh:argument-1:' tag-order hosts users
zstyle ':completion:*:scp:argument-rest:' tag-order hosts files users
zstyle ':completion:*:(ssh|scp|rdp):*:hosts' hosts
if ! (( P9K_SSH )); then
zstyle ':z4h:sudo' term ''
fi
###
[ ! -f /etc/motd ] || cat /etc/motd
###
z4h install romkatv/archive || return
z4h init || return
####
zstyle ':completion:*' matcher-list "m:{a-z}={A-Z}" "l:|=* r:|=*"
####
fpath+=($Z4H/romkatv/archive)
autoload -Uz archive lsarchive unarchive edit-command-line
zle -N edit-command-line
my-fzf () {
emulate -L zsh -o extended_glob
local MATCH MBEGIN MEND
fzf "${@:/(#m)--query=?*/$MATCH }"
}
my-ctrl-z() {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER="fg"
zle accept-line -w
else
zle push-input -w
zle clear-screen -w
fi
}
zle -N my-ctrl-z
###
z4h bindkey z4h-backward-kill-word Ctrl+Backspace
z4h bindkey z4h-backward-kill-zword Ctrl+Alt+Backspace
z4h bindkey z4h-kill-zword Ctrl+Alt+Delete
z4h bindkey backward-kill-line Ctrl+U
z4h bindkey kill-line Alt+U
z4h bindkey kill-whole-line Alt+I
z4h bindkey z4h-forward-zword Ctrl+Alt+Right
z4h bindkey z4h-backward-zword Ctrl+Alt+Left
z4h bindkey z4h-cd-back Alt+H
z4h bindkey z4h-cd-forward Alt+L
z4h bindkey z4h-cd-up Alt+K
z4h bindkey z4h-fzf-dir-history Alt+J
z4h bindkey my-ctrl-z Ctrl+Z
z4h bindkey edit-command-line Alt+E
z4h bindkey z4h-accept-line Enter
z4h bindkey z4h-exit Ctrl+D
###
setopt GLOB_DOTS
setopt IGNORE_EOF
###
[ -z "$EDITOR" ] && export EDITOR='vim'
[ -z "$VISUAL" ] && export VISUAL='vim'
export DIRENV_LOG_FORMAT=
export FZF_DEFAULT_OPTS="--reverse --multi"
export SYSTEMD_LESS="${LESS}S"
###
z4h source -- $HOME/.dotfiles/lscolors/lscolors.sh
z4h source -- $ZDOTDIR/.zsh-aliases
z4h source -- $ZDOTDIR/.zshrc-private
###
zsh_notify_bg_finish_pre() {
declare -g zsh_notify_bg_finish_cmd="${1:-$2}"
declare -g zsh_notify_bg_finish_start=$EPOCHSECONDS
}
zsh_notify_bg_finish_post() {
local last_status=$?
[ -n "$zsh_notify_bg_finish_start" ] || return 0
(( time_elapsed = EPOCHSECONDS - zsh_notify_bg_finish_start ))
local took=$(zsh_notify_bg_finish_duration "$time_elapsed")
local title="$(((last_status == 0)) && echo 'SUCCESS 🥳' || echo 'FAILURE 🤬')"
! (( P9K_SSH )) || title="$title on $HOST 💻"
title="$title after $took!"
local id=$EPOCHSECONDS
printf '\x1b]99;i=%d:d=0:o=unfocused;%s\x1b\\' "$id" "$title"
printf '\x1b]99;i=%d:d=1:p=body;%s\x1b\\' "$id" "$zsh_notify_bg_finish_cmd"
unset zsh_notify_bg_finish_cmd zsh_notify_bg_finish_start
}
zsh_notify_bg_finish_duration() {
local total_seconds=$1
local hours=$((total_seconds / 3600))
local minutes=$(( (total_seconds % 3600) / 60 ))
local seconds=$((total_seconds % 60))
local result=""
(( hours > 0 )) && result+="${hours}h "
(( minutes > 0 )) && result+="${minutes}m "
(( seconds > 0 || total_seconds == 0 )) && result+="${seconds}s"
echo "${result% }"
}
add-zsh-hook preexec zsh_notify_bg_finish_pre
add-zsh-hook precmd zsh_notify_bg_finish_post