#!/bin/sh # Install Freehand with uv, which also provides the Python it runs on; nothing else needs to be installed first. # # curl -LsSf https://raw.githubusercontent.com/microsoft/FreeHand/main/install.sh | sh # # Freehand is built from its source on GitHub; it is not published on PyPI yet. FREEHAND_INSTALL_SPEC picks something # else to install, for example a local checkout. Run it again, or `freehand update`, to upgrade. set -eu spec="${FREEHAND_INSTALL_SPEC:-git+https://github.com/microsoft/FreeHand}" caller_path="$PATH" # the PATH of the shell that ran this, which is where `freehand` is typed next if ! command -v uv >/dev/null 2>&1; then echo "Installing uv (https://docs.astral.sh/uv/), which manages Freehand's Python environment..." if command -v curl >/dev/null 2>&1; then curl -LsSf https://astral.sh/uv/install.sh | sh elif command -v wget >/dev/null 2>&1; then wget -qO- https://astral.sh/uv/install.sh | sh else echo "error: neither curl nor wget is available to download uv" >&2 exit 1 fi PATH="${XDG_BIN_HOME:-$HOME/.local/bin}:$HOME/.cargo/bin:$PATH" export PATH fi uv tool install --upgrade --python 3.12 "$spec" # warns, with the fix, if the command directory is not on PATH bin_dir="$(uv tool dir --bin 2>/dev/null || echo "$HOME/.local/bin")" echo echo "Freehand is installed. Next:" case ":$caller_path:" in *":$bin_dir:"*) ;; *) # uv's own installer adds the directory to the shell's startup files, which only new shells read if [ -f "$bin_dir/env" ]; then echo " . \"$bin_dir/env\" # or open a new terminal: $bin_dir is not on this shell's PATH yet" else echo " uv tool update-shell # then open a new terminal: $bin_dir is not on PATH yet" fi ;; esac echo " freehand login # Continue with ChatGPT (or an API key: freehand login openai | anthropic)" echo " cd your/project && freehand"