-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (41 loc) · 1.21 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"os"
"github.com/mrusme/shell-time/history"
"github.com/mrusme/shell-time/stats"
)
func main() {
// TODO: Filepath
histfile := os.Getenv("HISTFILE")
if histfile == "" {
histfile = os.Getenv("HOME") "/.zsh_history"
}
hist, err := history.New("zsh", histfile)
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
}
s, err := stats.LoadStats(hist)
fmt.Println()
fmt.Println("=== YOUR TOP 10 COMMANDS ===")
topCommands := s.TopCommands(10)
for i := 0; i < len(topCommands); i {
fmt.Printf("-. %s (%d times)\n", (i 1), topCommands[i].Command, topCommands[i].Count)
}
fmt.Println()
fmt.Println("=== LONG FORGOTTEN COMMANDS ===")
luCommands := s.LeastUsedCommands(10)
for i := 0; i < len(luCommands); i {
fmt.Printf("-. %s\n", (i 1), luCommands[i].Command)
}
fmt.Println()
fmt.Println("=== MOST PRODUCTIVE HOURS ===")
topHours := s.TopHours(5)
for i := 0; i < len(topHours); i {
fmt.Printf("-. -:00 (%d commands fired)\n", (i 1), topHours[i].Hour, topHours[i].Count)
}
fmt.Println()
// fmt.Printf("%v\n\n", s.MinutesPerDay)
fmt.Printf("On average you ran commands on the shell for about %d minutes per day.\n\n", s.AverageMinutesPerDay)
}