Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 82/comment default config #87

Merged
merged 6 commits into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
-printcfg shows commented configuration
  • Loading branch information
arl committed Feb 18, 2023
commit 9e30346f22d482f0036d4ad08b91808535951974
81 changes: 81 additions & 0 deletions .gitmux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
tmux:
# The symbols section defines the symbols printed before specific elements
# of Git status displayed in tmux status string.
symbols:
# current branch name.
branch: "⎇ "
# Git SHA1 hash (in 'detached' state).
hashprefix: ":"
# 'ahead count' when local and remote branch diverged.
ahead: ↑·
# 'behind count' when local and remote branch diverged.
behind: ↓·
# count of files in the staging area.
staged: "● "
# count of files in conflicts.
conflict: "✖ "
# count of modified files.
modified: "✚ "
# count of untracked files.
untracked: "… "
# count of stash entries.
stashed: "⚑ "
# count of inserted lines (stats section).
insertions: Σ
# count of deleted lines (stats section).
deletions: Δ
# Shown when the working tree is clean.
clean: ✔

# Styles are tmux format strings used to specify text colors and attributes
# of Git status elements. See the STYLES section of tmux man page.
# https://man7.org/linux/man-pages/man1/tmux.1.html#STYLES.
styles:
# Clear previous style.
clear: "#[fg=default]"
# Special tree state strings such as [rebase], [merge], etc.
state: "#[fg=red,bold]"
# Local branch name
branch: "#[fg=white,bold]"
# Remote branch name
remote: "#[fg=cyan]"
# 'divergence' counts
divergence: "#[fg=yellow]"
# 'staged' count
staged: "#[fg=green,bold]"
# 'conflicts' count
conflict: "#[fg=red,bold]"
# 'modified' count
modified: "#[fg=red,bold]"
# 'untracked' count
untracked: "#[fg=magenta,bold]"
# 'stash' count
stashed: "#[fg=cyan,bold]"
# 'insertions' count
insertions: "#[fg=green]"
# 'deletions' count
deletions: "#[fg=red]"
# 'clean' symbol
clean: "#[fg=green,bold]"

# The layout section defines what components gitmux shows and the order in
# which they appear on tmux status bar.
#
# Allowed components:
# - branch: local branch name. Examples: `⎇ main`, `⎇ :345e7a0` or `[rebase]`
# - remote-branch: remote branch name, for example: `origin/main`.
# - divergence: divergence between local and remote branch, if any. Example: `↓·2↑·1`
# - remote: alias for `remote-branch` followed by `divergence`, for example: `origin/main ↓·2↑·1`
# - flags: symbols representing the working tree state, for example `✚ 1 ⚑ 1 … 2`
# - stats: insertions/deletions (lines), for example`Σ56 Δ21`
# - some string `foo`: any other character of string is directly shown, for example `foo` or `|`
layout: [branch, " ", remote-branch, divergence, " - ", flags]

# Additional configuration options.
options:
# Maximum displayed length for local and remote branch names.
branch_max_len: 0
# Trim left or right end of the branch (`right` or `left`).
branch_trim: right
# Character indicating whether and where a branch was truncated.
ellipsis: …
17 changes: 13 additions & 4 deletions gitmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
_ "embed"
"flag"
"fmt"
"io"
Expand Down Expand Up @@ -33,7 +34,17 @@ Options:
// Config configures output formatting.
type Config struct{ Tmux tmux.Config }

var defaultCfg = Config{Tmux: tmux.DefaultCfg}
// default config (decoded in init)
var defaultCfg Config

//go:embed .gitmux.yml
var cfgBytes []byte

func init() {
if err := yaml.Unmarshal(cfgBytes, &defaultCfg); err != nil {
panic(fmt.Sprintf("default config is invalid: %v", err))
}
}

func parseOptions() (ctx context.Context, cancel func(), dir string, dbg bool, cfg Config) {
var (
Expand All @@ -60,9 +71,7 @@ func parseOptions() (ctx context.Context, cancel func(), dir string, dbg bool, c
}

if *printCfgOpt {
enc := yaml.NewEncoder(os.Stdout)
check(enc.Encode(&defaultCfg), *dbgOpt)
enc.Close()
os.Stdout.Write(cfgBytes)
os.Exit(0)
}

Expand Down