-
Notifications
You must be signed in to change notification settings - Fork 8
/
kks-buffers
executable file
·23 lines (20 loc) · 744 Bytes
/
kks-buffers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
#
# pick buffers
#
# requires:
# - fzf (https://github.com/junegunn/fzf)
# - bat (change to your liking) (https://github.com/sharkdp/bat)
preview_cmd="bat --color=always --line-range=:500"
history_file="$HOME/.cache/kks-buffers-history"
[ -f "$history_file" ] || touch "$history_file"
kks get '%val{buflist}' |
grep -F "$*" |
fzf --height 100% --prompt 'buf> ' --preview "kks cat -b {} | $preview_cmd" \
--header="[c-x] delete, [c-t] new scratch" \
--bind="ctrl-x:execute-silent(kks send -b {} delete-buffer)+reload(kks get '%val{buflist}')" \
--bind="ctrl-t:execute-silent(kks send edit -scratch {q})+reload(kks get '%val{buflist}')" \
--history="$history_file" |
while read -r name; do
kks send buffer "$name"
done