From 8bd52e20171c047f20c7705d306067f97e53c4f7 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Thu, 25 May 2023 21:18:04 -0400 Subject: [PATCH] Advanced git-checkout --- zsh/.config/zsh/aliases | 2 +- zsh/.config/zsh/functions | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/zsh/.config/zsh/aliases b/zsh/.config/zsh/aliases index c992118..ffe780e 100644 --- a/zsh/.config/zsh/aliases +++ b/zsh/.config/zsh/aliases @@ -24,7 +24,7 @@ alias gc="git commit" alias gca="git commit --amend" alias gcl="git commit -m 'Linting'" alias gcn="git commit --allow-empty --message 'noop'" -alias gco="git checkout" +alias gco="advanced-git-checkout" alias gcp="git cherry-pick" alias gcs="git commit -m '¯\_(ツ)_/¯'" alias gct="git commit -m '( ͡° ͜ʖ ͡°)'" diff --git a/zsh/.config/zsh/functions b/zsh/.config/zsh/functions index 4ac8683..7debb0c 100644 --- a/zsh/.config/zsh/functions +++ b/zsh/.config/zsh/functions @@ -1,3 +1,13 @@ +function advanced-git-checkout { + if [ $# -eq 0 ]; then + git branch \ + | fzf \ + | xargs -I {} git checkout {} + else + git checkout $@ + fi +} + function ag-count { if [ $# -lt 1 ]; then echo Usage: ag-count SEARCHTERM