Skip to content

Commit

Permalink
Add tmux-color subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
justincampbell committed May 31, 2019
1 parent 8fcc7a9 commit f9a4f7d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cmd/tmux_color.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

const (
tmuxRed = "colour1"
tmuxGreen = "colour2"
)

func init() {
RootCmd.AddCommand(&cobra.Command{
Use: "tmux-color",
Short: "Return a tmux color string for the status.",
RunE: tmuxColorCmd,
})
}

func tmuxColorCmd(cmd *cobra.Command, args []string) error {
s, err := client.CurrentState()
if err != nil {
return err
}

if s.Pomodoro.IsActive() {
fmt.Printf(tmuxGreen)
}

if s.Pomodoro.IsDone() {
fmt.Printf(tmuxRed)
}

return nil
}

0 comments on commit f9a4f7d

Please sign in to comment.