Howdoi - Instant answers from the (kak) command line

http://cheat.sh/

declare-option -hidden str cheat_filetype
define-command -params 1.. cheat %{
    set-option global cheat_filetype %opt{filetype}
    try %{ delete-buffer! *cheat* }
    edit -scratch *cheat*
    execute-keys "!curl cheat.sh/%opt{cheat_filetype}/%sh{echo $@ | tr ' ' '+'}<ret>"
    ansi-render
}

Needs kak-ansi plugin, if you don’t want to use it you can change curl query to

+ execute-keys "!curl cheat.sh/%opt{cheat_filetype}/%sh{echo $@ | tr ' ' '+'}/T<ret>"
- execute-keys "!curl cheat.sh/%opt{cheat_filetype}/%sh{echo $@ | tr ' ' '+'}<ret>"
- ansi-render
3 Likes