gitmux

💻 Git in your tmux status bar
授权协议 MIT License
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 张鸿宝
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Gitmux shows git status in your tmux status bar


demo

  • easy. Install and forget about it
  • minimal. Just shows what you need, when you need it
  • discrete. Get out of your way if current directory is not in a Git tree
  • shell-agnostic. Does not rely on shell-features so works with all of them
  • customizable. Colors, symbols and layout are configurable

Prerequisites

Works with all decently recent tmux versions.

Installing

Binary release

Download the latest binary for your platform/architecture and uncompress it.

From source

Download and install a Go compiler (Go 1.10 or later).Run go get to build and install gitmux:

go get -u github.com/arl/gitmux

Getting started

If your tmux version supports pane_current_path (tmux v2.1+),just add this line to your .tmux.conf:

set -g status-right '#(gitmux "#{pane_current_path}")'

If your tmux doesn't support pane_current_path then you can usea bash-specific solutionto achieve relatively similar behaviour: gitmux will refresh after every shell commandyou run or when you switch windows, however it won't refresh automatically, nor when switching panes.

Note that tmux v2.1 was released in 2015 so you're probably better off updating to a more recent version anyway �� .

Customizing

gitmux output can be customized via a configuration file in YAML format.

The gitmux configuration file is in YAML format.

tmux:
  symbols:
    branch: ''
    hashprefix: ':'
    ahead: ↑·
    behind: ↓·
    staged: ''
    conflict: ''
    modified: ''
    untracked: ''
    stashed: ''
    clean: 
  styles:
    clear: '#[fg=default]'
    state: '#[fg=red,bold]'
    branch: '#[fg=white,bold]'
    remote: '#[fg=cyan]'
    staged: '#[fg=green,bold]'
    conflict: '#[fg=red,bold]'
    modified: '#[fg=red,bold]'
    untracked: '#[fg=magenta,bold]'
    stashed: '#[fg=cyan,bold]'
    clean: '#[fg=green,bold]'
    divergence: "#[fg=yellow]"    
  layout: [branch, .., remote, " - ", flags]
  options:
    branch_max_len: 0

First, save the default configuration to a new file:

gitmux -printcfg > .gitmux.conf

Modify the line in .tmux.conf, passing the path of the configuration file as argument to gitmux

gitmux -cfg .gitmux.conf

Open .gitmux.conf and modify it, replacing symbols, styles and layout to suit your needs.

In tmux status bar, gitmux output immediately reflects the changes you make to the configuration.

gitmux configuration is split into 4 sections:

  • symbols: they're just strings of unicode characters
  • styles: tmux format strings
  • layout: list of gitmux layout components, defines the component to show and in their order.
  • options: additional configuration options

Symbols

The symbols section describes the symbols gitmux prints for the various components of the status string.

symbols:
    branch: ''      # Shown before a branch
    hashprefix: ':'    # Shown before a Git hash (in 'detached HEAD' state)
    ahead: ↑·          # Shown before the 'ahead count' when local and remote branch diverge
    behind: ↓·         # Shown before the 'behind count' when local/remote branch diverge
    staged: ''       # Shown before the 'staged' files count
    conflict: ''     # Shown before the 'conflicts' count
    modified: ''     # Shown before the 'modified' files count
    untracked: ''    # Shown before the 'untracked' files count
    stashed: ''      # Shown before the 'stash' count
    clean: ✔           # Shown when the working tree is clean (empty staging area)

Styles

Styles are tmux format strings used to specify text colors and attributes.See tmux styles reference.

styles:
    clear: '#[fg=default]'          # Style clearing previous styles (printed before each component)
    state: '#[fg=red,bold]'         # Style of the special states strings like [rebase], [merge], etc.
    branch: '#[fg=white,bold]'      # Style of the local branch name
    remote: '#[fg=cyan]'            # Style of the remote branch name
    divergence: "#[fg=yellow]"      # Style of the 'divergence' string
    staged: '#[fg=green,bold]'      # Style of the 'staged' files count
    conflict: '#[fg=red,bold]'      # Style of the 'conflicts' count
    modified: '#[fg=red,bold]'      # Style of the 'modified' files count
    untracked: '#[fg=magenta,bold]' # Style of the 'modified' files count
    stashed: '#[fg=cyan,bold]'      # Style of the 'stash' entries count
    clean: '#[fg=green,bold]'       # Style of the 'clean' symbol

Layout components

The layout is a list of the components gitmux shows, and the order inwhich they appear on tmux status bar.

For example, the default gitmux layout shows is:

layout: [branch, .., remote-branch, divergence, " - ", flags]

It shows, in that order:

  • the local branch name,
  • 2 dots characters ..,
  • the remote branch name
  • the local/remote divergence
  • a - character
  • and finally the flags representing the working tree state

Note that elements only appear when they make sense, for example if local andremote branch are aligned, the divergence string won't show up. Same thing forthe remote branch, etc.

But you can anyway choose to never show some components if you wish, or to presentthem in a different order.

This is the list of the possible components of the layout:

Layout component Description Example
branch local branch name main
remote-branch remote branch name origin/main
divergence divergence local/remote branch, if any ↓·2↑·1
remote alias for remote-branch followed by divergence origin/main ↓·2↑·1
flags Symbols representing the working tree state ✚ 1 ⚑ 1 … 2
any string foo Any other string is directly shown foo

Some example layouts:

  • default layout:
layout: [branch, .., remote-branch, divergence, " - ", flags]
  • some more minimal layouts:
layout: [branch, divergence, " - ", flags]
layout: [flags, " ", branch]

Additional options

This is the list of additional configuration options:

Option Description Default
branch_max_len Maximum displayed length for local and remote branch names 0 (no limit)

Troubleshooting

Please report anything by filing an issue.

Contributing

Pull requests are welcome.
For major changes, please open an issue first to open a discussion.

License: MIT

相关阅读

相关文章

相关问答

相关文档