Skip to content

Commit 7041748

Browse files
Change tmux-color to take custom colors
1 parent c40c0bd commit 7041748

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* [Take a break](#take-a-break)
1616
* [Repeat the last Pomodoro](#repeat-the-last-pomodoro)
1717
* [Show Pomodoro history](#show-pomodoro-history)
18+
* [Tmux Color](#tmux-color)
1819
* [Status Format](#status-format)
1920
* [Available Parts](#available-parts)
2021
* [Hooks](#hooks)
@@ -183,6 +184,34 @@ $ pomodoro history --output json
183184
$ pomodoro history --output ical > ~/Pomodoros.ics
184185
```
185186

187+
### Tmux Color
188+
189+
`tmux-color` returns a color for the current Pomodoro status.
190+
191+
```
192+
# Active Pomodoro
193+
$ pomodoro tmux-color
194+
colour2 # Green
195+
196+
# Finished Pomodoro
197+
$ pomodoro tmux-color
198+
colour1 # Red
199+
```
200+
201+
Nothing is output if no Pomodoro is active.
202+
203+
You can also define custom colors:
204+
205+
```
206+
# Active Pomodoro
207+
$ pomodoro tmux-color --active colour166 --done colour165
208+
colour166 # Orange
209+
210+
# Finished Pomodoro
211+
$ pomodoro tmux-color --active colour166 --done colour165
212+
colour165 # Purple
213+
```
214+
186215
## Status Format
187216

188217
All commands which display the status of a single Pomodoro can take an additional `--format` / `-f` argument.

cmd/tmux_color.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,27 @@ import (
66
"github.com/spf13/cobra"
77
)
88

9-
const (
10-
tmuxRed = "colour1"
11-
tmuxGreen = "colour2"
9+
var (
10+
activeFlag string
11+
doneFlag string
1212
)
1313

1414
func init() {
15-
RootCmd.AddCommand(&cobra.Command{
15+
command := &cobra.Command{
1616
Use: "tmux-color",
1717
Short: "Return a tmux color string for the status.",
1818
RunE: tmuxColorCmd,
19-
})
19+
}
20+
21+
command.Flags().StringVarP(
22+
&activeFlag, "active", "a", "colour2",
23+
"color when a Pomodoro is active")
24+
25+
command.Flags().StringVarP(
26+
&doneFlag, "done", "d", "colour1",
27+
"color when a Pomodoro is done")
28+
29+
RootCmd.AddCommand(command)
2030
}
2131

2232
func tmuxColorCmd(cmd *cobra.Command, args []string) error {
@@ -26,11 +36,11 @@ func tmuxColorCmd(cmd *cobra.Command, args []string) error {
2636
}
2737

2838
if s.Pomodoro.IsActive() {
29-
fmt.Printf(tmuxGreen)
39+
fmt.Printf(activeFlag)
3040
}
3141

3242
if s.Pomodoro.IsDone() {
33-
fmt.Printf(tmuxRed)
43+
fmt.Printf(doneFlag)
3444
}
3545

3646
return nil

0 commit comments

Comments
 (0)