From 2db0a0ec918d6754f169bc19207e9faa9384dcf5 Mon Sep 17 00:00:00 2001 From: Billie Hilton <587740+billiegoose@users.noreply.github.com> Date: Fri, 23 Feb 2024 11:06:41 -0500 Subject: [PATCH] fix: use 'column', with 'vl', and 'sed' as fallbacks --- bin/g | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/g b/bin/g index 555220c..ddfd72d 100755 --- a/bin/g +++ b/bin/g @@ -29,6 +29,16 @@ confirmYes () { esac } +columnify () { + if which column > /dev/null; then + column -ts'|' + elif which vl > /dev/null; then + vl -s'\|' + else + sed 's/|/\t/g' + fi +} + case "$1" in '?' | status) # TODO: Display help if not inside a repo @@ -296,7 +306,7 @@ done < "$TEMP/merged.branches" git for-each-ref --sort=-committerdate refs/remotes \ --format='%(HEAD) %(color:green)%(committerdate:relative)%(color:reset)|%(color:red)%(objectname:short)%(color:reset)|%(color:blue)%(refname:short)%(color:reset)' > "$TEMP/remote.branches" # Print them in columns -cat "$TEMP/local.branches" "$TEMP/remote.branches" | vl -s'\|' +cat "$TEMP/local.branches" "$TEMP/remote.branches" | columnify ;; fetch)