Skip to content

Instantly share code, notes, and snippets.

@kriipke
Created July 31, 2025 03:18
Show Gist options
  • Save kriipke/4863bb65e4e8605eeff8b09cda5508dd to your computer and use it in GitHub Desktop.
Save kriipke/4863bb65e4e8605eeff8b09cda5508dd to your computer and use it in GitHub Desktop.
nnn configuration/installation
#!/usr/bin/env sh
set -e
# Default configuration
FLAVOR="nerd" # Options: nerd, emoji, icons
VERSION="5.1"
PREFIX="/usr/local"
ARCH="x86_64"
EXT="tar.gz"
# Print help message
usage() {
cat <<EOF
Usage: $(basename "$0") [OPTIONS]
Install a statically-linked nnn binary and its plugin installer.
Options:
--flavor [nerd|emoji|icons] Flavor of nnn to install (default: nerd)
--version VERSION nnn version to install (default: 5.1)
--prefix PREFIX Installation prefix (default: /usr/local)
--help Show this help message and exit
Examples:
./install-nnn.sh --flavor emoji --version 5.1 --prefix /usr/local
EOF
exit 0
}
# Parse command line arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--flavor)
FLAVOR="$2"; shift 2;;
--version)
VERSION="$2"; shift 2;;
--prefix)
PREFIX="$2"; shift 2;;
--help|-h)
usage;;
*)
echo "Unknown option: $1" >&2
usage;;
esac
done
# Derived values
FILE_PATH="https://github.com/jarun/nnn/releases/download/v${VERSION}"
ARCHIVE_NAME="nnn-${FLAVOR}-static-${VERSION}.${ARCH}.${EXT}"
BINARY_NAME="nnn-${FLAVOR}-static"
PLUGIN_SCRIPT="nnn-gitplugs"
echo "➡️ Installing nnn v${VERSION} [flavor: ${FLAVOR}] to ${PREFIX}/bin"
# Step 1: Download the binary archive
echo "⬇️ Downloading ${ARCHIVE_NAME} from ${FILE_PATH}..."
(
cd /tmp/
curl -sSL -O "${FILE_PATH}/${ARCHIVE_NAME}"
)
# Step 2: Extract and install binary
echo "📦 Extracting and installing nnn..."
(
TMPDIR="$(mktemp -d)"
cd "${TMPDIR}"
tar xzvf "/tmp/${ARCHIVE_NAME}"
echo "🛠️ Installing ${BINARY_NAME} as 'nnn' to ${PREFIX}/bin"
install "${BINARY_NAME}" "${PREFIX}/bin/nnn"
)
# Step 3: Download and install plugin helper
echo "🔌 Installing plugin helper script (${PLUGIN_SCRIPT})..."
(
cd /tmp/
curl -sSL -o "${PLUGIN_SCRIPT}" "https://raw.githubusercontent.com/jarun/nnn/v${VERSION}/plugins/getplugs"
install "${PLUGIN_SCRIPT}" "${PREFIX}/bin/"
)
# Step 4: Verify plugin helper
echo "📚 Verifying plugin helper..."
"${PREFIX}/bin/${PLUGIN_SCRIPT}" --help || echo "⚠️ Plugin helper installed but not functional"
echo "✅ nnn v${VERSION} (${FLAVOR}) successfully installed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment