Skip to content

Instantly share code, notes, and snippets.

@naranyala
Created July 17, 2025 09:24
Show Gist options
  • Save naranyala/2ef050e45591a5102fa89eda3b42e0cb to your computer and use it in GitHub Desktop.
Save naranyala/2ef050e45591a5102fa89eda3b42e0cb to your computer and use it in GitHub Desktop.
easy installation for zsh (z shell) and starship terminal
#!/usr/bin/env bash
set -e
# Helper to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
echo "πŸ” Checking dependencies..."
# Install Zsh if not present
if ! command_exists zsh; then
echo "πŸ“¦ Installing Zsh..."
sudo apt update && sudo apt install -y zsh
else
echo "βœ… Zsh already installed."
fi
# Install Git and Curl if missing
for pkg in git curl; do
if ! command_exists "$pkg"; then
echo "πŸ“¦ Installing $pkg..."
sudo apt install -y "$pkg"
else
echo "βœ… $pkg already installed."
fi
done
# Install fonts-powerline for better visuals
if ! fc-list | grep -iq "Powerline"; then
echo "🎨 Installing Powerline fonts..."
sudo apt install -y fonts-powerline
else
echo "βœ… Powerline fonts already installed."
fi
# Change default shell to Zsh
if [ "$SHELL" != "$(which zsh)" ]; then
echo "πŸ”„ Changing default shell to Zsh..."
chsh -s "$(which zsh)"
fi
# Install Oh My Zsh
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo "🌟 Installing Oh My Zsh..."
export RUNZSH=no
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
echo "βœ… Oh My Zsh already installed."
fi
# Install Zsh plugins
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
declare -A plugins=(
["zsh-autosuggestions"]="https://github.com/zsh-users/zsh-autosuggestions"
["zsh-syntax-highlighting"]="https://github.com/zsh-users/zsh-syntax-highlighting"
)
for name in "${!plugins[@]}"; do
path="$ZSH_CUSTOM/plugins/$name"
if [ ! -d "$path" ]; then
echo "πŸ”Œ Installing $name..."
git clone "${plugins[$name]}" "$path"
else
echo "βœ… $name already installed."
fi
done
# Update .zshrc plugins
sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/' ~/.zshrc
# Install Starship
if ! command_exists starship; then
echo "πŸš€ Installing Starship..."
curl -sS https://starship.rs/install.sh | sh
else
echo "βœ… Starship already installed."
fi
# Add Starship init to .zshrc
if ! grep -q 'starship init zsh' ~/.zshrc; then
echo 'eval "$(starship init zsh)"' >> ~/.zshrc
fi
# Create Starship config
mkdir -p ~/.config
cat <<EOF > ~/.config/starship.toml
add_newline = false
[character]
success_symbol = "[❯](bold green)"
error_symbol = "[βœ—](bold red)"
EOF
echo "πŸŽ‰ Setup complete! Restart your terminal or run: exec zsh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment