diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d438222..6197580 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -28,7 +28,7 @@ archives: formats: - tar.gz name_template: >- - {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }} + {{ .ProjectName }}_{{ .Os }}_{{ .Arch }} checksum: name_template: checksums.txt diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..bf673dc --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,82 @@ +# Install + +The fast path is the install script in the [README](README.md). This file covers the alternatives. + +## Install script options + +The install script accepts a few env-var overrides: + +```bash +# Install to a custom directory (no sudo needed if writable) +TRY_INSTALL_DIR=~/.local/bin curl -fsSL https://raw.githubusercontent.com/hmk/try-bedazzled/main/install.sh | sh + +# Pin to a specific version +TRY_VERSION=v0.1.3 curl -fsSL https://raw.githubusercontent.com/hmk/try-bedazzled/main/install.sh | sh + +# Install the binary but skip editing your shell rc file +TRY_NO_RC_EDIT=1 curl -fsSL https://raw.githubusercontent.com/hmk/try-bedazzled/main/install.sh | sh +``` + +## With Go + +```bash +go install github.com/hmk/try-bedazzled/cmd/try@latest +``` + +Then add the shell function manually (see "Manual shell setup" below). + +## Manual download + +Pick the tarball for your OS/arch from [Releases](https://github.com/hmk/try-bedazzled/releases/latest): + +```bash +# macOS, Apple Silicon +curl -fsSL -o try.tar.gz https://github.com/hmk/try-bedazzled/releases/latest/download/try-bedazzled_darwin_arm64.tar.gz + +# macOS, Intel +curl -fsSL -o try.tar.gz https://github.com/hmk/try-bedazzled/releases/latest/download/try-bedazzled_darwin_amd64.tar.gz + +# Linux, amd64 +curl -fsSL -o try.tar.gz https://github.com/hmk/try-bedazzled/releases/latest/download/try-bedazzled_linux_amd64.tar.gz + +# Linux, arm64 +curl -fsSL -o try.tar.gz https://github.com/hmk/try-bedazzled/releases/latest/download/try-bedazzled_linux_arm64.tar.gz + +tar xzf try.tar.gz +sudo mv try /usr/local/bin/ +``` + +Then add the shell function manually (see "Manual shell setup" below). + +## Debian / RPM packages + +Each release ships `.deb` and `.rpm` packages on the [Releases page](https://github.com/hmk/try-bedazzled/releases/latest). + +```bash +# Debian/Ubuntu +sudo dpkg -i try-bedazzled_linux_amd64.deb + +# RHEL/Fedora +sudo rpm -i try-bedazzled_linux_amd64.rpm +``` + +Then add the shell function manually (see "Manual shell setup" below). + +## Manual shell setup + +`try` needs a shell function wrapper to be able to `cd` your shell into the selected directory. The install script adds it for you; the other paths above don't. + +**bash / zsh** (`.bashrc` or `.zshrc`): +```bash +eval "$(try init)" +``` + +**fish** (`config.fish`): +```fish +try init | source +``` + +Use a custom tries directory: +```bash +eval "$(try init ~/workspace/experiments)" +``` diff --git a/README.md b/README.md index 3801122..7e31fee 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ A Go rewrite of [tobi/try-cli](https://github.com/tobi/try-cli) using [Charmbracelet](https://charm.sh) — the same dated-throwaway-folder workflow, now with shifting cursor hues, rainbow fuzzy hits, -gradient row highlights, and a theme picker that lets you turn the sparkle up to 11 (or off, if -you're a coward). +gradient row highlights, and a theme picker that lets you turn the sparkle up to 11 (or all the way +down to a calm monochrome — every preference welcome). 🦄 ![demo](demo.gif) @@ -33,65 +33,15 @@ Type to filter. Press Enter to `cd`. Type a new name and press Enter to create. ## Install -### With Go - -```bash -go install github.com/hmk/try-bedazzled/cmd/try@latest -``` - -### curl (pre-built binary) - -Pick the tarball for your OS/arch from [Releases](https://github.com/hmk/try-bedazzled/releases/latest): - ```bash -# macOS, Apple Silicon -curl -fsSL -o try.tar.gz https://github.com/hmk/try-bedazzled/releases/latest/download/try-bedazzled_Darwin_arm64.tar.gz - -# macOS, Intel -curl -fsSL -o try.tar.gz https://github.com/hmk/try-bedazzled/releases/latest/download/try-bedazzled_Darwin_amd64.tar.gz - -# Linux, amd64 -curl -fsSL -o try.tar.gz https://github.com/hmk/try-bedazzled/releases/latest/download/try-bedazzled_Linux_amd64.tar.gz - -# Linux, arm64 -curl -fsSL -o try.tar.gz https://github.com/hmk/try-bedazzled/releases/latest/download/try-bedazzled_Linux_arm64.tar.gz - -tar xzf try.tar.gz -sudo mv try /usr/local/bin/ +curl -fsSL https://raw.githubusercontent.com/hmk/try-bedazzled/main/install.sh | sh ``` -> **macOS Gatekeeper**: the published binaries aren't notarized yet. If the -> first run prints "cannot be opened because the developer cannot be -> verified", clear the quarantine flag once: -> -> ```bash -> xattr -d com.apple.quarantine /usr/local/bin/try -> ``` - -### Debian / RPM +Then restart your shell (or `source ~/.zshrc`) and run `try`. -Each release also ships `.deb` and `.rpm` packages on the Releases page. +The installer downloads the latest release for your platform, drops the binary in `/usr/local/bin/`, and adds the shell function to your rc file. macOS binaries are signed and notarized. ---- - -## Setup - -Add one line to your shell config and you're done: - -**bash / zsh** (`.bashrc` or `.zshrc`): -```bash -eval "$(try init)" -``` - -**fish** (`config.fish`): -```fish -try init | source -``` - -Use a custom directory: -```bash -eval "$(try init ~/workspace/experiments)" -``` +For other install paths (Go, manual download, custom directory), see [INSTALL.md](INSTALL.md). --- @@ -133,10 +83,10 @@ Five built-in themes, switchable live with `try theme` — pick your sparkle lev | Theme | Vibe | |---|---| | `bedazzled` *(default)* | 🌈 Catppuccin Mocha pastels under a full rainbow finish — rainbow search rules, shifting cursor hues, rainbow fuzzy hits, gradient row highlight | -| `rainbow` | 💖 Hot-pink accent, all rainbow, no apologies — the loudest one | -| `catppuccin` | 🍮 Catppuccin Mocha pastels, no rainbow (for grown-ups) | +| `rainbow` | 💖 Hot-pink accent, all rainbow, all the time — the loudest one | +| `catppuccin` | 🍮 Catppuccin Mocha pastels, sparkle dialed back | | `dracula` | 🧛 Dark and saturated | -| `minimal` | 🪨 ASCII-safe, no unicode, no glitter — good for CI and people who hate joy | +| `minimal` | 🪨 ASCII-safe, no unicode, no glitter — perfect for CI logs and quiet terminals | Set in config or override per-session: diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..14243cf --- /dev/null +++ b/install.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env sh +# install.sh — install try-bedazzled and wire up the shell function. +# +# curl -fsSL https://raw.githubusercontent.com/hmk/try-bedazzled/main/install.sh | sh +# +# Env overrides: +# TRY_INSTALL_DIR install location for the binary (default: /usr/local/bin) +# TRY_VERSION release tag to install (default: latest) +# TRY_NO_RC_EDIT if set, skip editing the shell rc file + +set -eu + +REPO="hmk/try-bedazzled" +INSTALL_DIR="${TRY_INSTALL_DIR:-/usr/local/bin}" +VERSION="${TRY_VERSION:-latest}" + +bold() { printf '\033[1m%s\033[0m\n' "$1"; } +info() { printf ' %s\n' "$1"; } +warn() { printf '\033[33m %s\033[0m\n' "$1" >&2; } +die() { printf '\033[31merror:\033[0m %s\n' "$1" >&2; exit 1; } + +bold "try-bedazzled installer" + +# --- detect platform ---------------------------------------------------------- + +uname_s=$(uname -s) +uname_m=$(uname -m) + +case "$uname_s" in + Darwin) os=darwin ;; + Linux) os=linux ;; + *) die "unsupported OS: $uname_s (try Homebrew or download from GitHub Releases)" ;; +esac + +case "$uname_m" in + x86_64|amd64) arch=amd64 ;; + arm64|aarch64) arch=arm64 ;; + *) die "unsupported architecture: $uname_m" ;; +esac + +info "platform: ${os}_${arch}" + +# --- resolve download URL ----------------------------------------------------- + +if [ "$VERSION" = "latest" ]; then + url="https://github.com/${REPO}/releases/latest/download/try-bedazzled_${os}_${arch}.tar.gz" +else + url="https://github.com/${REPO}/releases/download/${VERSION}/try-bedazzled_${os}_${arch}.tar.gz" +fi + +info "download: $url" + +# --- download + extract ------------------------------------------------------- + +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT + +if ! curl -fsSL -o "$tmp/try.tar.gz" "$url"; then + die "download failed — check that ${VERSION} has a release asset for ${os}_${arch}" +fi + +tar -xzf "$tmp/try.tar.gz" -C "$tmp" + +if [ ! -x "$tmp/try" ]; then + die "downloaded archive does not contain a 'try' binary" +fi + +# --- install binary ----------------------------------------------------------- + +info "install: $INSTALL_DIR/try" + +if [ -w "$INSTALL_DIR" ]; then + install -m 0755 "$tmp/try" "$INSTALL_DIR/try" +else + if ! command -v sudo >/dev/null 2>&1; then + die "$INSTALL_DIR is not writable and sudo is not available — set TRY_INSTALL_DIR to a writable path" + fi + warn "$INSTALL_DIR not writable — using sudo" + sudo install -m 0755 "$tmp/try" "$INSTALL_DIR/try" +fi + +# --- wire up shell function --------------------------------------------------- + +if [ -n "${TRY_NO_RC_EDIT:-}" ]; then + info "rc file: skipped (TRY_NO_RC_EDIT set)" + echo + bold "Done." + echo " Add this line to your shell config to enable the 'try' function:" + echo " eval \"\$(try init)\" # bash/zsh" + echo " try init | source # fish" + exit 0 +fi + +shell_name=$(basename "${SHELL:-/bin/sh}") + +case "$shell_name" in + bash) rc="$HOME/.bashrc"; line='eval "$(try init)"' ;; + zsh) rc="$HOME/.zshrc"; line='eval "$(try init)"' ;; + fish) rc="$HOME/.config/fish/config.fish"; line='try init | source' ;; + *) + warn "unrecognized shell '$shell_name' — skipping rc edit" + echo + bold "Done." + echo " Add the appropriate line to your shell config:" + echo " eval \"\$(try init)\" # bash/zsh" + echo " try init | source # fish" + exit 0 + ;; +esac + +mkdir -p "$(dirname "$rc")" +[ -f "$rc" ] || : > "$rc" + +if grep -Fq 'try init' "$rc" 2>/dev/null; then + info "rc file: $rc (already configured)" +else + info "rc file: $rc (appending)" + { + echo '' + echo '# try-bedazzled (https://github.com/hmk/try-bedazzled)' + echo "$line" + } >> "$rc" +fi + +# --- done --------------------------------------------------------------------- + +echo +bold "Installed!" +echo " Restart your shell or run: source $rc" +echo " Then try it: try"