Skip to content

Commit

Permalink
Add support to show current date and time
Browse files Browse the repository at this point in the history
Fixes #238
  • Loading branch information
flybyray committed Jul 23, 2021
1 parent bedd965 commit 7366233
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type arguments struct {
Eval *bool
Condensed *bool
IgnoreWarnings *bool
Time *string
}

var args = arguments{
Expand Down Expand Up @@ -188,6 +189,10 @@ var args = arguments{
"duration",
defaults.Duration,
comments("The elapsed clock-time of the previous command")),
Time: flag.String(
"time",
defaults.Time,
comments("The elapsed clock-time of the previous command")),
DurationMin: flag.String(
"duration-min",
defaults.DurationMin,
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Config struct {
Modes SymbolMap `json:"modes"`
Shells ShellMap `json:"shells"`
Themes ThemeMap `json:"themes"`
Time string `json:"-"`
}

func (mode *SymbolTemplate) UnmarshalJSON(data []byte) error {
Expand Down
1 change: 1 addition & 0 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,7 @@ var defaults = Config{
NixShellBg: gruvbox_faded_purple,
},
},
Time: "15:04:05",
}

const (
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ func main() {
cfg.Condensed = *args.Condensed
case "ignore-warnings":
cfg.IgnoreWarnings = *args.IgnoreWarnings
case "time":
cfg.Time = *args.Time
}
})

Expand Down
3 changes: 2 additions & 1 deletion segment-time.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package main

import (
"strings"
pwl "github.com/justjanne/powerline-go/powerline"
"time"
)

func segmentTime(p *powerline) []pwl.Segment {
return []pwl.Segment{{
Name: "time",
Content: time.Now().Format("15:04:05"),
Content: time.Now().Format(strings.TrimSpace(p.cfg.Time)),
Foreground: p.theme.TimeFg,
Background: p.theme.TimeBg,
}}
Expand Down

0 comments on commit 7366233

Please sign in to comment.