install.sh: offer to configure PATH and shell completions in shellrc#3
Open
install.sh: offer to configure PATH and shell completions in shellrc#3
Conversation
When the install directory isn't on PATH, the installer now warns and offers to append an `export PATH=...` line to the user's shellrc, guarded behind a y/N confirmation prompt. Declining or running non-interactively falls back to printing the manual command. Likewise, when shell completions aren't already configured, offer to append a `source <(ghost completion <shell>)` snippet to the shellrc. For zsh users whose rc doesn't already load compinit (directly or via a framework like oh-my-zsh, prezto, zinit, antigen, zplug, or zgenom), also offer to add `autoload -Uz compinit && compinit -i`. Both prompts read from /dev/tty so they work under `curl | sh`. The shellrc file is detected from $SHELL (zsh -> .zshrc, bash -> .bashrc or .bash_profile on macOS, fish -> config.fish), with sensible fallbacks for unknown shells. Fish uses `set -gx PATH ...` and `ghost completion fish | source`. Modeled on the equivalent logic in ox's install.sh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The install script now helps users finish setup by offering (with a y/N confirmation prompt) to:
PATHin the user's shellrc when it isn't already there.source <(ghost completion <shell>)snippet to the shellrc when completions aren't already configured.Both prompts work under
curl | sh(they read from/dev/tty). Declining a prompt or running non-interactively falls back to printing the exact manual command the user would need to run, so the installer stays useful in CI / pipelines.Modeled on the equivalent logic in ox's
install.sh, adapted to stay POSIX/dash-compatible (the Ghost installer's existing shebang is#!/bin/sh).Details
Shellrc detection (
detect_shell_rc) uses$SHELL:zsh→${ZDOTDIR:-$HOME}/.zshrcbash→$HOME/.bash_profileon macOS when it exists, otherwise$HOME/.bashrcfish→${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish.zshrcon Darwin or when it already exists, otherwise.bashrcPATH configuration (
configure_path_in_shellrc):PATHor already referenced in the shellrc.fish_add_path/set -gx PATHfor fish,export PATH="$dir:$PATH"otherwise.Completion configuration (
configure_shell_completions):bash,zsh,fish. Silently skips for unknown shells with a pointer toghost completion --help.zsh, detects whethercompinitis already loaded (directly or viaoh-my-zsh,prezto,zinit,antigen,zplug, orzgenom) and offers to addautoload -Uz compinit && compinit -iwhen it isn't.ghost completion fish | sourcefor fish,source <(ghost completion <shell>)otherwise.Removed the static PATH warning that lived inside
verify_installation— that responsibility now belongs toconfigure_path_in_shellrc, which can actually fix the problem instead of just warning about it.Testing
sh -n scripts/install.shpasses.$SHELLvalues; each returns the expected rc path, shell type, and completion snippet.