Howdoi - Instant answers from the (kak) command line

Need to install via:
$ pip install howdoi

# <>
declare-option -hidden str howdoicmd 'howdoi -n 5'
# <>
define-command -params .. \
    -docstring %{howdoi [<arguments>]: howdoi --help
    All the optional arguments are forwarded to the howdoi utility
    Instant coding answers via the command line
    <>} \
    howdoi %{ evaluate-commands %sh{
        output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-howdoi.XXXXXXXX)/fifo
        mkfifo ${output}

     if [ $# -gt 0 ]; then
         ( ${kak_opt_howdoicmd} "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
         ( ${kak_opt_howdoicmd} "${kak_selection}" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null

     printf %s\\n "evaluate-commands %{
               edit! -fifo ${output} *howdoi*
               hook -always -once buffer BufCloseFifo .* %{ nop %sh{ rm -r $(dirname ${output}) } }

Defaults to -n 5 answers and terminal does not render colour flag -c
see for system settings/usage.

:howdoi format date bash
★  Answer from ★
# put current date as yyyy-mm-dd in $date
# -1 -> explicit current date, bash >=4.3 defaults to current time if not provided
# -2 -> start time for shell
printf -v date '%(%Y-%m-%d)T\n' -1 

# put current date as yyyy-mm-dd HH:MM:SS in $date
printf -v date '%(%Y-%m-%d %H:%M:%S)T\n' -1 

# to print directly remove -v flag, as such:
printf '%(%Y-%m-%d)T\n' -1
# -> current date printed to terminal

Cool guys enjoy your week. Bye.

Nice! It reminds me of tldr.kak made by ironzorg

Yeah tldr :white_check_mark: and a short term hope but a long term plan is implementation like explain-shell.kak spit screen and the ability to append to buffer. All requests are cached by howdoi so maybe, maybe not save temp file, probably not, but maybe save search pattern to perfect a search string.

If anyone knows the author ath3 give him a tap on the shoulder point him over here and say: “mate it’s amateur hour, time to crack the knuckles and show this bloke how its done”.

Or anyone else who just wants to give me sh#t and turn this into a kakoune plugin or feature like man.kak for :trophy: time.

Cool cool bye.

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_filetype}/%sh{echo $@ | tr ' ' '+'}<ret>"

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

+ execute-keys "!curl{cheat_filetype}/%sh{echo $@ | tr ' ' '+'}/T<ret>"
- execute-keys "!curl{cheat_filetype}/%sh{echo $@ | tr ' ' '+'}<ret>"
- ansi-render
1 Like

Night before xmas @TeddyDD and @eraserhd have just put santa out of business. Run rudolf run, there coming for you!!

Great gift, thanks guys.