Skip to content

Instantly share code, notes, and snippets.

@raylee
Last active February 17, 2024 20:00

Revisions

  1. raylee revised this gist Feb 17, 2024. No changes.
  2. raylee revised this gist Feb 17, 2024. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -10,3 +10,9 @@
    --format='%(HEAD)%(color:bold blue)%(refname:short)|%(color:green)%(committerdate:relative)|%(color:blue)%(authorname)|%(color:reset)%(subject)' \
    | column -ts'|' \
    | bash -c '"cut -c1-$((20 + $(stty size -F /dev/stderr | cut -f2 -d\" \")))"'

    # fetch-all: retrieve all branch data from the remote. This can download a lot of data!
    fetch-all = "!f(){ git checkout --detach 2>/dev/null \
    && git fetch --tags origin '+refs/heads/*:refs/heads/*' \
    && git branches; }; f"

  3. raylee created this gist Feb 17, 2024.
    12 changes: 12 additions & 0 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    [alias]
    # branches: List recent branches sorted by date
    # ${COLUMNS} is the standard environment variable to use to get the terminal's width. Unfortunately
    # git sanitizes that away. git 2.31 will have a way to keep that variable. For now, extract it from
    # the environment via stty. The below adds 20 to that value to account for the overhead of ANSI
    # color sequences.
    branches = !git for-each-ref refs/heads \
    --color=always \
    --sort=-committerdate \
    --format='%(HEAD)%(color:bold blue)%(refname:short)|%(color:green)%(committerdate:relative)|%(color:blue)%(authorname)|%(color:reset)%(subject)' \
    | column -ts'|' \
    | bash -c '"cut -c1-$((20 + $(stty size -F /dev/stderr | cut -f2 -d\" \")))"'