nu: Add git sha command

This commit is contained in:
2026-02-10 14:34:51 +01:00
parent 50e4f8528d
commit 378da0e7be

View File

@@ -18,3 +18,26 @@ def gitfixremote [
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
}