From 881aaedd4ad1158228233fd876a9af34bcce8311 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 9 Jul 2024 11:05:25 +0200 Subject: [PATCH] home/git/switch-interactive: fix for branchnames with '/' --- home/programs/git/scripts/git-switch-interactive.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/home/programs/git/scripts/git-switch-interactive.sh b/home/programs/git/scripts/git-switch-interactive.sh index c2d7717..600a92b 100644 --- a/home/programs/git/scripts/git-switch-interactive.sh +++ b/home/programs/git/scripts/git-switch-interactive.sh @@ -7,5 +7,10 @@ fi BRANCHES=$(cat <(git branch) <(git branch --remotes) | grep --invert-match '^\*\|HEAD ->' | sed 's|^\s*||') CHOSEN_BRANCH=$(fzf --reverse --info=inline --preview 'git show --color {}' <<<"$BRANCHES") -CLEAN_BRANCH_NAME=$(sed 's|^\s*.*/||' <<<"$CHOSEN_BRANCH") -git switch "$CLEAN_BRANCH_NAME" \ No newline at end of file + +CLEAN_BRANCH_NAME=$(sed 's|^\s*||' <<<"$CHOSEN_BRANCH") +for REMOTE in $(git remote); do + CLEAN_BRANCH_NAME=$(sed "s|^${REMOTE}/||" <<<"$CLEAN_BRANCH_NAME") +done + +git switch "${CLEAN_BRANCH_NAME}"