Skip to content

Instantly share code, notes, and snippets.

@hoop33
Created April 5, 2023 20:34
Show Gist options
  • Save hoop33/5c319ebb22e10a27bd52f31538487f8d to your computer and use it in GitHub Desktop.
Save hoop33/5c319ebb22e10a27bd52f31538487f8d to your computer and use it in GitHub Desktop.
Nushell functions for `git switch` and `git branch -d` using fzf
# 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