Compare
# Pick a branch in a TUI and switch to it
def "git pick" [--remote(-r)] {
let flags = if $remote {[--remotes]} else {[]}
let picked = ^git branch --format "%(refname:short)%09%(upstream:short)" ...$flags|lines|parse "{name}\t{upstream}"
|tui label --title "branches"|tui search --placeholder "filter" --bind /
| tui split --sizes [40% 1fr] [(tui table --columns [name upstream])
(tui preview {|row| ^git log --oneline -n 20 $row.name})]
|tui label --status "enter: switch q: quit"|tui run
match $picked {
{action: quit} => {print "Nothing picked"}
{selected: {name: $name}} if ($name|str starts-with "origin/") => {
^git switch --track $name}
{selected: {name: $name}} => {^git switch $name}
}
}
# Pick a branch in a TUI and switch to it
def "git pick" [--remote(-r)] {
let flags = if $remote { [--remotes] } else { [] }
let picked = ^git branch --format "%(refname:short)%09%(upstream:short)" ...$flags
| lines
| parse "{name}\t{upstream}"
| tui label --title "branches"
| tui search --placeholder "filter" --bind /
| tui split --sizes [40%, 1fr] [
(tui table --columns [name, upstream])
(tui preview {|row| ^git log --oneline -n 20 $row.name })
]
| tui label --status "enter: switch q: quit"
| tui run
match $picked {
{ action: quit } => { print "Nothing picked" }
{ selected: { name: $name } } if ($name | str starts-with "origin/") => {
^git switch --track $name
}
{ selected: { name: $name } } => { ^git switch $name }
}
}
Install
cargo install --git https://github.com/mst-mkt/nuten nuten
nix profile install github:mst-mkt/nuten
How Nuten stays correct
Lossless CSTParses code into a tree that keeps everything, including whitespace and comments.
Parser snapshotsCatches unexpected changes in parsing results.
Formatter fixturesCompares formatted output with the expected output, so the style never drifts.
Real-world corpusFormats real-world scripts and makes sure no token or comment is lost.
nu as oracleAsks nu whether it parses code the same way before and after formatting.
FuzzingThrows random input at Nuten to make sure it never crashes or loses code.
Benchmark
See Performance for more results and how they are measured.
Editors and tools
The same formatter, from the CLI to the tools you already use.