init commit
This commit is contained in:
57
install.sh
Executable file
57
install.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/mach"
|
||||
BINARY="build/mach"
|
||||
|
||||
OS="$(uname -s)"
|
||||
|
||||
echo "Installing mach..."
|
||||
|
||||
# Build if binary not present
|
||||
if [ ! -f "$BINARY" ]; then
|
||||
echo "Building..."
|
||||
make build
|
||||
fi
|
||||
|
||||
# Install binary
|
||||
echo "Copying binary to $INSTALL_DIR..."
|
||||
sudo cp "$BINARY" "$INSTALL_DIR/mach"
|
||||
sudo chmod +x "$INSTALL_DIR/mach"
|
||||
|
||||
# Check PATH
|
||||
if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then
|
||||
echo "WARNING: $INSTALL_DIR is not in your PATH. Add it to your shell profile."
|
||||
fi
|
||||
|
||||
# Create config with defaults if not present
|
||||
if [ ! -f "$CONFIG_DIR/config.json" ]; then
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
cat > "$CONFIG_DIR/config.json" <<'EOF'
|
||||
{
|
||||
"input_type": "md",
|
||||
"output_type": "rtf"
|
||||
}
|
||||
EOF
|
||||
echo "Created default config at $CONFIG_DIR/config.json"
|
||||
fi
|
||||
|
||||
# Linux: create .desktop entry
|
||||
if [ "$OS" = "Linux" ]; then
|
||||
DESKTOP_DIR="$HOME/.local/share/applications"
|
||||
mkdir -p "$DESKTOP_DIR"
|
||||
cat > "$DESKTOP_DIR/mach.desktop" <<EOF
|
||||
[Desktop Entry]
|
||||
Name=mach
|
||||
Comment=Markdown to RTF clipboard converter
|
||||
Exec=$INSTALL_DIR/mach %f
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Utility;TextTools;
|
||||
MimeType=text/markdown;
|
||||
EOF
|
||||
echo "Created desktop entry at $DESKTOP_DIR/mach.desktop"
|
||||
fi
|
||||
|
||||
echo "Done! Run 'mach -v' to verify."
|
||||
Reference in New Issue
Block a user