Files
dotfiles/dot_config/nushell/git.nu
T
mpuchstein ff1cdc02b9 nu: add nushell config and apex-styled prompt
Initial nushell dotfiles: config, modules (git, k8s, sys, hypr, pkg,
dev), apex theme files, and a chezmoi-templated prompt that shows dir
and git branch/dirty using apex-neon/aeon colors with vi mode indicators.
2026-05-17 08:48:19 +02:00

45 lines
1.0 KiB
Nu

# List branches with upstream, last commit date and subject
def gb [] {
^git for-each-ref --format "%(refname:short)\t%(upstream:short)\t%(creatordate:relative)\t%(subject)" refs/heads
| lines
| each {|l|
let p = $l | split row "\t"
{
branch: $p.0
upstream: (if ($p.1 | is-empty) { null } else { $p.1 })
date: $p.2
subject: $p.3
}
}
}
# Git log as a table — default 20 entries, pass n to change
def gl [n: int = 20] {
^git log --format "%H\t%as\t%an\t%s" -n $n
| lines
| each {|l|
let p = $l | split row "\t"
{
hash: ($p.0 | str substring 0..7)
date: $p.1
author: $p.2
subject: $p.3
}
}
}
# Diff stats as a table (unstaged by default; --cached for staged)
def gd [--cached] {
let flags = if $cached { [--cached] } else { [] }
^git diff --numstat ...$flags
| lines
| each {|l|
let p = $l | split row "\t"
{
ins: ($p.0 | into int)
del: ($p.1 | into int)
file: $p.2
}
}
}