Skip to content

guuszz/gh-streak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”₯ gh-streak

GitHub contribution streak no terminal.
Ano inteiro de commits em ASCII colorido, sem sair do shell.

CI MIT License Latest release


✨ Preview

@guuszz Β· Gustavo Oliveira
May 27, 2025 β€” May 27, 2026 Β· 1,247 contributions

         Jan       Fev   Mar       Abr   Mai       Jun
     β–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆ
Seg  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ
Qua  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
     β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Sex  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
     β–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ

Less β–‘β–‘β–’β–’β–“β–“β–ˆβ–ˆ More

Current streak: 12 days πŸ”₯
Longest streak: 42 days (Mar 14 β†’ Apr 24, 2026)
Active days:    287 / 365 (79%)

Cores reais no teu terminal β€” paleta GitHub (5 nΓ­veis de verde).


πŸ’‘ Por que existe

GitHub mostra o teu heatmap no perfil web. Mas quando vocΓͺ tΓ‘ no terminal codando, ver progresso requer abrir browser, esperar carregar, scrollar. gh-streak traz isso pra dentro do shell β€” ΓΊtil pra:

  • βœ… Adicionar no teu prompt do shell (PROMPT_COMMAND) β€” vΓͺ streak antes de cada comando
  • βœ… PΓ΄r no MOTD de uma VPS β€” motiva self-hosters
  • βœ… Compartilhar em screenshots de termo (asciinema, freeze)
  • βœ… Usar em scripts (gh-streak --json | jq .streak.current)

πŸ“¦ InstalaΓ§Γ£o

Via Go (recomendado)

go install github.com/guuszz/gh-streak@latest

Garanta que $GOPATH/bin estΓ‘ no $PATH.

Via binary release

Baixe do latest release o arquivo pra teu OS/arch:

# macOS arm64
curl -L https://github.com/guuszz/gh-streak/releases/latest/download/gh-streak_Darwin_arm64.tar.gz | tar xz
sudo mv gh-streak /usr/local/bin/

# Linux x86_64
curl -L https://github.com/guuszz/gh-streak/releases/latest/download/gh-streak_Linux_x86_64.tar.gz | tar xz
sudo mv gh-streak /usr/local/bin/

Via Homebrew (planejado)

brew install guuszz/tap/gh-streak  # em breve

πŸš€ Uso

# Tua prΓ³pria conta (auto-detecta via gh CLI ou git config)
gh-streak

# Outro usuΓ‘rio
gh-streak torvalds

# Ano especΓ­fico
gh-streak --year 2024 guuszz

# Sem cores (pra piping)
gh-streak --no-color | tee streak.txt

# JSON pra script
gh-streak --json | jq '.streak.current'

πŸ”‘ Token

gh-streak precisa de um token do GitHub pra ler o contribution calendar (a REST API nΓ£o expΓ΅e β€” sΓ³ GraphQL). Tenta as fontes nesta ordem:

  1. GH_TOKEN env var
  2. GITHUB_TOKEN env var
  3. gh auth token (se GitHub CLI tiver autenticado)

Scope mΓ­nimo: read:user. Crie um aqui.

πŸ›  Como funciona

A query GraphQL

O REST API do GitHub nΓ£o expΓ΅e o contribution graph. SΓ³ o GraphQL via contributionsCollection.contributionCalendar:

query($login: String!, $from: DateTime!, $to: DateTime!) {
  user(login: $login) {
    contributionsCollection(from: $from, to: $to) {
      contributionCalendar {
        totalContributions
        weeks {
          contributionDays {
            contributionCount
            date
            contributionLevel
          }
        }
      }
    }
  }
}

O contributionLevel Γ© um enum (NONE, FIRST_QUARTILE, ..., FOURTH_QUARTILE) que o GitHub jΓ‘ calculou β€” mapeamos pra 0..4 e usamos como Γ­ndice na paleta de cores.

CΓ‘lculo do streak

Current streak conta de hoje pra trΓ‘s, parando no primeiro dia com 0 contributions. TolerΓ’ncia: se hoje ainda tΓ‘ vazio, nΓ£o quebra (mesma regra do perfil do GitHub).

Longest streak Γ© um single pass O(n) pelo array de days, mantendo o run atual e o max.

Render

Usa lipgloss pra cores true-color (com fallback ANSI 256 automΓ‘tico). Cada dia vira 2 chars (β–ˆβ–ˆ) pra dar aparΓͺncia de "quadrado" em fontes monoespaΓ§adas.

Layout: 7 linhas (dias da semana, Domβ†’SΓ‘b) Γ— ~53 colunas (semanas). Labels Seg/Qua/Sex Γ  esquerda, mΓͺs no rodapΓ©.

πŸ“ Estrutura

gh-streak/
β”œβ”€β”€ main.go      # Flag parsing, CLI orchestration, JSON output
β”œβ”€β”€ github.go    # GraphQL client + token discovery
β”œβ”€β”€ streak.go    # Streak calc (current + longest)
β”œβ”€β”€ render.go    # Heatmap + stats + colors (lipgloss)
β”œβ”€β”€ go.mod
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ workflows/ci.yml         # build + vet em cada push
β”‚   └── workflows/release.yml    # GoReleaser em cada tag
└── .goreleaser.yaml             # binaries Linux/macOS/Windows

πŸ€” Por que Go (e nΓ£o outra linguagem)

  • Single binary β€” go build gera 1 arquivo executΓ‘vel sem runtime
  • Cross-compile trivial β€” GOOS=darwin GOARCH=arm64 go build from any machine
  • stdlib generoso β€” net/http, encoding/json, time, flag cobrem 90% do escopo
  • Startup instantΓ’neo β€” CLIs Node leva 100ms+ pra inicializar V8. Go = 10ms.
  • Match com gh CLI ecosystem β€” o prΓ³prio GitHub CLI Γ© Go

πŸ—Ί Roadmap

  • Current + longest streak
  • ASCII heatmap colorido (5 nΓ­veis)
  • JSON output pra scripts
  • Token discovery (env + gh CLI)
  • gh-streak compare <user1> <user2> β€” lado a lado
  • gh-streak --shell-prompt β€” modo "1 linha" pra PS1
  • Cache local (1h TTL) β€” evita hammer na API
  • Homebrew tap
  • gh CLI extension (gh extension install guuszz/gh-streak)

🀝 Contribuindo

PRs welcome! LΓͺ o CONTRIBUTING.md e abre issue antes de feature grande.

πŸ“ LicenΓ§a

MIT Β© Gustavo Oliveira

About

πŸ”₯ GitHub contribution streak no terminal β€” heatmap ASCII colorido com paleta GitHub. CLI Go single-binary.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages