From 310208dbb597faf8efb81ff5d587290ce8fb008d Mon Sep 17 00:00:00 2001 From: Julius Riegel Date: Fri, 22 Mar 2024 17:11:35 +0100 Subject: [PATCH] Format branch --- content/config/nushell/scripts/ide.nu | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/content/config/nushell/scripts/ide.nu b/content/config/nushell/scripts/ide.nu index f931090..a2d6875 100755 --- a/content/config/nushell/scripts/ide.nu +++ b/content/config/nushell/scripts/ide.nu @@ -145,7 +145,7 @@ export def `zjstatus powerline_left` [] { fg: "#ffffff" } { - text: $"(git rev-parse --abbrev-ref HEAD) " + text: $"(branch-name) " icon: "" bg: "blue" fg: $ZELLIJ_BG @@ -154,12 +154,23 @@ export def `zjstatus powerline_left` [] { render powerline $ZELLIJ_BG $elements --start "" } +def branch-name [] { + let name = (git rev-parse --abbrev-ref HEAD) + let parts = ($name | split row "/") + + if ($parts | length) > 1 { + $"(ansi {attr: i})($parts.0)/(ansi reset)(ansi {fg: $ZELLIJ_BG, bg: blue, attr: b})($parts | skip 1 | str join '/')" + } else { + $"(ansi {attr: b})($name)" + } +} + export def `zjstatus powerline_right` [] { use ci.nu let sys = (sys) let elements = ([ - (ci status) + (try { ci status } catch { null }) { text: ($sys.cpu.cpu_usage | math avg | math round -p 2 | $"($in) % " | fill -a right -c ' ' -w 8) icon: ""