Created
April 5, 2023 20:34
-
-
Save hoop33/5c319ebb22e10a27bd52f31538487f8d to your computer and use it in GitHub Desktop.
Nushell functions for `git switch` and `git branch -d` using fzf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git branch switch | |
def gbs [] { | |
let branch = ( | |
git branch | | |
split row "\n" | | |
str trim | | |
where ($it !~ '\*') | | |
where ($it != '') | | |
str join (char nl) | | |
fzf --no-multi | |
) | |
if $branch != '' { | |
git switch $branch | |
} | |
} | |
# git branch -d | |
def gbd [] { | |
let branches = ( | |
git branch | | |
split row "\n" | | |
str trim | | |
where ($it !~ '\*') | | |
where ($it != '') | | |
str join (char nl) | | |
fzf --multi | | |
split row "\n" | | |
where ($it != '') | |
) | |
if ($branches | length) > 0 { | |
$branches | each { |branch| git branch -d $branch } | |
"" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment