Skip to content

Instantly share code, notes, and snippets.

@pizzimenti
Created March 31, 2025 00:16
Show Gist options
  • Select an option

  • Save pizzimenti/c6f212233d1b5aa398431ec090b02366 to your computer and use it in GitHub Desktop.

Select an option

Save pizzimenti/c6f212233d1b5aa398431ec090b02366 to your computer and use it in GitHub Desktop.
Manjaro Development Setup Script
#!/bin/zsh
# Setup development environment on a clean Manjaro Linux install
# Usage: sudo ./manjaro_dev_setup.sh
# Exit on error
set -e
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "โŒ Please run as root (use sudo)"
exit 1
fi
echo "๐Ÿš€ Starting Manjaro development environment setup..."
# Configure parallel downloads
echo "โš™๏ธ Configuring parallel downloads..."
# More targeted approach to set ParallelDownloads
if grep -q "^ParallelDownloads" /etc/pacman.conf; then
# If exists uncommented, replace it
sed -i 's/^ParallelDownloads.*/ParallelDownloads = 11/' /etc/pacman.conf
elif grep -q "^#ParallelDownloads" /etc/pacman.conf; then
# If exists commented, uncomment and set value
sed -i 's/^#ParallelDownloads.*/ParallelDownloads = 11/' /etc/pacman.conf
else
# If not found, add after the [options] section
sed -i '/^\[options\]/a ParallelDownloads = 11' /etc/pacman.conf
fi
# Update system
echo "๐Ÿ“ฆ Updating system packages..."
pacman -Syu --noconfirm
# Install essential development tools
echo "๐Ÿ› ๏ธ Installing essential development tools..."
pacman -S --noconfirm \
base-devel \
neovim \
chromium \
code \
docker \
python-pip \
nodejs \
github-cli \
glab \
yay \
timeshift-autosnap-manjaro
# Enable Docker service (will start after reboot)
echo "๐Ÿณ Setting up Docker..."
systemctl enable docker
echo "โš ๏ธ Docker service enabled but requires a reboot to start properly"
# Get the original user who ran sudo
REAL_USER=$(logname || echo $SUDO_USER)
REAL_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6)
# Add user to docker group so they can run docker without sudo
echo "๐Ÿ‘ค Adding user to docker group..."
usermod -aG docker "$REAL_USER"
# Set Neovim as default editor in user's shell profile
echo "โš™๏ธ Configuring shell environment..."
if [ -f "$REAL_HOME/.zshrc" ]; then
# Add to zshrc if not already present
if ! grep -q "export EDITOR=nvim" "$REAL_HOME/.zshrc"; then
echo 'export EDITOR=nvim' >> "$REAL_HOME/.zshrc"
echo 'export VISUAL=nvim' >> "$REAL_HOME/.zshrc"
fi
fi
# Configure global Git user settings
echo "๐Ÿ”ง Configuring Git global settings..."
su - "$REAL_USER" -c "git config --global user.name \"Bradley Pizzimenti\""
su - "$REAL_USER" -c "git config --global user.email \"[email protected]\""
# Install uBlock Origin for Firefox and Chromium
echo "๐Ÿ›ก๏ธ Installing uBlock Origin extension..."
# Firefox extension directory
FIREFOX_EXTENSIONS_DIR="/usr/lib/firefox/browser/extensions"
# Chromium extension directory
CHROMIUM_EXTENSIONS_DIR="/usr/share/chromium/extensions"
# Create extension directories if they don't exist
mkdir -p "$FIREFOX_EXTENSIONS_DIR"
mkdir -p "$CHROMIUM_EXTENSIONS_DIR"
# uBlock Origin extension IDs
UBLOCK_FIREFOX_ID="[email protected]"
UBLOCK_CHROMIUM_ID="cjpalhdlnbpafiamejdnhcphjbkeiagm"
# Firefox - Download and install uBlock Origin
wget -q "https://addons.mozilla.org/firefox/downloads/file/4003969/ublock_origin-latest.xpi" -O "$FIREFOX_EXTENSIONS_DIR/$UBLOCK_FIREFOX_ID.xpi"
chmod 644 "$FIREFOX_EXTENSIONS_DIR/$UBLOCK_FIREFOX_ID.xpi"
# Chromium - Create extension manifest
cat > "$CHROMIUM_EXTENSIONS_DIR/$UBLOCK_CHROMIUM_ID.json" << EOF
{
"external_update_url": "https://clients2.google.com/service/update2/crx"
}
EOF
chmod 644 "$CHROMIUM_EXTENSIONS_DIR/$UBLOCK_CHROMIUM_ID.json"
# Install AUR applications (as the regular user, not root)
echo "๐Ÿ’ป Installing AUR applications..."
# Temporarily allow the user to use sudo without a password
echo "$REAL_USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/99-temp-privileges
chmod 440 /etc/sudoers.d/99-temp-privileges
# Install AUR packages as the user
su - "$REAL_USER" -c "yay -S --noconfirm cursor-bin 1password claude-code || echo 'โš ๏ธ AUR installation failed - install manually after reboot'"
# Remove the temporary sudo privileges
rm -f /etc/sudoers.d/99-temp-privileges
# Cleanup
echo "๐Ÿงน Cleaning up..."
pacman -Sc --noconfirm
# Configure GRUB for maximum verbosity and snapshot menu
echo "โš™๏ธ Configuring boot options..."
# Remove "quiet" if present
sed -i 's/quiet //g' /etc/default/grub
# Set loglevel to 9 (maximum)
if grep -q "loglevel=" /etc/default/grub; then
# If loglevel exists, update it to 9
sed -i 's/loglevel=[0-9]/loglevel=9/g' /etc/default/grub
sed -i 's/loglevel=debug/loglevel=9/g' /etc/default/grub
else
# If loglevel doesn't exist, add it to GRUB_CMDLINE_LINUX_DEFAULT
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="/GRUB_CMDLINE_LINUX_DEFAULT="loglevel=9 /g' /etc/default/grub
fi
# Ensure menu is displayed for snapshots
sed -i 's/GRUB_TIMEOUT_STYLE=.*/GRUB_TIMEOUT_STYLE=menu/g' /etc/default/grub
# Configure snapshot submenu for GRUB
if ! grep -q "^GRUB_BTRFS_SUBMENUNAME" /etc/default/grub; then
echo 'GRUB_BTRFS_SUBMENUNAME="System Snapshots"' >> /etc/default/grub
echo 'GRUB_BTRFS_DISPLAY_PATH_SNAPSHOT="true"' >> /etc/default/grub
fi
# Update GRUB configuration
update-grub
# Create an initial snapshot if timeshift is installed
if command -v timeshift >/dev/null; then
echo "๐Ÿ“ธ Creating initial system snapshot..."
timeshift --create --comments "Fresh Manjaro development setup" --yes
fi
echo "โœจ Manjaro development environment setup complete!"
echo ""
echo "โš ๏ธ Please reboot your system for all changes to take effect."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment