ytfzf icon indicating copy to clipboard operation
ytfzf copied to clipboard

[Feature request]: Requests history

Open timsofteng opened this issue 3 years ago • 1 comments

Background

[ x] I have checked ytfzf(1) and ytfzf(5) or the wiki before creating this.

Problem

I want to have requests history.

Feature

Main point is to have requests history in shell promt before fzf is on screen.

> ytfzf
Search
>

It would be cool to have ability to press ctrl-r like in bash to have history of requests with fzf-history widget.

timsofteng avatar Aug 09 '22 15:08 timsofteng

You can use the -q option to see the search history, however this is not exactly the same as what you are proposing.

You can add the below to ~/.config/ytfzf/conf.sh, and you'll be able to press the up/down arrow keys to cycle through history, you'll also be able to use ctrl-r

search_prompt_menu () {
    [ -z "$cache_dir" ] && cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/ytfzf"
    HISTFILE="$cache_dir/bash_search_hist"
    printf "Search\n"
    history -r
    read -p "> " -er _search
    #uncomment the line below to enable history expansion
    #_search="$(history -p "$_search")"
    history -s "$_search"
    history -a
    printf "\033[1A\033[K\r%s\n" "> $_search" > /dev/stderr
}

If you want you can also uncomment the line before history -s "$_search" to be able to do things like !! to mean the last search.

Edit: Forgot to mention that /bin/sh has to point to bash for this to work

Euro20179 avatar Aug 09 '22 15:08 Euro20179

As of version 2.5.0 you can copy the bsm addon to ~/.config/ytfzf/extension then add load_extension bsm to conf.sh, and you will get this feature.

Euro20179 avatar Sep 19 '22 02:09 Euro20179