rename: myclaude -> myagents
This commit is contained in:
@@ -1,46 +1,64 @@
|
||||
#!/bin/bash
|
||||
# Install shell completions for myclaude to user directory only
|
||||
# Usage: install_completion.sh <venv_myclaude_path> <comp_dir>
|
||||
# Install shell completions for myagents, myclaude, mykimi to user directory only
|
||||
# Usage: install_completion.sh <venv_bin_dir> <comp_dir>
|
||||
|
||||
VENV_MYCLAUDE="$1"
|
||||
VENV_BIN_DIR="$1"
|
||||
COMP_DIR="$2"
|
||||
|
||||
if [[ -z "$VENV_MYCLAUDE" || -z "$COMP_DIR" ]]; then
|
||||
echo "Usage: $0 <venv_myclaude_path> <comp_dir>" >&2
|
||||
if [[ -z "$VENV_BIN_DIR" || -z "$COMP_DIR" ]]; then
|
||||
echo "Usage: $0 <venv_bin_dir> <comp_dir>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
USER_SHELL=$(basename "$SHELL")
|
||||
|
||||
# Portable uppercase helper (macOS bash 3.2 lacks ${var^^}).
|
||||
_upcase() {
|
||||
printf '%s' "$1" | tr '[:lower:]' '[:upper:]'
|
||||
}
|
||||
|
||||
install_zsh_completion() {
|
||||
local cmd="$1"
|
||||
local out="$2"
|
||||
local var="_$(_upcase "$cmd")_COMPLETE"
|
||||
mkdir -p "$COMP_DIR" 2>/dev/null || { echo "Error: cannot create $COMP_DIR" >&2; return 1; }
|
||||
if _MYCLAUDE_COMPLETE=zsh_source "$VENV_MYCLAUDE" > "$COMP_DIR/_myclaude" 2>/dev/null; then
|
||||
echo "Installed zsh completion: $COMP_DIR/_myclaude"
|
||||
if eval "$var=zsh_source ${VENV_BIN_DIR}/${cmd}" > "$out" 2>/dev/null; then
|
||||
echo "Installed zsh completion: $out"
|
||||
return 0
|
||||
else
|
||||
echo "Warning: failed to generate zsh completion" >&2
|
||||
echo "Warning: failed to generate zsh completion for $cmd" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_bash_completion() {
|
||||
local cmd="$1"
|
||||
local out="$2"
|
||||
local var="_$(_upcase "$cmd")_COMPLETE"
|
||||
mkdir -p "$COMP_DIR" 2>/dev/null || { echo "Error: cannot create $COMP_DIR" >&2; return 1; }
|
||||
if _MYCLAUDE_COMPLETE=bash_source "$VENV_MYCLAUDE" > "$COMP_DIR/myclaude.bash" 2>/dev/null; then
|
||||
echo "Installed bash completion: $COMP_DIR/myclaude.bash"
|
||||
if eval "$var=bash_source ${VENV_BIN_DIR}/${cmd}" > "$out" 2>/dev/null; then
|
||||
echo "Installed bash completion: $out"
|
||||
return 0
|
||||
else
|
||||
echo "Warning: failed to generate bash completion" >&2
|
||||
echo "Warning: failed to generate bash completion for $cmd" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$USER_SHELL" == "zsh" ]]; then
|
||||
install_zsh_completion
|
||||
install_zsh_completion myagents "$COMP_DIR/_myagents"
|
||||
install_zsh_completion myclaude "$COMP_DIR/_myclaude"
|
||||
install_zsh_completion mykimi "$COMP_DIR/_mykimi"
|
||||
elif [[ "$USER_SHELL" == "bash" ]]; then
|
||||
install_bash_completion
|
||||
install_bash_completion myagents "$COMP_DIR/myagents.bash"
|
||||
install_bash_completion myclaude "$COMP_DIR/myclaude.bash"
|
||||
install_bash_completion mykimi "$COMP_DIR/mykimi.bash"
|
||||
else
|
||||
echo "Shell '$USER_SHELL' is not supported for automatic completion installation."
|
||||
echo "To install completions manually, run one of the following commands:"
|
||||
echo " zsh: _MYCLAUDE_COMPLETE=zsh_source $VENV_MYCLAUDE > /path/to/completions/_myclaude"
|
||||
echo " bash: _MYCLAUDE_COMPLETE=bash_source $VENV_MYCLAUDE > /path/to/completions/myclaude.bash"
|
||||
for cmd in myagents myclaude mykimi; do
|
||||
var="_$(_upcase "$cmd")_COMPLETE"
|
||||
echo " zsh: $var=zsh_source ${VENV_BIN_DIR}/${cmd} > /path/to/completions/_${cmd}"
|
||||
echo " bash: $var=bash_source ${VENV_BIN_DIR}/${cmd} > /path/to/completions/${cmd}.bash"
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Remove ~/.local/bin/{myagents,myclaude,mykimi} symlinks to this repo's venv."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
_COMMANDS = ("myagents", "myclaude", "mykimi")
|
||||
|
||||
|
||||
def _remove_link(link: str, want: str) -> bool:
|
||||
"""Remove link if it is a symlink pointing to want. Returns True if removed."""
|
||||
if not os.path.islink(link):
|
||||
return False
|
||||
|
||||
target = os.readlink(link)
|
||||
if not os.path.isabs(target):
|
||||
target = os.path.join(os.path.dirname(link), target)
|
||||
target = os.path.normpath(target)
|
||||
|
||||
if target == want:
|
||||
os.unlink(link)
|
||||
print("Removed", link)
|
||||
return True
|
||||
|
||||
print("Skip:", link, "points to", target, "(not this repo's", want + ")")
|
||||
return False
|
||||
|
||||
|
||||
def main() -> int:
|
||||
root = os.path.normpath(os.environ.get("ROOT_DIR", os.getcwd()))
|
||||
bin_dir = os.path.expanduser("~/.local/bin")
|
||||
removed = 0
|
||||
skipped = 0
|
||||
|
||||
for command in _COMMANDS:
|
||||
want = os.path.normpath(os.path.join(root, ".venv", "bin", command))
|
||||
link = os.path.join(bin_dir, command)
|
||||
if _remove_link(link, want):
|
||||
removed += 1
|
||||
elif os.path.lexists(link):
|
||||
print("Skip:", link, "is not a symlink, leaving untouched")
|
||||
skipped += 1
|
||||
|
||||
if removed == 0 and skipped == 0:
|
||||
print("Nothing to remove")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Remove ~/.local/bin/myclaude if it is a symlink to this repo's .venv/bin/myclaude."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> int:
|
||||
root = os.path.normpath(os.environ.get("ROOT_DIR", os.getcwd()))
|
||||
link = os.path.expanduser("~/.local/bin/myclaude")
|
||||
want = os.path.normpath(os.path.join(root, ".venv", "bin", "myclaude"))
|
||||
|
||||
if not os.path.islink(link):
|
||||
if os.path.lexists(link):
|
||||
print("Skip: not a symlink, leaving untouched")
|
||||
else:
|
||||
print("Nothing to remove")
|
||||
return 0
|
||||
|
||||
target = os.readlink(link)
|
||||
if not os.path.isabs(target):
|
||||
target = os.path.join(os.path.dirname(link), target)
|
||||
target = os.path.normpath(target)
|
||||
|
||||
if target == want:
|
||||
os.unlink(link)
|
||||
print("Removed", link)
|
||||
return 0
|
||||
|
||||
print("Skip: points to", target, "(not this repo's", want + ")")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user