tmux icon indicating copy to clipboard operation
tmux copied to clipboard

Added new options to use arbitrary time format.

Open ucchiee opened this issue 2 years ago • 11 comments

Added new options because I wanted to use my original time format.

  • dracula-arbitrary-time-format : true/false, default to false
  • dracula-time-format : time format, default to "%Y-%m-%d(%a) %H:%M"

Where should I write readme??

ucchiee avatar Sep 18 '21 13:09 ucchiee

Hmm, why are you using an if inside a case? Seems odd. EDIT: Nevermind, makes sense, didn't look closely enough.

ethancedwards8 avatar Oct 09 '21 22:10 ethancedwards8

Where should I write readme??

What do you mean?

ethancedwards8 avatar Oct 14 '21 18:10 ethancedwards8

So this is a good idea, but instead of creating two options here, could we just check if dracula-time-format is empty or not and go from there?

ethancedwards8 avatar Oct 14 '21 18:10 ethancedwards8

Where should I write readme??

What do you mean?

I think I need to add some description about this new option, but couldn't find out where to write.

could we just check if dracula-time-format is empty or not and go from there?

You are right. So, how about this one ? (deleted the dracula-arbitrary-time-format option)

    if [ $plugin = "time" ]; then
      IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-time-colors" "dark_purple white")
      if [ -n "$time_format" ]; then
        script=${time_format}
      else
        if $show_day_month && $show_military ; then # military time and dd/mm
          script="%a %d/%m %R ${timezone} "
        elif $show_military; then # only military time
          script="%a %m/%d %R ${timezone} "
        elif $show_day_month; then # only dd/mm
          script="%a %d/%m %I:%M %p ${timezone} "
        else
          script="%a %m/%d %I:%M %p ${timezone} "
        fi
      fi
    fi

ucchiee avatar Oct 15 '21 15:10 ucchiee

I confirmed that the code above works.

Btw, the time related options are hard to configure and adding this new option would make them unnecessary. (but deleting them would break backward compatibility...) What do you think about this?

ucchiee avatar Oct 15 '21 16:10 ucchiee

Does the code work with time zones? Not sure if you can add it with the % syntax, or if you need to add the ${timezone} variable.

ethancedwards8 avatar Oct 15 '21 18:10 ethancedwards8

Also, for backwards compatibility, let's keep the existing options at least for the time being. Maybe in the future they can be removed.

If you could squash all your commits into one that would be useful. Also updating your PR title.

ethancedwards8 avatar Oct 15 '21 18:10 ethancedwards8

Yes, you need to document the options in INSTALL.md. A baby should be able to follow them ;)

ethancedwards8 avatar Oct 15 '21 18:10 ethancedwards8

Does the code work with time zones?

Yes, you can add timezones like this:

set -g @dracula-time-format "%Y-%m-%d(%a) %H:%M:%S #(date +%Z)"

Should I change to respect the @dracula-show-timezone option? I think it might make this option a little bit complicated.

Also, for backwards compatibility, let's keep the existing options at least for the time being. Maybe in the future they can be removed.

Understood.

ucchiee avatar Oct 16 '21 05:10 ucchiee

Should I change to respect the @dracula-show-timezone option? I think it might make this option a little bit complicated.

IMO, yes.

ethancedwards8 avatar Oct 23 '21 16:10 ethancedwards8

Hi, will this PR be merged in the future?

NitroCao avatar May 10 '22 16:05 NitroCao