Git Reference ยท Plumbing Commands
git column command
Reference for git column: arrange lines from standard input in columns or rows with --mode, --width, --padding, --indent and --nl, as Git does for branch lists.
git column takes a list of lines on standard input and prints them as a table: several short items side by side instead of one long vertical list. Git uses the same layout code for git branch, git tag, git status and git clean when column.ui is turned on. The command exposes that code for your own scripts.
Each input line is one cell. The command chooses the number of columns to fit the width you give it (or the terminal width), pads the cells so they line up, and prints the result.
git column --mode=column --width=60 < items.txt git branch --format='%(refname:short)' | git column --mode=row
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git column [--command=<name>] [--[raw-]mode=<mode>] [--width=<width>] [--indent=<string>] [--nl=<string>] [--padding=<n>]
| Name | Description |
|---|---|
--mode=<mode> |
Layout settings, comma-separated. One of column, row, plain; plus optionally always, never or auto, and dense or nodense. |
--raw-mode=<n> |
Layout as the numeric flag value used internally. Intended for programs that call git column. |
--command=<name> |
Read the layout from column.<name> in the configuration (for example branch), which falls back to column.ui. |
--width=<n> |
Total width available. Defaults to the terminal width, or 80 if that is unknown. |
--indent=<string> |
Text printed before every line. |
--nl=<string> |
Text printed at the end of every line. The default is a newline. |
--padding=<n> |
Spaces between columns. The default is 1. |
Modes: column fills each column top to bottom before moving right (like ls). row fills across first. plain prints one item per line and ignores the width. dense lets each column use its own width, so more fit on a line.
Exit status: 0 on success. An unknown mode word is an error.
Usage notes
autoandalways.automakes layout happen only when standard output is a terminal;neverdisables it;alwaysforces it. In scripts and pipes, set a mode explicitly so the output does not change with the environment.- Width is measured in display cells. Wide characters such as CJK text count as two; combining marks count as zero.
- No sorting. Items appear in input order. Sort first if you want alphabetical columns:
... | sort | git column. - Long items. A cell wider than the available width gets its own line.
- Configuration.
column.uiaccepts the same words as--mode(for exampleauto,dense), and per-command keys such ascolumn.branchoverride it. The commands that use columns arebranch,status,tagandclean. - Not a table formatter. There are no separators, headers or alignment of numbers. Use
column -torprintffor real tables.
Related
- git branch, git status, git config
- Lessons: Aliases, Setup and Configuration