feat: add herdr & pi auto theme

This commit is contained in:
johannes committed 2026-07-31 00:28:11 +02:00
1 parent 658ef3f3ed
commit 5af8007804
6 files changed
+101 -2

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
[theme]
auto_switch = true
dark_name = "catppuccin"
light_name = "catppuccin-latte"
[keys]
# Prefix key
prefix = "ctrl+b"
# Direct pane navigation (bypasses prefix)
focus_pane_left = "alt+h"
focus_pane_down = "alt+j"
focus_pane_up = "alt+k"
focus_pane_right = "alt+l"
# Direct pane creation (bypasses prefix)
split_vertical = "alt+v"
split_horizontal = "alt+s"
+1 -1
View File
@@ -114,7 +114,7 @@ overlay use scripts/alias-finder.nu
source scripts/commands.nu
source ~/.local/share/nushell/vendor/autoload/wt.nu
#source ~/.local/share/nushell/vendor/autoload/wt.nu
#----------------
# Custom Commands
+12
View File
@@ -55,6 +55,18 @@ def --env zj [path?: string] {
zellij attach -c $session_name
}
# hd: "Smart Herdr"
# 1. If argument provided: cd there, then open herdr
# 2. If no argument: open herdr in current dir
def --env hd [path?: string] {
if ($path != null) {
cd $path
}
let session_name = ($env.PWD | path basename)
herdr --session $session_name
}
def man [topic: string] {
^man $topic | bat -l man -p
}
+1
View File
@@ -19,6 +19,7 @@
fastfetch
atuin
zellij
herdr
unp
carapace
bun
+4 -1
View File
@@ -2,6 +2,9 @@
"lastChangelogVersion": "0.82.0",
"defaultProvider": "openai-codex",
"defaultModel": "gpt-5.5",
"extensions": [
"../extensions"
],
"packages": [
"npm:pi-antigravity",
"npm:pi-catppuccin-tui",
@@ -19,7 +22,7 @@
],
"theme": "catppuccin-tui-latte",
"hideThinkingBlock": true,
"quiteStartup": true,
"quietStartup": true,
"enableInstallTelemetry": false,
"powerline": "full"
}
+65
View File
@@ -0,0 +1,65 @@
// @ts-nocheck
import { exec } from "node:child_process";
import { promisify } from "node:util";
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
const execAsync = promisify(exec);
async function checkTheme(): Promise<{ dark: boolean; error?: string }> {
try {
if (process.platform === "darwin") {
const { stdout } = await execAsync(
"osascript -e 'tell application \"System Events\" to tell appearance preferences to return dark mode'",
);
return { dark: stdout.trim() === "true" };
} else if (process.platform === "linux") {
const { stdout } = await execAsync(
"dbus-send --session --print-reply --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:'org.freedesktop.appearance' string:'color-scheme'",
);
// 1 is Dark, 2 is Light, 0 is Default
return { dark: stdout.includes("uint32 1") };
}
return { dark: true, error: "Unsupported OS" };
} catch (e: any) {
return { dark: true, error: e.message.split("\n")[0] }; // First line of error
}
}
export default function (pi: ExtensionAPI) {
let intervalId: ReturnType<typeof setInterval> | null = null;
const updateTheme = async (ctx: any, currentTheme: string) => {
const res = await checkTheme();
const newTheme = res.dark ? "catppuccin-tui-mocha" : "catppuccin-tui-latte";
if (res.error) {
ctx.ui.setStatus(
"auto-theme",
ctx.ui.theme.fg("error", `theme err: ${res.error}`),
);
} else {
ctx.ui.setStatus("auto-theme", ctx.ui.theme.fg("muted", "theme auto"));
}
if (newTheme !== currentTheme) {
ctx.ui.setTheme(newTheme);
}
return newTheme;
};
pi.on("session_start", async (_event, ctx) => {
let currentTheme = "";
currentTheme = await updateTheme(ctx, currentTheme);
intervalId = setInterval(async () => {
currentTheme = await updateTheme(ctx, currentTheme);
}, 2000);
});
pi.on("session_shutdown", () => {
if (intervalId) {
clearInterval(intervalId);
intervalId = null;
}
});
}