From 7f52c7a4cbf95d861e8bd29ac085c3dc54c1925c Mon Sep 17 00:00:00 2001 From: druckdev Date: Mon, 31 Jan 2022 12:50:54 +0100 Subject: [PATCH] git,zsh:autoload: Move git-track into own function Move `git-track` into its own autoloadable function. This way it is better maintainable as in one-liner format and brings the possibility of having more complexity (e.g. for better portability). By that it is also now executable as `git-track` as well as `git track` as before. --- .config/git/config | 2 +- .config/zsh/autoload/git/git-track | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 .config/zsh/autoload/git/git-track diff --git a/.config/git/config b/.config/git/config index e84d5c7..b474a15 100644 --- a/.config/git/config +++ b/.config/git/config @@ -6,7 +6,7 @@ fixes = log -1 --pretty=fixes root = rev-parse --show-toplevel spull = "!__git_spull() { git pull \"$@\" && git submodule sync --recursive && git submodule update --init --recursive; }; __git_spull" - track = "!git for-each-ref --format='%(upstream),%(refname)' refs/heads refs/remotes | sort -d | sed -Ez 's:(^|\\n|,)refs/(heads|remotes/):\\1:g; s:(^|\\n),([^/][^\\n]*):\\1\\2,:g; s:,/:,:g; s:(^|\\n)([^,]+),\\n\\2:\\1\\2:g; s:(^|\\n)([^/,]*)([^\\n]*\\n\\2(,|/))*:\\n&:g; s:\\n+$:\\n:' | (echo remote,local; cat) | column -tdLs, -Na,b -Ob,a | sed '2d; 1{p;s/./―/g}'" + track = "!\"${XDG_CONFIG_HOME:-$HOME/.config}/zsh/autoload/git/git-track\"" [color "status"] added = 076 untracked = 014 diff --git a/.config/zsh/autoload/git/git-track b/.config/zsh/autoload/git/git-track new file mode 100755 index 0000000..04ae6b1 --- /dev/null +++ b/.config/zsh/autoload/git/git-track @@ -0,0 +1,15 @@ +#!/usr/bin/env zsh + +git for-each-ref --format='%(upstream),%(refname)' refs/heads refs/remotes \ + | sort -d \ + | sed -Ez ' + s:(^|\n|,)refs/(heads|remotes/):\1:g + s:(^|\n),([^/][^\n]*):\1\2,:g + s:,/:,:g + s:(^|\n)([^,]+),\n\2:\1\2:g + s:(^|\n)([^/,]*)([^\n]*\n\2(,|/))*:\n&:g + s:\n+$:\n: + ' \ + | (echo remote,local; cat) \ + | column -tdLs, -Na,b -Ob,a \ + | sed '2d; 1{p;s/./―/g}'