-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqish.zshrc
33 lines (33 loc) · 910 Bytes
/
sqish.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
SQISH_ID="$(hostname)_$(date +%s)_$(shuf -i 1-100 -n 1)"
SQISH=sqish
# Add to history.
function sqish-add () { nohup $SQISH --shell_session_id $SQISH_ID add "$1" >& /dev/null }
autoload add-zsh-hook
add-zsh-hook zshaddhistory sqish-add
# Search history.
function sqish-search () {
fullscreen=$1
t=$(mktemp)
if [[ fullscreen -eq 1 ]]; then
cmd="search"
else
cmd="inline"
fi
if [[ $BUFFER != "" ]]; then
$SQISH --shell_session_id $SQISH_ID $cmd --query $BUFFER 2> $t
else
$SQISH --shell_session_id $SQISH_ID $cmd 2> $t
fi
cmd=$(cat $t)
LBUFFER+="$cmd"
}
function sqish-search-fullscreen () {
sqish-search 1
}
function sqish-search-inline () {
sqish-search 0
}
zle -N sqish-search-fullscreen
bindkey '^z' sqish-search-fullscreen
zle -N sqish-search-inline
bindkey '^i' sqish-search-inline