Created
November 26, 2019 16:06
-
-
Save lisael/84a1d7d1c4f1699662fd55225a122637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare-option str-list quickbufs | |
define-command -override quickbuf %{ | |
eval %sh{ | |
rm /tmp/buflist | |
rm /tmp/buflist_tmp | |
for bufname in $kak_opt_quickbufs $kak_buflist | |
do printf "%s\n" "$bufname" >> /tmp/buflist_tmp | |
done | |
cat /tmp/buflist_tmp | awk '!seen[$0]++' | grep -v "/tmp/buflist" > /tmp/buflist | |
printf "edit /tmp/buflist" | |
rm /tmp/buflist_tmp | |
} | |
} | |
remove-hooks global quickbuf | |
hook -group quickbuf global BufWritePost /tmp/buflist %{ | |
eval %sh{ | |
printf "set global quickbufs\n" | |
loop=0 | |
cat /tmp/buflist | while read line; do | |
printf "set -add global quickbufs %s\n" $line | |
loop=$(( $loop + 1 )) | |
if test $loop -lt 10; then | |
printf "map global normal <a-%s> :edit<space>%s<ret>\n" $loop $line | |
fi | |
done | |
printf "delete-buffer" | |
} | |
} | |
hook -group quickbuf global BufCreate /tmp/buflist %{ | |
map buffer user q :delete-buffer<ret> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment