Something went wrong. Try again.
Monorepo for Aesthetic.Computer aesthetic.computer
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667#!/usr/bin/env bash
set -euo pipefail
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"# AESEL_* first; EASEL_* is the same setting under the old name.BIN_DIR="${AESEL_BIN_DIR:-${EASEL_BIN_DIR:-${HOME}/.local/bin}}"CONFIG_DIR="${AESEL_CONFIG_DIR:-${EASEL_CONFIG_DIR:-${HOME}/.config/aesel}}"FISH_CONFIG="${XDG_CONFIG_HOME:-${HOME}/.config}/fish/config.fish"ZSH_PROFILE="${ZDOTDIR:-${HOME}}/.zprofile"
# The same move src/paths.mjs makes: an old ~/.config/easel becomes the new# folder, with a link left where it was for any older copy still reading it.# Creating an empty ~/.config/aesel first would strand the old settings.OLD_CONFIG="${HOME}/.config/easel"if [[ "$CONFIG_DIR" == "${HOME}/.config/aesel" && ! -e "$CONFIG_DIR" && -d "$OLD_CONFIG" && ! -L "$OLD_CONFIG" ]]; then mv "$OLD_CONFIG" "$CONFIG_DIR" && ln -s "$CONFIG_DIR" "$OLD_CONFIG"fimkdir -p "$BIN_DIR" "$CONFIG_DIR"chmod +x "$PROJECT_DIR/bin/"{easel,aesel,easel-desktop,a,aes}ln -sfn "$PROJECT_DIR/bin/easel" "$BIN_DIR/easel"ln -sfn "$PROJECT_DIR/bin/aesel" "$BIN_DIR/aesel"ln -sfn "$PROJECT_DIR/bin/a" "$BIN_DIR/a"ln -sfn "$PROJECT_DIR/bin/aes" "$BIN_DIR/aes"ln -sfn "$PROJECT_DIR/bin/easel" "$BIN_DIR/ac"
# The tool was called `aesthetic` before it was called Aesel, and that name# belongs to the platform helper it displaced. Take it back only if it is still# our own symlink — never touch a real file someone else put there.if [[ -L "$BIN_DIR/aesthetic" ]] && [[ "$(readlink "$BIN_DIR/aesthetic")" == *"/bin/aesthetic" || "$(readlink "$BIN_DIR/aesthetic")" == *"/bin/easel" ]]; then rm -f "$BIN_DIR/aesthetic"fi
# The tool shipped as Aesthetic Code first, and its Fish block named that path.# The block is inert once the path is gone — `test -f` simply fails — but it# lingers on every machine that ever installed the old name, so take it out.if [[ -f "$FISH_CONFIG" ]] && grep -Fq '# aesthetic-code:start' "$FISH_CONFIG"; then /usr/bin/sed -i '' '/# aesthetic-code:start/,/# aesthetic-code:end/d' "$FISH_CONFIG"fi
if [[ -f "$FISH_CONFIG" ]] && ! grep -Fq '# easel:start' "$FISH_CONFIG"; then { printf '\n# easel:start\n' printf 'if test -f %q\n' "$PROJECT_DIR/shell/aesel.fish" printf ' source %q\n' "$PROJECT_DIR/shell/aesel.fish" printf 'end\n' printf '# easel:end\n' } >> "$FISH_CONFIG"fi
if [[ -f "$ZSH_PROFILE" ]] && ! grep -Fq '# easel:path:start' "$ZSH_PROFILE"; then { printf '\n# easel:path:start\n' printf 'export PATH="$HOME/.local/bin:$PATH"\n' printf '# easel:path:end\n' } >> "$ZSH_PROFILE"fi
case ":${PATH}:" in *":${BIN_DIR}:"*) ;; *) printf 'Add %s to PATH to use the commands.\n' "$BIN_DIR" >&2 ;;esac
printf 'Installed Aesel:\n'printf ' %s\n' "$BIN_DIR/ac"printf ' %s\n' "$BIN_DIR/easel"