Add command to fix git remotes
This commit is contained in:
@ -674,6 +674,7 @@ alias xo = xdg-open
|
|||||||
# random scripts
|
# random scripts
|
||||||
source ~/.local/nu/readelf.nu
|
source ~/.local/nu/readelf.nu
|
||||||
source ~/.local/nu/mullvad.nu
|
source ~/.local/nu/mullvad.nu
|
||||||
|
source ~/.local/nu/git.nu
|
||||||
|
|
||||||
# init zoxide
|
# init zoxide
|
||||||
source ~/.cache/zoxide.nu
|
source ~/.cache/zoxide.nu
|
||||||
|
|||||||
19
tree/.local/nu/git.nu
Normal file
19
tree/.local/nu/git.nu
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
def gitfixremote [
|
||||||
|
--name: string = "origin",
|
||||||
|
] {
|
||||||
|
let url = (git remote get-url $name)
|
||||||
|
let parsed = ($url | parse --regex '(https://)?(?P<host>[^/]+)(/|:)(?P<owner>[^/]+)/(?P<repo>[^/\.]+)')
|
||||||
|
if ($parsed | is-empty) {
|
||||||
|
print "Unparseable remote"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let parsed = ($parsed | get 0)
|
||||||
|
|
||||||
|
if ($parsed.host in ["github.com" "git.nubo.sh"]) {
|
||||||
|
git remote set-url $name $"https://($parsed.host)/($parsed.owner)/($parsed.repo).git"
|
||||||
|
git remote set-url --push $name $"($parsed.host):($parsed.owner)/($parsed.repo).git"
|
||||||
|
} else {
|
||||||
|
print $"Unknown host: ($parsed.host)"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user