Files
claude-app-builder-4-mac/make-ghostty-app.sh
T
marcus.hinz 401ddd6f98 Ghostty-per-Projekt-Builder: Template + make/rebuild-Skripte
- ghostty-template/Ghostty.app: lokal gebautes Ghostty v1.3.1 mit DockTilePlugin-Patch
  (eigenes Dock-Icon ueber Contents/Resources/DockIcon.png)
- make-ghostty-app.sh: erzeugt pro Projekt eine App; Slots fuer
  icon/workdir/command/theme/bg/fg/font/font-size
- rebuild-template.sh: baut Template lokal neu (nur Xcode, kein Zig/VM),
  gepinnt auf vendor/libghostty v1.3.1
- ghostty-template/dock-icon.patch: der DockTilePlugin-Patch
- icons/robotunits.png
- enthaelt zudem die vorausgehende MiniTerm/libghostty-Integration
2026-06-24 18:50:53 +02:00

112 lines
3.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Erzeugt aus dem gepatchten Ghostty-Template eine eigenständige, pro-Projekt
# konfigurierte macOS-App: eigene Bundle-ID (eigenes Dock-Icon + ⌘-Tab),
# eigenes Icon, eigene Ghostty-Config (working-directory, command, Farben, Font).
#
# Beispiel:
# ./make-ghostty-app.sh misc \
# --icon ~/claude-projects/misc/misc-icon.png \
# --workdir ~/claude-projects/misc \
# --command ~/.local/bin/claude \
# --bg 2b0a3d --fg ffd000 --font "Courier New" --font-size 18
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEMPLATE="$SCRIPT_DIR/ghostty-template/Ghostty.app"
PB=/usr/libexec/PlistBuddy
# --- Defaults ---
NAME=""
BUNDLE_ID=""
ICON=""
WORKDIR=""
COMMAND_LINE=""
THEME=""
BG=""
FG=""
FONT=""
FONT_SIZE=""
OUT_DIR="$HOME/Applications"
CFG_BASE="$HOME/.config-ghostty"
usage() { grep '^#' "$0" | sed 's/^# \?//'; exit 1; }
[[ $# -ge 1 ]] || usage
NAME="$1"; shift
while [[ $# -gt 0 ]]; do
case "$1" in
--id) BUNDLE_ID="$2"; shift 2;;
--icon) ICON="$2"; shift 2;;
--workdir) WORKDIR="$2"; shift 2;;
--command) COMMAND_LINE="$2"; shift 2;;
--theme) THEME="$2"; shift 2;;
--bg) BG="$2"; shift 2;;
--fg) FG="$2"; shift 2;;
--font) FONT="$2"; shift 2;;
--font-size) FONT_SIZE="$2"; shift 2;;
--out) OUT_DIR="$2"; shift 2;;
*) echo "Unbekannte Option: $1" >&2; usage;;
esac
done
[[ -d "$TEMPLATE" ]] || { echo "Template fehlt: $TEMPLATE (erst rebuild-template.sh laufen lassen)" >&2; exit 1; }
: "${BUNDLE_ID:=com.mitchellh.ghostty.$NAME}"
APP="$OUT_DIR/Ghostty-$NAME.app"
CFG="$CFG_BASE/$NAME"
# Pfade expandieren (~)
WORKDIR="${WORKDIR/#\~/$HOME}"
ICON="${ICON/#\~/$HOME}"
COMMAND_LINE="${COMMAND_LINE/#\~/$HOME}"
echo ">> Baue $APP (id=$BUNDLE_ID)"
# --- 1. Template kopieren ---
mkdir -p "$OUT_DIR"
pkill -9 -f "$APP/Contents/MacOS" 2>/dev/null || true
sleep 1
rm -rf "$APP"
cp -R "$TEMPLATE" "$APP"
# --- 2. Icon (PNG -> .icns für statisch + PNG fürs Dock-Tile) ---
if [[ -n "$ICON" ]]; then
[[ -f "$ICON" ]] || { echo "Icon nicht gefunden: $ICON" >&2; exit 1; }
TMP_ISET="$(mktemp -d)/icon.iconset"; mkdir -p "$TMP_ISET"
for s in 16 32 128 256 512; do
sips -z $s $s "$ICON" --out "$TMP_ISET/icon_${s}x${s}.png" >/dev/null
sips -z $((s*2)) $((s*2)) "$ICON" --out "$TMP_ISET/icon_${s}x${s}@2x.png" >/dev/null
done
iconutil -c icns "$TMP_ISET" -o "$APP/Contents/Resources/Ghostty.icns"
cp "$ICON" "$APP/Contents/Resources/DockIcon.png" # laufendes Dock-Tile (Plugin-Patch)
rm -rf "$(dirname "$TMP_ISET")"
fi
# --- 3. Info.plist: Identität + Config-Pfad ---
PL="$APP/Contents/Info.plist"
$PB -c "Set :CFBundleIdentifier $BUNDLE_ID" "$PL"
$PB -c "Set :CFBundleName Ghostty-$NAME" "$PL" 2>/dev/null || $PB -c "Add :CFBundleName string Ghostty-$NAME" "$PL"
$PB -c "Delete :CFBundleIconName" "$PL" 2>/dev/null || true # sonst gewinnt Assets.car (Geist)
$PB -c "Delete :LSEnvironment" "$PL" 2>/dev/null || true
$PB -c "Add :LSEnvironment dict" "$PL"
$PB -c "Add :LSEnvironment:XDG_CONFIG_HOME string $CFG" "$PL"
# --- 4. Ghostty-Config schreiben ---
mkdir -p "$CFG/ghostty"
{
[[ -n "$WORKDIR" ]] && echo "working-directory = $WORKDIR"
[[ -n "$COMMAND_LINE" ]] && echo "command = $COMMAND_LINE"
[[ -n "$COMMAND_LINE" ]] && echo "wait-after-command = true"
[[ -n "$THEME" ]] && echo "theme = $THEME"
[[ -n "$BG" ]] && echo "background = $BG"
[[ -n "$FG" ]] && echo "foreground = $FG"
[[ -n "$FONT" ]] && echo "font-family = $FONT"
[[ -n "$FONT_SIZE" ]] && echo "font-size = $FONT_SIZE"
} > "$CFG/ghostty/config"
# --- 5. ad-hoc signieren ---
codesign --force --deep --sign - "$APP" >/dev/null
echo ">> Fertig: $APP"
echo " Config: $CFG/ghostty/config"
echo " Starten: open -n \"$APP\""