aesophor / py-todo

📋 Lightweight reminder / todo-list in cli
https://www.reddit.com/r/unixporn/comments/9qy35q/oc_pytodo_a_lightweight_reminder_in_cli/
MIT License
107 stars 22 forks source link

Compatibility with fish shell and fish-prompt-metro #34

Closed silviubogan closed 4 years ago

silviubogan commented 4 years ago

I am not sure if the issue is in py-todo or in fish-prompt-metro. Also this is the fish-prompt-metro repo: https://github.com/fishpkg/fish-prompt-metro.

The issue:

~ > todo -a
Title: throw a party
Expiry date (YYYY/MM/DD or <days>d) (Optional): 2
An error occurred while parsing your date.
humanize_duration: nu s-a găsit comanda
~/.config/fish/functions/fish_right_prompt.fish (line 1): 
echo $CMD_DURATION | humanize_duration
                     ^
in command substitution
    called on line 28 of file ~/.config/fish/functions/fish_right_prompt.fish
in function 'fish_right_prompt'
in command substitution
~/.config/fish/functions/fish_right_prompt.fish: Unknown error while evaluating command substitution
in function 'fish_right_prompt'
in command substitution
 ~ >

The contents of ~/.config/fish/functions/fish_right_prompt.fish are:

function fish_right_prompt
    set -l status_copy $status
    set -l status_code $status_copy
    set -l status_color 555
    set -l status_glyph
    set -l duration_glyph

    switch "$status_copy"
        case 0 "$__metro_status_last"
            set status_code
    end

    set -g __metro_status_last $status_copy

    if test "$status_copy" -eq 0
        set duration_glyph " "
    else
        set status_color red
        set status_glyph │
    end

    if test "$CMD_DURATION" -gt 250
        if test ! -z "$status_code"
            echo -sn (set_color $status_color) "($status_code)" (set_color normal)
            set status_glyph ┃
        end

        set -l duration (echo $CMD_DURATION | humanize_duration)
        echo -sn (set_color $status_color) " ($duration) $duration_glyph" (set_color normal)

    else
        if test ! -z "$status_code"
            echo -sn (set_color $status_color) "$status_code " (set_color normal)
            set status_glyph ┃
        end
    end

    echo -sn (set_color $status_color) "$status_glyph" (set_color normal)
end

The output of fisher ls is:

 ~ > fisher ls                                                                                                                        (3s 269ms)  
fishpkg/fish-prompt-metro
franciscolourenco/done
jethrokuan/fzf
jorgebucaran/fish-nvm
joseluisq/gitnow

Thank you.

aesophor commented 4 years ago

Hi there!

I think the issue is caused by the incorrect syntax. Could you please try typing 2d (2 days) instead of 2 in the expiry date field? Without the d character, that string will be treated as YYYY/MM/DD.


Here's what I mean:

silviubogan commented 4 years ago

Hi!

It works with d (although after a restart of the computer).

Now the output for a wrong input is:

 ~ > todo -a
Title: title
Expiry date (YYYY/MM/DD or <days>d) (Optional): 5
An error occurred while parsing your date.

I think that it is more beautiful than the one in the description of the issue.

Thank you!