# Author:       Li Junhao       l@x-cmd.com
# shellcheck    shell=sh        disable=SC2039,SC1090,SC3043,SC2263

# license:      AGPLv3

xrc:mod:lib     termux   main

___x_cmd_termux(){
    ___x_cmd_termux___main "$@"
}

___x_cmd_termux___tsvlabel(){
    local line
    read -r line
    ___x_cmd_cmds awk '
        BEGIN{
            FS = "\t"
        }
        {
            print NR "\t" $0
        }
    '
}

___x_cmd_termux___fzfpretty(){
    command awk '{ gsub(/\\n/, "  ", $0); print }'
}

___x_cmd_termux___fzf(){
    ___x_cmd jq --preparecmd
    FZF_DEFAULT_OPTS="
--ansi
--reverse
--height='80%'
--bind='ctrl-w:toggle-preview-wrap'
--bind='ctrl-r:change-preview-window(right,70%|down,40%,99%,border-horizontal|hidden|right)'
"   ___x_cmd fzf "$@"
}

xrc setmain ___x_cmd_termux
