Replace codex_tmux with generic trw, tmclaude, tmcodex helpers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
function codex_tmux {
|
|
||||||
base=$(basename "$PWD")
|
|
||||||
name="$base"
|
|
||||||
if tmux has-session -t "$name" 2>/dev/null; then
|
|
||||||
i=2
|
|
||||||
while tmux has-session -t "${name}-${i}" 2>/dev/null; do
|
|
||||||
i=$((i+1))
|
|
||||||
done
|
|
||||||
name="${name}-${i}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
tmux new-session -s "$name" -c "$PWD" codex --dangerously-bypass-approvals-and-sandbox "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
codex_tmux "$@"
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
function codex_tmux_resume {
|
|
||||||
base=$(basename "$PWD")
|
|
||||||
target=$(tmux list-sessions -F '#S' 2>/dev/null | awk -v base="$base" '
|
|
||||||
$0 == base { print; found=1; exit }
|
|
||||||
{
|
|
||||||
prefix = base "-"
|
|
||||||
if (substr($0, 1, length(prefix)) == prefix) {
|
|
||||||
rest = substr($0, length(prefix) + 1)
|
|
||||||
if (rest ~ /^[0-9]+$/) {
|
|
||||||
n = rest + 0
|
|
||||||
if (n > max) { max = n; best = $0 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
END { if (found != 1 && best != "") print best }
|
|
||||||
')
|
|
||||||
|
|
||||||
if [ -n "$target" ]; then
|
|
||||||
if [ -n "$TMUX" ]; then
|
|
||||||
tmux switch-client -t "$target"
|
|
||||||
else
|
|
||||||
tmux attach-session -t "$target"
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
codex_tmux "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
codex_tmux_resume "$@"
|
|
||||||
7
dotfiles/lib/functions/tmclaude
Normal file
7
dotfiles/lib/functions/tmclaude
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
function tmclaude {
|
||||||
|
trw claude "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
tmclaude "$@"
|
||||||
7
dotfiles/lib/functions/tmcodex
Normal file
7
dotfiles/lib/functions/tmcodex
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
function tmcodex {
|
||||||
|
trw codex --dangerously-bypass-approvals-and-sandbox "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
tmcodex "$@"
|
||||||
7
dotfiles/lib/functions/trw
Normal file
7
dotfiles/lib/functions/trw
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
function trw {
|
||||||
|
tmux new-session -c "$PWD" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
trw "$@"
|
||||||
Reference in New Issue
Block a user