repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

nushell: usage commands for minimax and zai wezterm: ai helper command

404749a1a5fd957f478493f59cdf2fdde9a64e77

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (21)

.gitignore

Modified
1 1 tresor/box_do_key
3 +gh/hosts.yml
3 5 nugu/output/
5 7 nushell/zoxide.nu

.opencode/skills/presentation-updates/SKILL.md

Added
new file mode 100644
1 +# Updates for AI Agents Presentation
3 +## Changes to make based on YouTube video:
5 +1. Add clearer Automation vs Agent comparison with umbrella example
6 +2. Add "Three Components" slide (Brain, Memory, Tools)
7 +3. Add Tool Categories (Retrieve, Act, Orchestrate)
8 +4. Add Guardrails section - CRITICAL
9 +5. Add Prompt Structure framework
10 +6. Add "Build simplest thing that works" principle
11 +7. Add Memory Context Window explanation
12 +8. Add Prompt Injection warning
15 +## Completed Updates:
16 +- Guardrails section added
17 +- Prompt structure framework added
18 +- Tool categories clarified
19 +- "Build simplest thing that works" principle added
20 +- Memory context window explained
21 +- Prompt injection warning added
22 +- Better automation vs agent comparison with umbrella example

neovide/config.toml

Modified
1 -fork = true
2 1 frame = "none"
3 2 tabs = true
4 3 theme = "auto"

nushell/env.nu

Modified
10 10 $env.CARGO_HOME = ( "~/.cargo" | path expand )
11 11 $env.GO_HOME = ( "~/.go" | path expand )
12 12 $env.OPENCODE_HOME = ( "~/.opencode" | path expand)
13 +$env.ANTHROPIC_BASE_URL = "https://api.minimax.io/anthropic"
14 +$env.MINIMAX_API_HOST = "https://api.minimax.io"
15 +$env.OPENCODE_EXPERIMENTAL_LSP_TOOL = true
16 +if (not $env.WIN32) {
17 + # make sure to start ssh-agent user service: userctl enable --now ssh-agent
18 + $env.SSH_AUTH_SOCK = $"($env.XDG_RUNTIME_DIR)/ssh-agent.socket"
14 21 if $env.WIN32 {
15 22 $env.Path = (

nushell/gen-aliases.nu

Modified
24 24 aka web firefox
25 25 aka code neovide
26 26 aka edit nvim '--clean'
27 -aka timer tclock timer '--paused' '--no-millis' '--duration'
28 -aka countdown tclock countdown '--time'
27 +# TODO use cyber-timer
28 +# aka timer tclock timer '--paused' '--no-millis' '--duration'
29 +# aka countdown tclock countdown '--time'
29 30 aka video mpv '--no-config' '--vo=kitty' '--vo-kitty-use-shm=yes' '--profile=sw-fast' '--really-quiet'
30 31 aka package mise use '--global'
31 32 aka unpackage mise unuse '--global'
44 45 if (not $env.WIN32) {
45 46 aka fg job unfreeze
48 +aka oc opencode
49 +aka occ opencode '-c'
48 51 aka userctl systemctl '--user'

nushell/gen-secrets.nu

Modified
24 24 # needs to be classic token for package.nu
25 25 # see: https://github.com/settings/tokens
26 -secret GITHUB_TOKEN
27 26 secret ECOSYSTEMS_TOKEN
28 27 secret CONTEXT7_TOKEN
28 +secret GITHUB_PAT_TOKEN
29 +secret GITHUB_PAT_TOKEN_LLM
30 +secret MINIMAX_API_KEY
31 +secret ZAI_API_KEY

nushell/login.nu

Modified
2 2 use prompt.nu
3 3 use sy.nu
4 4 use md.nu
5 5 use todo.nu
6 -use ssh-keygen-ed.nu
6 +use ssh.nu *
7 +use btrfs.nu
7 8 use start.nu
8 9 use dwnld.nu
9 10 use notes.nu
11 12 use akku.nu
12 13 use colors.nu
13 14 use syncthing.nu
14 -use alias-finder.nu
15 +use minimax.nu
16 +use zai.nu
16 18 use wrappers.nu *

nushell/modules/alias-finder.nu

Deleted
deleted file mode 100644
1 -export-env {
2 - def get_prefix [] {
3 - if ($env.NU_ALIAS_FINDER_PREFIX? | is-empty) == true {
4 - return " Alias Tip:"
5 - }
6 - return $env.NU_ALIAS_FINDER_PREFIX
7 - }
8 - def check_if_command_in_ignored [cmd: string] {
9 - if ($env.NU_ALIAS_FINDER_IGNORED? | is-empty) == true {
10 - return false
11 - }
12 - let $ignored = ($env.NU_ALIAS_FINDER_IGNORED | split row ",")
13 - return ($ignored | any { |item| $item | str contains $cmd })
14 - if ($ignored | any { |item| $item | str contains $cmd }) {
15 - return true
16 - }
17 - return false
18 - }
19 - # functions
20 - export def check_if_aliased [cmd: string] {
21 - if (check_if_command_in_ignored $cmd) == true {
22 - return
23 - }
24 - if (help aliases | where name == '($cmd)' | length ) > 0 {
25 - return
26 - }
27 - if (help aliases | where expansion == ($cmd) | length ) > 0 {
28 - print $"(ansi blue_bold)(get_prefix)(ansi reset) (help aliases | where expansion == ($cmd) | get 0 | get name)"
29 - return
30 - }
31 - if (help aliases | where {|it| $cmd | str contains $it.expansion} | length ) > 0 {
32 - print $"(ansi blue_bold)(get_prefix)(ansi reset) (help aliases | where {|it| $cmd | str contains $it.expansion} | get 0 | get name)"
33 - return
34 - }
35 - }
36 - # hook
37 - $env.config = (
38 - $env.config
39 - | upsert hooks.pre_execution [ {||
40 - $env.repl_commandline = (commandline)
41 - check_if_aliased $env.repl_commandline
42 - } ]
43 - )
44 -}

nushell/modules/btrfs.nu

Added
new file mode 100644
1 +# Btrfs Maintenance Script
2 +# This script checks if your system is Btrfs and attempts to fix "Full" states
3 +# by running a balance on chunks > 75% full.
4 +export def maintenance [
5 + mount_point: path = '/' # mount point to check, `/` by default
6 +] {
7 + print "🔍 Checking filesystem type..."
8 + let fs_type = df | where Mounted == $mount_point | get Filesystem.0
10 + if $fs_type != "btrfs" {
11 + print $"❌ Error: Not a Btrfs filesystem ($fs_type). Aborting."
12 + exit 1
13 + }
15 + print "✅ Filesystem is Btrfs."
17 + print "\n📊 Current Btrfs Usage:"
18 + ^btrfs filesystem usage $mount_point
20 + print "\n🛠 Starting Btrfs Balance..."
22 + try {
23 + ^sudo btrfs balance start -dusage=75 -musage=75 $mount_point
24 + print "✅ Balance command sent successfully."
25 + } catch { |err |
26 + print $"❌ Failed to start balance: $err"
27 + print "Ensure you have sudo privileges."
28 + exit 1
29 + }
31 + print "\n⏳ Waiting for balance to complete or show status..."
32 + ^sudo btrfs status $mount_point
34 + if ($in | str contains "Balance") {
35 + print "\n⚠ Balance is still running. You can check progress with:"
36 + print $" btrfs balance status $MOUNT_POINT"
37 + }
39 + print "\n📈 Checking storage after balance:"
40 + ^btrfs filesystem usage $mount_point
42 + print "\n✅ Maintenance Complete."

nushell/modules/lib.nu

Added
new file mode 100644
1 +# Check if a binary is available in $env.PATH.
2 +# Throws error if not.
3 +export def require-binary [
4 + bin: string # name of a binary, that should be in $env.PATH
5 +] {
6 + if (which $bin | is-empty) {
7 + error make {
8 + msg: $"`$bin` is not installed or not in PATH"
9 + label: {
10 + text: $"run `which $bin` to verify"
11 + }
12 + }
13 + }

nushell/modules/minimax.nu

Added
new file mode 100644
1 +# Uses the unofficial Z.AI REST API to show current usage of the Coding Plan.
2 +# Needs the ZAI_API_KEY environment variable
3 +export def usage [] {
4 + let token = $env | get --optional ZAI_API_KEY
5 + if ($token | is-empty) {
6 + error make {
7 + msg: "Token for Z.AI missing in environment"
8 + help: "Make sure to put ZAI_API_KEY in your secrets.nuon file"
9 + }
10 + }
11 + let headers = {
12 + Authorization: $'Bearer ($token)'
13 + Content-Type: 'application/json'
14 + }
15 + let response = http get --headers $headers 'https://api.z.ai/api/monitor/usage/quota/limit'
16 + let base_response = $response | get base_resp
18 + if ($base_response.code ) != 200 {
19 + error make {
20 + msg: $base_response.msg
21 + help: "The Z.AI environment variable ZAI_API_KEY seems to be wrong."
22 + }
23 + }
25 + $response.data.limits
26 + | update nextResetTime { $in // 1000 | into datetime --timezone u --format '%s' }

nushell/modules/ssh-keygen-ed.nu

Deleted
deleted file mode 100644
1 -# Generate a new ed25519 SSH private key
2 -export def main [
3 - email: string # Identifier for the COMMENT section of the key
4 -] {
5 - ssh-keygen -t ed25519 -C $email
6 -}

nushell/modules/ssh.nu

Added
new file mode 100644
1 +use ./lib.nu *
3 +# Generate a new ed25519 SSH private key
4 +export def ssh-keygen-ed [
5 + email: string # Identifier for the COMMENT section of the key
6 +] {
7 + require-binary ssh-keygen
8 + ssh-keygen -t ed25519 -C $email
9 +}
11 +# Generate public key from private key
12 +export def ssh-keygen-pub [
13 + key: path # path to private key
14 +] {
15 + require-binary ssh-keygen
16 + ssh-keygen -y -f $key | save --raw $"($key + .pub)"

nushell/modules/zai.nu

Added
new file mode 100644
1 +# Uses the unofficial Z.AI REST API to show current usage of the Coding Plan.
2 +# Needs the ZAI_API_KEY environment variable
3 +export def usage [] {
4 + let token = $env | get --optional ZAI_API_KEY
5 + if ($token | is-empty) {
6 + error make {
7 + msg: "Token for Z.AI missing in environment"
8 + help: "Make sure to put ZAI_API_KEY in your secrets.nuon file"
9 + }
10 + }
11 + let headers = {
12 + Authorization: $'Bearer ($token)'
13 + Content-Type: 'application/json'
14 + }
15 + let response = http get --headers $headers 'https://api.z.ai/api/monitor/usage/quota/limit'
17 + if ($response.code ) != 200 {
18 + error make {
19 + msg: $response.msg
20 + help: "The Z.AI environment variable ZAI_API_KEY seems to be wrong."
21 + }
22 + }
24 + $response.data.limits
25 + | update nextResetTime { $in // 1000 | into datetime --timezone u --format '%s' }

wezterm/bugabinga/ai_shell.lua

Added
new file mode 100644
1 +local wezterm = require 'wezterm'
2 +local system_prompt = require 'bugabinga.ai_system_prompt'
4 +local M = {}
6 +local OLLAMA_URL = 'http://localhost:11434/api/generate'
7 +local MODEL = 'minimax-m2.5:cloud'
8 +local MAX_SCROLLBACK_LINES = 300
10 +local ai_state = {}
12 +local function get_ai_state(window)
13 + local id = window:window_id()
14 + if not ai_state[id] then
15 + ai_state[id] = {
16 + status = 'idle',
17 + }
18 + end
19 + return ai_state[id]
20 +end
22 +function M.trigger_ai_shell(window, pane, question)
23 + local state = get_ai_state(window)
24 + state.status = 'loading'
26 + local scrollback = pane:get_lines_as_text(MAX_SCROLLBACK_LINES)
28 + local full_prompt = system_prompt.prompt .. '\n\n---\n\nRECENT SCROLLBACK:\n' .. scrollback .. '\n\n---\n\nUSER QUESTION: ' .. question .. '\n\nRESPONSE:'
30 + local json_payload = wezterm.json_encode({
31 + model = MODEL,
32 + prompt = full_prompt,
33 + stream = false,
34 + })
36 + local success, stdout, stderr = wezterm.run_child_process({
37 + 'curl', '-s', '-X', 'POST', OLLAMA_URL,
38 + '-H', 'Content-Type: application/json',
39 + '-d', json_payload,
40 + })
42 + if not success or stdout == '' then
43 + state.status = 'offline'
44 + wezterm.time.call_after(2, function()
45 + state.status = 'idle'
46 + end)
47 + return
48 + end
50 + local ok, response = pcall(function()
51 + return wezterm.json_parse(stdout)
52 + end)
54 + if not ok or not response or not response.response then
55 + state.status = 'error'
56 + wezterm.time.call_after(2, function()
57 + state.status = 'idle'
58 + end)
59 + return
60 + end
62 + local command = M.strip_markdown(response.response)
63 + command = command:match('^%s*(.-)%s*$')
65 + pane:send_text(command)
67 + state.status = 'success'
68 + wezterm.time.call_after(1.5, function()
69 + state.status = 'idle'
70 + end)
71 +end
73 +function M.strip_markdown(text)
74 + local lines = {}
75 + for line in text:gmatch('[^\r\n]+') do
76 + table.insert(lines, line)
77 + end
79 + if #lines > 0 and (lines[1]:match('^```%w*$') or lines[1] == '```') then
80 + table.remove(lines, 1)
81 + end
83 + if #lines > 0 and lines[#lines] == '```' then
84 + table.remove(lines, #lines)
85 + end
87 + local filtered = {}
88 + for _, line in ipairs(lines) do
89 + if line ~= '```' then
90 + table.insert(filtered, line)
91 + end
92 + end
94 + return table.concat(filtered, '\n')
95 +end
97 +function M.get_status_icon(window)
98 + local state = get_ai_state(window)
100 + local icon, color, label
102 + if state.status == 'loading' then
103 + icon = wezterm.nerdfonts.md_robot_confused
104 + color = 'Yellow'
105 + label = 'loading...'
106 + elseif state.status == 'success' then
107 + icon = wezterm.nerdfonts.md_robot_excited
108 + color = 'Green'
109 + label = 'done'
110 + elseif state.status == 'error' then
111 + icon = wezterm.nerdfonts.md_robot_dead
112 + color = 'Red'
113 + label = 'error'
114 + elseif state.status == 'offline' then
115 + icon = wezterm.nerdfonts.md_robot_off
116 + color = 'Gray'
117 + label = 'offline'
118 + else
119 + icon = wezterm.nerdfonts.md_robot
120 + color = nil
121 + label = nil
122 + end
124 + return icon, color, label
125 +end
127 +function M.get_status(window)
128 + local icon, color, label = M.get_status_icon(window)
129 + local parts = {}
130 + if icon then
131 + if color then
132 + table.insert(parts, { Foreground = { AnsiColor = color } })
133 + end
134 + table.insert(parts, { Text = icon })
135 + end
136 + if label then
137 + if color then
138 + table.insert(parts, { Foreground = { AnsiColor = color } })
139 + end
140 + table.insert(parts, { Text = ' ' .. label })
141 + end
142 + return wezterm.format(parts)
143 +end
145 +function M.trigger_prompt(window, pane)
146 + window:perform_action(
147 + wezterm.action.PromptInputLine({
148 + description = wezterm.format({
149 + { Attribute = { Intensity = 'Bold' } },
150 + { Foreground = { AnsiColor = 'Fuchsia' } },
151 + { Text = '󰚩 Ask AI for Nushell command' },
152 + { Text = '\n' },
153 + { Attribute = { Intensity = 'Normal' } },
154 + { Foreground = { AnsiColor = 'Silver' } },
155 + { Text = 'e.g. "list only directories"' },
156 + }),
157 + prompt = wezterm.format({
158 + { Foreground = { AnsiColor = 'Green' } },
159 + { Text = '> ' },
160 + }),
161 + action = wezterm.action_callback(function(win, p, line)
162 + if line and line ~= '' then
163 + M.trigger_ai_shell(win, p, line)
164 + end
165 + end),
166 + }),
167 + pane
169 +end
171 +return M

wezterm/bugabinga/ai_system_prompt.lua

Added
new file mode 100644
1 +local M = {}
3 +--[[
4 + NUSHELL SYSTEM PROMPT
5 + =====================
6 +
7 + This prompt instructs the AI to generate valid Nushell commands.
8 + Update this when Nushell syntax changes significantly.
9 +
10 + KEY CRAFTING PRINCIPLES:
11 + -------------------------
12 + 1. Be explicit about Nushell version (0.110+)
13 + 2. List common Bash-to-Nushell equivalents
14 + 3. Emphasize: NO markdown, NO code fences, raw command only
15 + 4. Include examples of modern Nushell syntax (pipelines, $env, etc.)
16 + 5. Warn about common pitfalls (> is comparison, not redirection)
18 + RESOURCES FOR UPDATING:
19 + -----------------------
20 + - https://www.nushell.sh/book/thinking_in_nu.html
21 + - https://www.nushell.sh/book/coming_from_bash.html
22 + - https://www.nushell.sh/book/cheat_sheet.html
23 + - https://www.nushell.sh/book/quick_tour.html
25 + TESTING UPDATES:
26 + ----------------
27 + After updating, test with queries like:
28 + - "list files in current directory"
29 + - "find all .lua files recursively"
30 + - "show only directories in current folder"
31 + - "get the 5 largest files in current directory"
32 +]]
34 +M.prompt = [===[You are a Nushell (0.110+) expert. Generate ONLY raw shell commands valid in modern Nushell 0.110+.
36 +KEY NUSHELL CONCEPTS:
37 +- Nushell is NOT Bash. > is comparison operator, not redirection
38 +- Use pipeline syntax: "output | filter | transform"
39 +- Every command returns structured data (tables, lists, records)
40 +- Variables are immutable by default: use `let` not `=`. Use `mut` for mutable
41 +- Command substitution: use $(cmd) NOT `cmd`
42 +- String interpolation: $"text ($variable)"
43 +- Environment: $env.VAR (not $VAR). Set with: $env.VAR = value
44 +- Redirection: use `| save file` not > file. Use `out>` or `o>` for stdout
45 +- External commands: prefix with ^ to run system command
46 +- Lists: [item1 item2], access with .index (not [index])
47 +- Records: {key: value}, access with .key
48 +- Tables: [[col1 col2]; [1 2]]
49 +- Conditionals: where column == value (not grep)
50 +- File globbing: **/*.rs (not find)
51 +- Date handling: date now, | into datetime
52 +- Error handling: try/catch blocks
54 +COMMON EQUIVALENTS:
55 +- echo $PATH -> $env.PATH
56 +- echo $? -> $env.LAST_EXIT_CODE
57 +- cd -> cd (same)
58 +- ls -la -> ls --long --all or ls -la
59 +- find . -name -> glob **/pattern
60 +- grep -> where $it =~ pattern
61 +- cat file -> open file
62 +- > file -> | save file
63 +- >/dev/null -> | ignore
64 +- export VAR=x -> $env.VAR = x
65 +- $(cmd) -> $(cmd) (same in Nushell)
66 +- sed/awk -> str replace, parse, split
68 +COMMAND SYNTAX:
69 +- Custom commands: def command-name [param: type] { ... }
70 +- Aliases: alias name = cmd
71 +- For loops: for x in $list { ... }
72 +- While: while condition { ... }
73 +- Match: match $var { val => ..., _ => ... }
74 +- Let + mutate: mut x = 1; $x = 2
75 +- Try/catch: try { ... } catch { ... }
77 +IMPORTANT:
78 +- Output ONLY the raw command. No markdown, no code fences, no backticks, no explanation.
79 +- If multiple commands needed, separate with semicolons or newlines.
80 +- Use current Nushell 0.110+ syntax only.]===]
82 +return M

wezterm/bugabinga/hosts/fedora.lua

Modified
2 2 return function ( cfg )
3 3 cfg.enable_wayland = true
4 4 cfg.max_fps = 144
5 5 cfg.font_size = 16
6 + cfg.term = 'wezterm'
6 7 end

wezterm/bugabinga/key_binds.lua

Modified
200 200 mods = 'LEADER',
201 201 action = wez.action.Search 'CurrentSelectionOrEmptyString',
204 + key = 'a',
205 + mods = 'LEADER',
206 + action = wez.action_callback(function(window, pane)
207 + require('bugabinga.ai_shell').trigger_prompt(window, pane)
208 + end),
209 + },
204 211 key = ' ',
205 212 mods = 'LEADER',

wezterm/bugabinga/status.lua

Modified
42 42 local os_icon = wez.target_triple:find 'windows' and ' ' or ' '
43 43 local time = wez.time.now():format '%H:%M'
44 - local status = { time, os_icon, leader, }
44 + local ai_shell = require 'bugabinga.ai_shell'
45 + local ai_status = ai_shell.get_status(window)
46 + local status = { time, os_icon, ai_status, leader, }
46 48 if key_table then
47 49 table.insert( status, key_table )
85 87 cfg.use_fancy_tab_bar = false
86 88 cfg.tab_max_width = 42
87 89 cfg.tab_bar_at_bottom = true
88 - cfg.status_update_interval = 60 * 1000
90 + cfg.status_update_interval = 1000

zed/keymap.json

Deleted
deleted file mode 100644
1 -[
2 - {
3 - "context": "vim_mode == normal",
4 - "bindings": {},
5 - },
6 - {
7 - "context": "vim_mode == insert",
8 - "bindings": {},
9 - },
10 - {
11 - "context": "vim_mode == visual",
12 - "bindings": {},
13 - },
14 -]

zed/settings.json

Deleted
deleted file mode 100644
1 -{
2 - "vim_mode": true,
3 - "buffer_font_size": 18,
4 - "buffer_font_features": {
5 - "calt": true,
6 - "liga": true,
7 - },
8 - "cursor_blink": false,
9 - "hide_mouse": "on_typing_and_movement",
10 - "relative_line_numbers": "enabled",
11 - "scroll_beyond_last_line": "off",
12 - "vertical_scroll_margin": 0,
13 - "horizontal_scroll_margin": 0,
14 - "tab_size": 2,
15 - "hard_tabs": true,
16 - "wrap_guides": [
17 - 80,
18 - 120,
19 - 140
20 - ],
21 - "show_wrap_guides": true,
22 - "show_whitespaces": "trailing",
23 - "inlay_hints": {
24 - "enabled": true,
25 - },
26 - "format_on_save": "on",
27 - "formatter": "language_server",
28 -}