2026-05-29 08:19:50 +00:00
#!/usr/bin/env fish
# deploy.fish – Copilot-Setup auf Linux mit fish-Shell deployen
2026-06-10 10:26:55 +02:00
# Usage:
# fish scripts/deploy.fish # Standard-Deploy (nicht-invasiv)
# fish scripts/deploy.fish --with-self-update-hook # + post-merge Auto-Deploy im Setup-Repo
#
# Hinweis: Setzt KEINEN globalen 'git init'-Alias und KEIN init.templateDir.
# Standard-'git init'/'git clone' bleiben unberuehrt. Opt-in: 'git init-copilot'.
set WITH_SELF_HOOK 0
for arg in $argv
switch $arg
case --with-self-update-hook
set WITH_SELF_HOOK 1
case '*'
echo " Unbekanntes Argument: $arg " > & 2
exit 2
end
end
2026-05-29 08:19:50 +00:00
set REPO_DIR ( dirname ( status filename) ) /..
set REPO_DIR ( realpath $REPO_DIR )
echo "=== Copilot Setup Deploy (Linux/fish) ==="
echo " Source: $REPO_DIR "
2026-06-10 10:26:55 +02:00
# VS Code User-Verzeichnis portabel ueber Editionen/OS ermitteln (identisch zu copilot-update.fish)
function detect_vscode_user_dir
for d in \
" $HOME /.vscode-server/data/User " \
" $HOME /.vscode-server-insiders/data/User " \
" $HOME /Library/Application Support/Code/User " \
" $HOME /Library/Application Support/Code - Insiders/User " \
" $HOME /Library/Application Support/VSCodium/User " \
" $HOME /Library/Application Support/Cursor/User " \
" $HOME /.config/Code/User " \
" $HOME /.config/Code - Insiders/User " \
" $HOME /.config/VSCodium/User " \
" $HOME /.config/Cursor/User " \
" $HOME /.var/app/com.visualstudio.code/config/Code/User " \
" /mnt/c/Users/ $USER /AppData/Roaming/Code/User " \
" /mnt/c/Users/ $USER /AppData/Roaming/Code - Insiders/User "
if test -d " $d "
echo $d
return 0
end
end
switch ( uname -s )
case Darwin
echo " $HOME /Library/Application Support/Code/User "
case '*'
echo " $HOME /.config/Code/User "
end
2026-05-29 08:19:50 +00:00
end
2026-06-10 10:26:55 +02:00
# ── 1. VS Code User-Verzeichnis ermitteln ─────────────────────────────────────
set VSCODE_USER ( detect_vscode_user_dir )
2026-05-29 08:19:50 +00:00
echo " VS Code User dir: $VSCODE_USER "
# ── 2. User settings.json mergen / anlegen ────────────────────────────────────
if test -f $VSCODE_USER /settings.json
echo " ─ settings.json exists – skipping (merge manually if needed)"
echo " Reference: $REPO_DIR /user-settings/settings.json "
else
mkdir -p $VSCODE_USER
cp $REPO_DIR /user-settings/settings.json $VSCODE_USER /settings.json
echo " ✓ settings.json deployed"
end
# ── 3. Prompt Files ───────────────────────────────────────────────────────────
mkdir -p $VSCODE_USER /prompts
for f in $REPO_DIR /prompts/*.prompt.md
set fname ( basename $f )
if test -f $VSCODE_USER /prompts/$fname
echo " ─ prompts/ $fname already exists, skipping "
else
cp $f $VSCODE_USER /prompts/$fname
echo " ✓ prompts/ $fname deployed "
end
end
# ── 4. Git-Templates ──────────────────────────────────────────────────────────
set GIT_TEMPLATE_DIR $HOME /.git-templates
2026-05-30 17:19:52 +00:00
mkdir -p $GIT_TEMPLATE_DIR /.github $GIT_TEMPLATE_DIR /.vscode \
$GIT_TEMPLATE_DIR /hooks $GIT_TEMPLATE_DIR /docs \
$GIT_TEMPLATE_DIR /history /summary
2026-05-29 08:19:50 +00:00
cp $REPO_DIR /git-templates/.github/copilot-instructions.md $GIT_TEMPLATE_DIR /.github/
cp $REPO_DIR /git-templates/.vscode/settings.json $GIT_TEMPLATE_DIR /.vscode/
cp $REPO_DIR /git-templates/.vscode/extensions.json $GIT_TEMPLATE_DIR /.vscode/
2026-05-30 17:19:52 +00:00
cp $REPO_DIR /git-templates/hooks/pre-commit $GIT_TEMPLATE_DIR /hooks/
chmod +x $GIT_TEMPLATE_DIR /hooks/pre-commit
cp $REPO_DIR /git-templates/docs/USER.md $GIT_TEMPLATE_DIR /docs/
cp $REPO_DIR /git-templates/docs/ADMIN.md $GIT_TEMPLATE_DIR /docs/
cp $REPO_DIR /git-templates/docs/MAINTAINER.md $GIT_TEMPLATE_DIR /docs/
cp $REPO_DIR /git-templates/history /summary/PROJECT_CONTEXT.md $GIT_TEMPLATE_DIR /history /summary/
2026-05-29 08:19:50 +00:00
echo " ✓ git-templates deployed → $GIT_TEMPLATE_DIR "
2026-06-10 10:26:55 +02:00
# init.templateDir bewusst NICHT global setzen (sonst erbt jeder git init/clone den Gate).
set CURRENT_TPL ( git config --global --get init.templateDir 2 > /dev/null)
if test " $CURRENT_TPL " = " $GIT_TEMPLATE_DIR "
git config --global --unset init .templateDir
echo " ✓ altes globales init.templateDir entfernt (nicht mehr invasiv)"
else
echo " ─ init.templateDir nicht global gesetzt (gewollt)"
end
2026-05-29 08:19:50 +00:00
2026-06-02 10:36:16 +00:00
# ── 5. Bootstrap- & Update-Skripte ───────────────────────────────────────────
2026-05-29 08:19:50 +00:00
mkdir -p $HOME /.local/bin
2026-05-30 17:19:52 +00:00
cp $REPO_DIR /scripts/copilot-bootstrap.sh $HOME /.local/bin/copilot-bootstrap.sh
chmod +x $HOME /.local/bin/copilot-bootstrap.sh
echo " ✓ copilot-bootstrap.sh installed to ~/.local/bin/"
2026-05-29 08:19:50 +00:00
cp $REPO_DIR /scripts/copilot-bootstrap.fish $HOME /.local/bin/copilot-bootstrap.fish
chmod +x $HOME /.local/bin/copilot-bootstrap.fish
echo " ✓ copilot-bootstrap.fish installed to ~/.local/bin/"
2026-06-02 10:36:16 +00:00
cp $REPO_DIR /scripts/copilot-update.sh $HOME /.local/bin/copilot-update.sh
chmod +x $HOME /.local/bin/copilot-update.sh
echo " ✓ copilot-update.sh installed to ~/.local/bin/"
if test -f $REPO_DIR /scripts/copilot-update.fish
cp $REPO_DIR /scripts/copilot-update.fish $HOME /.local/bin/copilot-update.fish
chmod +x $HOME /.local/bin/copilot-update.fish
echo " ✓ copilot-update.fish installed to ~/.local/bin/"
end
2026-05-29 08:19:50 +00:00
2026-06-02 10:36:16 +00:00
# ── 6. Git-Aliase: init → auto-bootstrap | copilot-update → updater ──────────
2026-05-30 17:19:52 +00:00
# Verwendet git --exec-path um Rekursion zu vermeiden (kein Alias-Loop).
2026-06-10 10:26:55 +02:00
# Kein Override des Standard-'git init' mehr. Frueheren invasiven Alias entfernen.
set CURRENT_INIT_ALIAS ( git config --global --get alias.init 2 > /dev/null)
if string match -q '*copilot-bootstrap*' -- " $CURRENT_INIT_ALIAS "
git config --global --unset alias .init
echo " ✓ alter invasiver 'git init'-Alias entfernt"
end
# Opt-in: explizites 'git init-copilot' macht git init + bootstrap.
git config --global alias.init-copilot '!f() { dir=.; for a in "$@"; do case "$a" in -*) ;; *) dir="$a" ;; esac; done; "$(git --exec-path)/git-init" "$@" && "$HOME/.local/bin/copilot-bootstrap.sh" "$dir"; }; f'
echo " ✓ git alias 'init-copilot' gesetzt (opt-in: git init + copilot-bootstrap)"
2026-06-02 10:36:16 +00:00
git config --global alias.copilot-update '!~/.local/bin/copilot-update.sh'
echo " ✓ git alias 'copilot-update' gesetzt (aktualisiert Templates & Prompts)"
2026-06-02 10:41:28 +00:00
# ── 7. post-merge + post-commit Hook für dieses Setup-Repo ───────────────────
2026-06-02 10:36:16 +00:00
set SELF_HOOKS_DIR $REPO_DIR /.git/hooks
2026-06-10 10:26:55 +02:00
if test $WITH_SELF_HOOK -eq 1
if test -d $SELF_HOOKS_DIR
echo '#!/usr/bin/env sh
2026-06-02 10:36:16 +00:00
# post-merge – Auto-Deploy nach git pull auf dem Setup-Repo
echo ""
echo " [post-merge] Setup-Repo aktualisiert – deploye Templates neu..."
SCRIPT_DIR = " $( cd " $( dirname " $0 " ) /../../scripts" && pwd)"
bash " $SCRIPT_DIR /deploy.sh " ' > $SELF_HOOKS_DIR /post-merge
2026-06-10 10:26:55 +02:00
chmod +x $SELF_HOOKS_DIR /post-merge
echo " ✓ post-merge Hook im Setup-Repo installiert (auto-deploy nach git pull)"
end
else
echo " ─ post-merge Auto-Deploy nicht installiert (opt-in: --with-self-update-hook)"
2026-06-02 10:36:16 +00:00
end
2026-05-30 17:19:52 +00:00
2026-05-29 08:19:50 +00:00
echo ""
echo "=== Done ==="
echo "Next: Activate Settings Sync in VS Code (Ctrl+Shift+P → 'Settings Sync: Turn On')"
2026-06-10 10:26:55 +02:00
echo " Neues Repo mit Copilot-Setup: git init-copilot [pfad]"
echo " Bestehendes Repo ausstatten: copilot-bootstrap.sh [pfad]"
echo " Templates aktuell halten: git copilot-update (in jedem Repo)"