ntu/install.sh

64 lines
1.6 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# Installation script for ntu (NameToUnix)
set -e
echo "=== NameToUnix Installation ==="
echo
# Check if binary exists
if [ ! -f "target/release/ntu" ]; then
echo "Error: Binary not found. Please run 'cargo build --release' first."
exit 1
fi
# Install binary
echo "Installing binary..."
sudo cp target/release/ntu /usr/local/bin/
sudo chmod 755 /usr/local/bin/ntu
echo "✓ Binary installed to /usr/local/bin/ntu"
# Install man page
echo "Installing man page..."
sudo cp man/ntu.1 /usr/share/man/man1/
sudo chmod 644 /usr/share/man/man1/ntu.1
sudo mandb -q
echo "✓ Man page installed to /usr/share/man/man1/ntu.1"
# Install config (user-specific)
echo "Installing configuration..."
mkdir -p ~/.config/NameToUnix/
cp .NameToUnix.conf ~/.config/NameToUnix/config.toml
echo "✓ Config installed to ~/.config/NameToUnix/config.toml"
# Install shell completions
echo "Installing shell completions..."
# Bash
if [ -d "/etc/bash_completion.d" ]; then
sudo cp completions/ntu.bash /etc/bash_completion.d/ntu
echo "✓ Bash completion installed"
fi
# Zsh
if [ -d "/usr/share/zsh/site-functions" ]; then
sudo cp completions/_ntu /usr/share/zsh/site-functions/_ntu
echo "✓ Zsh completion installed"
fi
# Fish
if [ -d "/usr/share/fish/vendor_completions.d" ]; then
sudo cp completions/ntu.fish /usr/share/fish/vendor_completions.d/ntu.fish
echo "✓ Fish completion installed"
fi
echo
echo "=== Installation complete ==="
echo
echo "Test the installation:"
echo " ntu --version"
echo " man ntu"
echo
echo "For shell completions to work, restart your shell or run:"
echo " source ~/.bashrc (Bash)"
echo " source ~/.zshrc (Zsh)"