Skip to content

Commit be3c1bd

Browse files
committed
Add --install / --uninstall flags to albert-code.sh
Symlinks albert-code.sh into ~/.local/bin/albert-code so the launcher is callable from any directory while preserving the current working directory as the agent's workdir. The bash flag is processed before the venv bootstrap so the installer runs instantly. A .bat equivalent will follow.
1 parent 9202dc4 commit be3c1bd

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

‎albert-code.sh‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# Usage :
1313
# ./albert-code.sh -> lance albert-code dans le repertoire courant
1414
# ./albert-code.sh --help -> affiche l'aide d'albert-code
15+
# ./albert-code.sh --install -> installe le lien ~/.local/bin/albert-code
16+
# (commande disponible globalement, cwd preserve)
17+
# ./albert-code.sh --uninstall -> retire le lien ~/.local/bin/albert-code
1518
#
1619
# Inspire de albert-cli/albert-cli.sh.
1720
#
@@ -25,6 +28,41 @@ set -euo pipefail
2528
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2629
VENV_DIR="$SCRIPT_DIR/.venv"
2730
PYTHON_BIN="${PYTHON_BIN:-python3}"
31+
SYMLINK_PATH="$HOME/.local/bin/albert-code"
32+
33+
# ---- Sous-commandes d'installation / desinstallation du lien global ----
34+
case "${1:-}" in
35+
--install)
36+
mkdir -p "$(dirname "$SYMLINK_PATH")"
37+
ln -sf "$SCRIPT_DIR/albert-code.sh" "$SYMLINK_PATH"
38+
echo "Lien cree : $SYMLINK_PATH -> $SCRIPT_DIR/albert-code.sh"
39+
case ":$PATH:" in
40+
*":$HOME/.local/bin:"*)
41+
echo "OK : ~/.local/bin est deja dans le PATH."
42+
;;
43+
*)
44+
echo
45+
echo "Note : ~/.local/bin n'est pas dans ton PATH."
46+
echo "Ajoute la ligne suivante a ton ~/.bashrc ou ~/.zshrc :"
47+
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
48+
echo "Puis ouvre un nouveau terminal."
49+
;;
50+
esac
51+
echo
52+
echo "Tu peux maintenant lancer 'albert-code' depuis n'importe quel dossier."
53+
echo "Le repertoire courant est utilise comme dossier de travail."
54+
exit 0
55+
;;
56+
--uninstall)
57+
if [ -L "$SYMLINK_PATH" ] || [ -e "$SYMLINK_PATH" ]; then
58+
rm -f "$SYMLINK_PATH"
59+
echo "Lien supprime : $SYMLINK_PATH"
60+
else
61+
echo "Aucun lien trouve a $SYMLINK_PATH (deja desinstalle)."
62+
fi
63+
exit 0
64+
;;
65+
esac
2866

2967
# Verifier que python3 est disponible
3068
if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then

0 commit comments

Comments
 (0)