Add zellij agent helpers
This commit is contained in:
24
dotfiles/config/zellij/config.kdl
Normal file
24
dotfiles/config/zellij/config.kdl
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
keybinds {
|
||||||
|
// Keep Ctrl-p available for readline/history/up in shells and editors.
|
||||||
|
unbind "Ctrl p"
|
||||||
|
|
||||||
|
shared_except "locked" "pane" {
|
||||||
|
bind "Ctrl Space" { SwitchToMode "Pane"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
pane {
|
||||||
|
bind "Ctrl Space" { SwitchToMode "Normal"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
tmux {
|
||||||
|
// Ctrl-b C: start a Codex pane from the current zellij tab.
|
||||||
|
bind "C" {
|
||||||
|
Run "codex" "--dangerously-bypass-approvals-and-sandbox" {
|
||||||
|
name "codex"
|
||||||
|
}
|
||||||
|
SwitchToMode "Normal"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default_mode "locked"
|
||||||
7
dotfiles/lib/functions/zclaude
Normal file
7
dotfiles/lib/functions/zclaude
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
function zclaude {
|
||||||
|
ZRW_NAME=claude zrw claude --dangerously-skip-permissions "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
zclaude "$@"
|
||||||
23
dotfiles/lib/functions/zcodex
Normal file
23
dotfiles/lib/functions/zcodex
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
function zcodex {
|
||||||
|
# Record launch directories so rofi_tmcodex can offer good defaults.
|
||||||
|
state_dir="${XDG_STATE_HOME:-$HOME/.local/state}/rofi-tmcodex"
|
||||||
|
history_file="$state_dir/dirs"
|
||||||
|
mkdir -p "$state_dir" 2>/dev/null || true
|
||||||
|
if [ -d "$PWD" ]; then
|
||||||
|
tmp="$(mktemp 2>/dev/null || true)"
|
||||||
|
if [ -n "$tmp" ]; then
|
||||||
|
{ printf '%s\n' "$PWD"; cat "$history_file" 2>/dev/null || true; } \
|
||||||
|
| awk 'NF && !seen[$0]++' \
|
||||||
|
| head -n 200 >"$tmp" 2>/dev/null || true
|
||||||
|
mv -f "$tmp" "$history_file" 2>/dev/null || true
|
||||||
|
else
|
||||||
|
printf '%s\n' "$PWD" >>"$history_file" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
ZRW_NAME=codex zrw codex --dangerously-bypass-approvals-and-sandbox "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
zcodex "$@"
|
||||||
59
dotfiles/lib/functions/zrw
Normal file
59
dotfiles/lib/functions/zrw
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
function _zrw_kdl_quote {
|
||||||
|
printf '"'
|
||||||
|
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
|
||||||
|
printf '"'
|
||||||
|
}
|
||||||
|
|
||||||
|
function _zrw_layout_string {
|
||||||
|
command="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
printf 'layout {\n'
|
||||||
|
printf ' pane command='
|
||||||
|
_zrw_kdl_quote "$command"
|
||||||
|
printf ' name='
|
||||||
|
_zrw_kdl_quote "${ZRW_NAME:-$(basename -- "$command")}"
|
||||||
|
printf ' cwd='
|
||||||
|
_zrw_kdl_quote "$PWD"
|
||||||
|
if [ "$#" -eq 0 ]; then
|
||||||
|
printf '\n'
|
||||||
|
else
|
||||||
|
printf ' {\n'
|
||||||
|
printf ' args'
|
||||||
|
for arg in "$@"; do
|
||||||
|
printf ' '
|
||||||
|
_zrw_kdl_quote "$arg"
|
||||||
|
done
|
||||||
|
printf '\n'
|
||||||
|
printf ' }\n'
|
||||||
|
fi
|
||||||
|
printf '}\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
function _zrw_session_name {
|
||||||
|
command_name="$(basename -- "$1")"
|
||||||
|
base="$(basename -- "$PWD")"
|
||||||
|
ck="$(printf '%s' "$PWD" | cksum | awk '{print $1}')"
|
||||||
|
session="${ZRW_SESSION:-${command_name}-${base}-${ck}}"
|
||||||
|
printf '%s' "$session" | tr -cs 'A-Za-z0-9_-' '-' | sed 's/^-//;s/-$//'
|
||||||
|
}
|
||||||
|
|
||||||
|
function zrw {
|
||||||
|
if [ "$#" -eq 0 ]; then
|
||||||
|
echo "Usage: zrw COMMAND [ARG ...]" >&2
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
tab_name="${ZRW_NAME:-$(basename -- "$1")}"
|
||||||
|
if [ -n "$ZELLIJ" ]; then
|
||||||
|
zellij action new-tab --cwd "$PWD" --name "$tab_name" -- "$@"
|
||||||
|
else
|
||||||
|
session="$(_zrw_session_name "$1")"
|
||||||
|
layout="$(_zrw_layout_string "$@")"
|
||||||
|
zellij --session "$session" --layout-string "$layout"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
zrw "$@"
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
--passphrase-file "$passphrase_path" \
|
--passphrase-file "$passphrase_path" \
|
||||||
--import "$normalized_key_file"
|
--import "$normalized_key_file"
|
||||||
'';
|
'';
|
||||||
|
multiplexerAliases = import ../../shared/multiplexer-aliases.nix;
|
||||||
|
|
||||||
excludedTopLevelEntries = [
|
excludedTopLevelEntries = [
|
||||||
"config"
|
"config"
|
||||||
@@ -228,9 +229,7 @@ in {
|
|||||||
};
|
};
|
||||||
shellAliases = {
|
shellAliases = {
|
||||||
df_ssh = "TERM='xterm-256color' ssh -o StrictHostKeyChecking=no";
|
df_ssh = "TERM='xterm-256color' ssh -o StrictHostKeyChecking=no";
|
||||||
ta = "tmux attach";
|
} // multiplexerAliases;
|
||||||
za = "zellij attach";
|
|
||||||
};
|
|
||||||
initContent = lib.mkMerge [
|
initContent = lib.mkMerge [
|
||||||
(lib.mkOrder 550 ''
|
(lib.mkOrder 550 ''
|
||||||
fpath+="${libDir}/functions"
|
fpath+="${libDir}/functions"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ let
|
|||||||
++ (map (machineName: "${machineName}.local") machineNames)
|
++ (map (machineName: "${machineName}.local") machineNames)
|
||||||
++ extraManagedSshHosts;
|
++ extraManagedSshHosts;
|
||||||
managedSshHostCasePattern = lib.concatStringsSep "|" managedSshHostPatterns;
|
managedSshHostCasePattern = lib.concatStringsSep "|" managedSshHostPatterns;
|
||||||
|
multiplexerAliases = import ../shared/multiplexer-aliases.nix;
|
||||||
in
|
in
|
||||||
with lib;
|
with lib;
|
||||||
{
|
{
|
||||||
@@ -81,9 +82,7 @@ with lib;
|
|||||||
shellAliases = {
|
shellAliases = {
|
||||||
df_ssh = "TERM=xterm-256color ssh -o StrictHostKeyChecking=no";
|
df_ssh = "TERM=xterm-256color ssh -o StrictHostKeyChecking=no";
|
||||||
fix_nix = "LD_LIBRARY_PATH='' nix";
|
fix_nix = "LD_LIBRARY_PATH='' nix";
|
||||||
ta = "tmux attach";
|
} // multiplexerAliases;
|
||||||
za = "zellij attach";
|
|
||||||
};
|
|
||||||
variables = {
|
variables = {
|
||||||
ROFI_SYSTEMD_TERM = "ghostty -e";
|
ROFI_SYSTEMD_TERM = "ghostty -e";
|
||||||
NIXPKGS_GIT_REV = "${inputs.nixpkgs.rev}";
|
NIXPKGS_GIT_REV = "${inputs.nixpkgs.rev}";
|
||||||
|
|||||||
4
nixos/flake.lock
generated
4
nixos/flake.lock
generated
@@ -1548,8 +1548,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1777078756,
|
"lastModified": 1777148012,
|
||||||
"narHash": "sha256-514PXbaRust8FYqpArC2ar1Y2pyBrQOhWrL8EHbhJYs=",
|
"narHash": "sha256-ExYOcgFOu8yTU00ZvZC0QLLuigaest/zhc3ecJsXnfs=",
|
||||||
"path": "/home/imalison/Projects/keepbook",
|
"path": "/home/imalison/Projects/keepbook",
|
||||||
"type": "path"
|
"type": "path"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ in {
|
|||||||
static_history = []
|
static_history = []
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
xdg.configFile."zellij/config.kdl".source =
|
||||||
|
config.lib.file.mkOutOfStoreSymlink
|
||||||
|
"${config.home.homeDirectory}/dotfiles/dotfiles/config/zellij/config.kdl";
|
||||||
|
|
||||||
xdg.mimeApps = lib.mkIf nixos.config.myModules.desktop.enable (
|
xdg.mimeApps = lib.mkIf nixos.config.myModules.desktop.enable (
|
||||||
let
|
let
|
||||||
browser = "google-chrome.desktop";
|
browser = "google-chrome.desktop";
|
||||||
|
|||||||
4
shared/multiplexer-aliases.nix
Normal file
4
shared/multiplexer-aliases.nix
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
ta = "tmux attach";
|
||||||
|
za = "zellij attach";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user