Last active
June 22, 2025 01:32
-
-
Save danilogco/add38f31bad753ab09a5b4b5fdc8f30d to your computer and use it in GitHub Desktop.
Amazon Linux 2023 / Linux Mint / Ubuntu - ZSH install script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Detecta gerenciador de pacotes | |
if command -v dnf &>/dev/null; then | |
PM="dnf" | |
elif command -v apt &>/dev/null; then | |
PM="apt" | |
else | |
echo "Gerenciador de pacotes não suportado. Use dnf ou apt." | |
exit 1 | |
fi | |
echo "🛠️ Usando gerenciador de pacotes: $PM" | |
echo "🌀 Atualizando pacotes..." | |
if [ "$PM" = "dnf" ]; then | |
sudo dnf update -y | |
else | |
sudo apt update -y | |
fi | |
echo "📦 Instalando Zsh e dependências..." | |
if [ "$PM" = "dnf" ]; then | |
sudo dnf install -y --allowerasing zsh git curl wget util-linux-user fontconfig | |
else | |
sudo apt install -y zsh git curl wget util-linux fontconfig | |
fi | |
echo "✅ Zsh instalado: $(zsh --version)" | |
echo "📁 Instalando Oh My Zsh..." | |
export RUNZSH=no | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
echo "🎨 Instalando Powerlevel10k..." | |
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \ | |
"${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" | |
echo "✨ Instalando plugins: autosuggestions, syntax-highlighting e completions..." | |
git clone https://github.com/zsh-users/zsh-autosuggestions \ | |
"${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \ | |
"${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" | |
git clone https://github.com/zsh-users/zsh-completions \ | |
"${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-completions" | |
echo "🔤 Instalando fonte MesloLGS NF..." | |
mkdir -p ~/.local/share/fonts | |
cd ~/.local/share/fonts | |
wget -q https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf | |
wget -q https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf | |
wget -q https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf | |
wget -q https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf | |
fc-cache -fv > /dev/null | |
echo "📝 Atualizando ~/.zshrc..." | |
# Define o tema powerlevel10k | |
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ~/.zshrc | |
# Plugins incluindo zsh-completions | |
sed -i 's/plugins=(git)/plugins=(git sudo common-aliases zsh-autosuggestions zsh-syntax-highlighting zsh-completions)/' ~/.zshrc | |
# Garante que oh-my-zsh seja carregado | |
grep -q "source \$ZSH/oh-my-zsh.sh" ~/.zshrc || echo -e '\nsource $ZSH/oh-my-zsh.sh' >> ~/.zshrc | |
echo "📂 Criando ~/.zsh_aliases e ~/.zsh_envs se não existirem..." | |
touch ~/.zsh_aliases | |
touch ~/.zsh_envs | |
# Garante que os arquivos sejam carregados | |
grep -q 'source ~/.zsh_envs' ~/.zshrc || echo '[[ -f ~/.zsh_envs ]] && source ~/.zsh_envs' >> ~/.zshrc | |
grep -q 'source ~/.zsh_aliases' ~/.zshrc || echo '[[ -f ~/.zsh_aliases ]] && source ~/.zsh_aliases' >> ~/.zshrc | |
echo "➕ Adicionando aliases em ~/.zsh_aliases..." | |
cat << 'EOF' >> ~/.zsh_aliases | |
# Meus aliases personalizados | |
alias ll='ls -la --color=auto' | |
alias upd='sudo apt update && sudo apt full-upgrade -y && flatpak upgrade -y' | |
alias cleanup='sudo apt autoremove && sudo apt autoclean && flatpak uninstall --unused' | |
alias please='sudo $(fc -ln -1)' | |
alias ip='ip -c a' | |
alias ports='sudo lsof -i -P -n | grep LISTEN' | |
# Aliases úteis de configuração Zsh | |
alias zshconfig="nano ~/.zshrc" | |
alias zshaliases="nano ~/.zsh_aliases" | |
alias ohmyzsh="nano ~/.oh-my-zsh" | |
alias zsh_update='omz update && git -C ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k pull' | |
EOF | |
echo "🧠 Alterando shell padrão para Zsh..." | |
chsh -s "$(which zsh)" | |
echo "✅ Tudo pronto!" | |
echo "🔁 Execute 'zsh' ou reconecte para usar o novo shell com Powerlevel10k!" | |
echo "🎨 Configure a fonte 'MesloLGS NF' no terminal (se gráfico) para exibir ícones corretamente." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment