def gitfixremote [ --name: string = "origin", ] { let url = (git remote get-url $name) let parsed = ($url | parse --regex '^(\w+://)?(\w*@)?(?P[^/:]+)(:(?P\d+))?(:|/)(?P\w+)/(?P[\w_-]+)') 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 $"ssh://($parsed.host)/($parsed.owner)/($parsed.repo).git" } else { print $"Unknown host: ($parsed.host)" } } def "git sha" [ --no-copy(-c), # don't copy to clipboard --full(-f), # output the complete sha ]: nothing -> record { mut sha = (git show -q | lines | parse "commit {sha}" | first); if ($sha | is-empty) { return; } $sha = $sha.sha if not $full { $sha = ($sha | str substring 0..7) } if not $no_copy { $sha | pbc } $sha }