-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.zshrc
executable file
·94 lines (78 loc) · 2.8 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
# ZSH Profiling
#zmodload zsh/zprof
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block, everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# More history,
# See: https://github.com/bamos/zsh-history-analysis/blob/master/README.md#increasing-the-history-file-size
export HISTSIZE=1000000000
export SAVEHIST=$HISTSIZE
setopt EXTENDED_HISTORY
# Preventing command with leading space being store in history,
# used for sensitive command.
setopt HIST_IGNORE_SPACE
setopt auto_cd
# Vim emulation.
bindkey -v
# All export's.
# It includes $PATH so that we source it before `.local.zsh`.
source "$HOME/.exports.zsh"
# Create `local.zsh` if it doesn't exist.
if [ ! -f "$HOME/.local.zsh" ]; then
cp $HOME/.local.example.zsh $HOME/.local.zsh
fi
# Any other customizations only available to local.
source "$HOME/.local.zsh"
# Zinit comfig.
source "$HOME/.zinit.zsh"
# All self-defined functions.
source "$HOME/.functions.zsh"
# All self-defined aliases.
source "$HOME/.aliases.zsh"
# https://github.com/larkery/zsh-histdb
_zsh_autosuggest_strategy_histdb_top_here() {
emulate -L zsh
(( $+functions[_histdb_query] && $+builtins[zsqlite_exec] )) || return
_histdb_init
local last_cmd="$(sql_escape ${history[$((HISTCMD-1))]})"
local cmd="$(sql_escape $1)"
local pwd="$(sql_escape $PWD)"
local reply=$(zsqlite_exec _HISTDB "
SELECT argv FROM (SELECT * FROM (
SELECT c1.argv, p1.dir, h1.session, h1.start_time, 1 AS priority
FROM history h1, history h2
LEFT JOIN commands c1 ON h1.command_id = c1.ROWID
LEFT JOIN commands c2 ON h2.command_id = c2.ROWID
LEFT JOIN places p1 ON h1.place_id = p1.ROWID
WHERE h1.ROWID = h2.ROWID + 1
AND c1.argv LIKE '$cmd%'
AND c2.argv = '$last_cmd'
) UNION SELECT * FROM (
SELECT c1.argv, p1.dir, h1.session, h1.start_time, 0 AS priority
FROM history h1
LEFT JOIN commands c1 ON h1.command_id = c1.ROWID
LEFT JOIN places p1 ON h1.place_id = p1.ROWID
WHERE c1.argv LIKE '$cmd%'
))
ORDER BY dir != '$pwd', priority DESC, session != $HISTDB_SESSION, start_time DESC
LIMIT 1
")
typeset -g suggestion=$reply
}
# support atuin
_zsh_autosuggest_strategy_atuin_search() {
emulate -L zsh
# (( $+functions[_atuin_search] )) || return
local reply=$(/home/fky/.cargo/bin/atuin search --cmd-only --search-mode prefix $1 | tail -n 1)
typeset -g suggestion=$reply
}
# ZSH_AUTOSUGGEST_STRATEGY=(histdb_top_here match_prev_cmd completion)
# ZSH_AUTOSUGGEST_STRATEGY=(atuin_search)
# p10k
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# ZSH Profiling
#zprof
# eval "$(atuin init zsh)"