-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc
161 lines (129 loc) · 4.19 KB
/
dot_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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Do you want red dots to be displayed while waiting for completion?
COMPLETION_WAITING_DOTS="true"
# Git auto-fetch
GIT_AUTO_FETCH_INTERVAL=600
# Starship config
export STARSHIP_CONFIG=$HOME/.config/starship/config.toml
# Load Antidote
source $HOME/.antidote/antidote.zsh
antidote load
# Docker completion
zstyle ':completion:*:*:docker:*' option-stacking yes
zstyle ':completion:*:*:docker-*:*' option-stacking yes
# FZF theme
export FZF_DEFAULT_OPTS=" \
--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8 \
--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc \
--color=marker:#b4befe,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8 \
--color=selected-bg:#45475a \
--multi"
# Aliases
source ~/.aliases.zsh
# Editor
export EDITOR=nvim
if [[ "$OSTYPE" == "darwin"* ]]; then
# Vistual editor
export VISUAL=subl
# Enable 1Password
source $HOME/.config/op/plugins.sh
# OrbStack
source ~/.orbstack/shell/init.zsh 2>/dev/null || :
# Path
## Local bin
PATH=$HOME/.local/bin:$PATH
## Curl
PATH=/opt/homebrew/opt/curl/bin:$PATH
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
fi
# Atuin configuration
autoload -U add-zsh-hook
zmodload zsh/datetime 2>/dev/null
# If zsh-autosuggestions is installed, configure it to use Atuin's search. If
# you'd like to override this, then add your config after the $(atuin init zsh)
# in your .zshrc
_zsh_autosuggest_strategy_atuin() {
suggestion=$(ATUIN_QUERY="$1" atuin search --cmd-only --limit 1 --search-mode prefix)
}
if [ -n "${ZSH_AUTOSUGGEST_STRATEGY:-}" ]; then
ZSH_AUTOSUGGEST_STRATEGY=("atuin" "${ZSH_AUTOSUGGEST_STRATEGY[@]}")
else
ZSH_AUTOSUGGEST_STRATEGY=("atuin")
fi
export ATUIN_SESSION=$(atuin uuid)
ATUIN_HISTORY_ID=""
_atuin_preexec() {
local id
id=$(atuin history start -- "$1")
export ATUIN_HISTORY_ID="$id"
__atuin_preexec_time=${EPOCHREALTIME-}
}
_atuin_precmd() {
local EXIT="$?" __atuin_precmd_time=${EPOCHREALTIME-}
[[ -z "${ATUIN_HISTORY_ID:-}" ]] && return
local duration=""
if [[ -n $__atuin_preexec_time && -n $__atuin_precmd_time ]]; then
printf -v duration %.0f $(((__atuin_precmd_time - __atuin_preexec_time) * 1000000000))
fi
(ATUIN_LOG=error atuin history end --exit $EXIT ${duration:+--duration=$duration} -- $ATUIN_HISTORY_ID &) >/dev/null 2>&1
export ATUIN_HISTORY_ID=""
}
_atuin_search() {
emulate -L zsh
zle -I
# swap stderr and stdout, so that the tui stuff works
# TODO: not this
local output
# shellcheck disable=SC2048
output=$(ATUIN_SHELL_ZSH=t ATUIN_LOG=error ATUIN_QUERY=$BUFFER atuin search $* -i 3>&1 1>&2 2>&3)
zle reset-prompt
if [[ -n $output ]]; then
RBUFFER=""
LBUFFER=$output
if [[ $LBUFFER == __atuin_accept__:* ]]
then
LBUFFER=${LBUFFER#__atuin_accept__:}
zle accept-line
fi
fi
}
_atuin_search_vicmd() {
_atuin_search --keymap-mode=vim-normal
}
_atuin_search_viins() {
_atuin_search --keymap-mode=vim-insert
}
_atuin_up_search() {
# Only trigger if the buffer is a single line
if [[ ! $BUFFER == *$'\n'* ]]; then
_atuin_search --shell-up-key-binding "$@"
else
zle up-line
fi
}
_atuin_up_search_vicmd() {
_atuin_up_search --keymap-mode=vim-normal
}
_atuin_up_search_viins() {
_atuin_up_search --keymap-mode=vim-insert
}
add-zsh-hook preexec _atuin_preexec
add-zsh-hook precmd _atuin_precmd
zle -N atuin-search _atuin_search
zle -N atuin-search-vicmd _atuin_search_vicmd
zle -N atuin-search-viins _atuin_search_viins
zle -N atuin-up-search _atuin_up_search
zle -N atuin-up-search-vicmd _atuin_up_search_vicmd
zle -N atuin-up-search-viins _atuin_up_search_viins
# These are compatibility widget names for "atuin <= 17.2.1" users.
zle -N _atuin_search_widget _atuin_search
zle -N _atuin_up_search_widget _atuin_up_search
bindkey -M emacs '^r' atuin-search
bindkey -M viins '^r' atuin-search-viins
bindkey -M vicmd '/' atuin-search
bindkey -M emacs '^[[A' atuin-up-search
bindkey -M vicmd '^[[A' atuin-up-search-vicmd
bindkey -M viins '^[[A' atuin-up-search-viins
bindkey -M emacs '^[OA' atuin-up-search
bindkey -M vicmd '^[OA' atuin-up-search-vicmd
bindkey -M viins '^[OA' atuin-up-search-viins
bindkey -M vicmd 'k' atuin-up-search-vicmd