~ane/public-inbox

1

btdt for ZSH

Details
Message ID
<CALAJNrhrGGdAZKJXJQFZwAuLPHsYcUA2T-rVm_MxPfYn_nBWiQ@mail.gmail.com>
DKIM signature
missing
Download raw message
I like your idea of command bookmarking. And your execution is simple
and effective. I had to make some small changes to `bt` to make it
work on my ZSH. Here is the modified function:
```
bt() {
    if [[ -z "$1" ]]; then
        CMD="$(history -10 | fzf --header="Choose a command to save"
--no-sort --tac | cut -d' ' -f 4-)"
    else
        CMD=$1
    fi

    [[ -z "$CMD" ]] && echo "Aborted" && return 2
    echo "Saving \"${CMD}\"..."
    read "NAME?Name of command: "
    [[ -z "$NAME" ]] && echo "No name given, aborting" && return 1
    read "LONG?Longer description (optional): "

    if [[ ! -d "${HOME}/.config/btdt" ]]; then
        mkdir -p "${HOME}/.config/btdt"
    fi

    DATA="${BTDT_DATA:-${HOME}/.config/btdt/data}"

    if [[ ! -f $DATA ]]; then
        touch $DATA
    fi

    result="${CMD}\t${NAME}\t${LONG}\n"
    printf "$result" >> $DATA
}
```
However, I am working on an implementation with ZSH widgets, which
will let me add a few additional features I want.

--
Anamitra Saha
Details
Message ID
<lyo7ykj5gn.fsf@iki.fi>
In-Reply-To
<CALAJNrhrGGdAZKJXJQFZwAuLPHsYcUA2T-rVm_MxPfYn_nBWiQ@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
Anamitra Saha <anamitra.saha21@gmail.com> writes:

> However, I am working on an implementation with ZSH widgets, which
> will let me add a few additional features I want.
>

Hi Anamitra, thank you for your suggestions and interest!

I have set up a repository for btdt here: https://git.sr.ht/~ane/btdt

If you don't mind, I'd like to add your version for zsh as
btdt.zsh. Would you like to submit adding the file as a patch for
btdt.git? If not, I can do that for you. (I will mark the file to be
under your copyright.)

-- 
Antoine Kalmbach
Reply to thread Export thread (mbox)