From f38ba5dceacc20702d0948dc589ee25fa82ce0d8 Mon Sep 17 00:00:00 2001 From: Alan Norton Date: Wed, 13 Dec 2023 14:44:31 -0500 Subject: [PATCH] git col --- .gitconfig | 1 + .githelpers | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.gitconfig b/.gitconfig index 25462b9..513fe71 100644 --- a/.gitconfig +++ b/.gitconfig @@ -41,6 +41,7 @@ ci = commit -v co = checkout + col = "!. ~/.githelpers && checkout_first_matching" df = "diff --name-only" dfo = "df origin/master" diff --git a/.githelpers b/.githelpers index 9ac1fd2..e72429c 100644 --- a/.githelpers +++ b/.githelpers @@ -97,6 +97,14 @@ delete_all_my_branches_interactive(){ done } +checkout_first_matching() { + if [ -z "$1" ]; then + echo "No pattern provided" + else + git branch | egrep "$1" | head -1 | xargs git checkout + fi +} + TIMESINCE="function timeSince(date) {\ var seconds = Math.floor((new Date() - date) / 1000);\ var interval = Math.floor(seconds / 31536000);\