grace/dots

dotfiles/nix configs

git clone https://git.gae.moe/grace/dots

Grace Yoderi have got to be better about these things9c3d491

main
820 B28 linesraw
1function fish_bind_count
2    argparse h/help z/zero r/read -- $argv
3    or return 1
4    if test -n "$_flag_help"
5        echo "Helper function to track count modifier with modal key bindings"
6        echo "Usage: $0 [-h] [-z] [DIGITS ...]"
7        return
8    end
9    if test -n "$_flag_zero" || not string match -rq '[1-9]\d*' "$fish_bind_count"
10        set -g fish_bind_count 0
11    end
12    # Iterate over given digits
13    for arg in $argv
14        for digit in (string split '' "$arg")
15            set -g fish_bind_count $(math "$fish_bind_count" \* 10 \+ "$digit")
16        end
17    end
18    if test -n "$_flag_read"
19        set -l count "$fish_bind_count"
20        set -g fish_bind_count 0
21        if test "$count" = 0
22            echo 1
23            return 1
24        else
25            echo "$count"
26        end
27    end
28end