Skip to content

jesposito/my-zsh-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

My Zsh Setup

Version License Shell

A zsh configuration installer that attempts to set up a nice terminal environment across different platforms. Originally created for my own use, but might be helpful for others.

⚠️ Note: This is a relatively new rewrite (v2.0.0) and needs more real-world testing across different environments. If you encounter issues, please open an issue or contribute a fix!

✨ What It Does

πŸ”„ Tries to be Safe

  • Attempts to run multiple times without breaking things (idempotent)
  • Backs up existing configurations automatically
  • Includes error handling and validation
  • Dry-run mode to see what would happen

🌍 Cross-Platform Goals

  • macOS (with Homebrew)
  • Linux (Ubuntu/Debian, Fedora, Arch)
  • WSL1/WSL2 with Windows integration attempts

Note: Primarily tested on WSL/Ubuntu. Other platforms need more testing.

🎨 What Gets Installed

βš™οΈ Customization Options

  • Command-line flags for selective installation
  • Environment variables for configuration
  • Non-interactive mode for automation

πŸš€ Quick Start

⚠️ Recommended: Run with --dry-run first to see what it will do!

Preview First (Recommended)

git clone https://github.com/jesposito/my-zsh-setup.git
cd my-zsh-setup
./setup.sh --dry-run

Standard Install

./setup.sh

Non-Interactive Install

./setup.sh --non-interactive

πŸ“‹ Requirements

  • Git
  • curl or wget
  • One of: apt, dnf, pacman, or brew (Homebrew)
  • sudo access (for package installation)

🎯 Usage

Basic Usage

./setup.sh [OPTIONS]

Command-Line Options

Option Description
-h, --help Show help message
-v, --verbose Enable verbose output
-n, --dry-run Preview changes without making them
-y, --non-interactive Run without prompts (use defaults)
--skip-omz Skip Oh My Zsh installation
--skip-p10k Skip Powerlevel10k installation
--skip-plugins Skip plugin installation
--skip-fonts Skip font installation
--skip-backup Skip backing up existing configs
--install-k8s Install Kubernetes tools

Environment Variables

You can also configure the installer using environment variables:

# Disable specific components
INSTALL_OMZ=false ./setup.sh

# Install with Kubernetes tools
INSTALL_K8S_TOOLS=true ./setup.sh

# Verbose dry run
VERBOSE=true DRY_RUN=true ./setup.sh
Variable Default Description
INSTALL_OMZ true Install Oh My Zsh
INSTALL_P10K true Install Powerlevel10k
INSTALL_PLUGINS true Install zsh plugins
INSTALL_FONTS true Install Nerd Fonts
INSTALL_K8S_TOOLS false Install Kubernetes tools
SKIP_BACKUP false Skip configuration backups
VERBOSE false Verbose output
DRY_RUN false Dry run mode
NON_INTERACTIVE false Non-interactive mode

πŸ“š Examples

Minimal Installation (No Fonts)

./setup.sh --skip-fonts

Install with Kubernetes Tools

./setup.sh --install-k8s

Automated/CI Installation

INSTALL_FONTS=false INSTALL_K8S_TOOLS=false ./setup.sh --non-interactive

Preview What Will Be Installed

./setup.sh --dry-run --verbose

Custom Installation

# Install only zsh with custom plugins, skip theme
INSTALL_P10K=false ./setup.sh --skip-fonts

πŸ› οΈ What Gets Installed

Core Components

  1. Zsh - Modern shell with advanced features
  2. Oh My Zsh - Plugin and theme framework
  3. Powerlevel10k - Fast, customizable prompt theme
  4. MesloLGS NF Font - Nerd Font with icon support

Included Plugins

  • git - Git integration and aliases
  • docker - Docker command completion
  • docker-compose - Docker Compose integration
  • kubectl - Kubernetes CLI integration (if kubectl installed)
  • npm - Node package manager shortcuts
  • vscode - VSCode integration
  • zsh-syntax-highlighting - Fish-like syntax highlighting
  • zsh-autosuggestions - Fish-like autosuggestions

Pre-Configured Aliases

Navigation

..      # cd ..
...     # cd ../..
....    # cd ../../..
~       # cd ~
home    # cd ~

Git

ga      # git add
gc      # git commit
gcm     # git commit -m
gp      # git push
gl      # git pull
gst     # git status
gco     # git checkout
glog    # git log --oneline --graph --decorate

Docker

dps     # docker ps
dpa     # docker ps -a
di      # docker images
dlog    # docker logs
dexec   # docker exec -it

Kubernetes (if installed)

k       # kubectl
kx      # kubectx
kns     # kubens

Custom Functions

  • mkcd <dir> - Create directory and cd into it
  • extract <file> - Extract various archive formats
  • code - Open VSCode (WSL-aware on Windows)
  • open - Open Windows Explorer (WSL only)

πŸ–₯️ Platform-Specific Features

macOS

  • Uses Homebrew for package installation
  • Installs fonts via Homebrew Cask

Linux

  • Supports apt, dnf, and pacman
  • Downloads fonts to ~/.local/share/fonts

WSL (Windows Subsystem for Linux)

  • Automatically detects WSL environment
  • Configures VSCode integration with Windows
  • Sets up Windows Explorer integration
  • Browser configuration for wslview

πŸ”§ Post-Installation

1. Restart Your Terminal

exec zsh

2. Configure Powerlevel10k

Run the configuration wizard:

p10k configure

3. Configure Your Terminal Font

Set your terminal to use MesloLGS NF font:

  • iTerm2 (macOS): Preferences β†’ Profiles β†’ Text β†’ Font
  • Terminal.app (macOS): Preferences β†’ Profiles β†’ Font
  • Windows Terminal: Settings β†’ Profiles β†’ Appearance β†’ Font face
  • GNOME Terminal: Preferences β†’ Profiles β†’ Text β†’ Custom font

4. Customize Your Config

Edit ~/.zshrc to add your personal customizations:

vim ~/.zshrc
# or
code ~/.zshrc

πŸ”„ Backup & Restore

Automatic Backups

The installer automatically backs up existing configurations to:

~/.zsh-setup-backups/YYYYMMDD-HHMMSS/

Restore Previous Configuration

# Find your backup
ls -la ~/.zsh-setup-backups/

# Restore
cp ~/.zsh-setup-backups/20260105-123456/.zshrc ~/.zshrc

Skip Backups

./setup.sh --skip-backup

πŸ§ͺ Testing

Run All Tests

cd tests
./run_tests.sh

Individual Tests

ShellCheck (Linting)

shellcheck setup.sh

Bats (Functional Tests)

bats tests/test_setup.bats

Syntax Validation

bash -n setup.sh

Install Test Dependencies

macOS

brew install shellcheck bats-core

Ubuntu/Debian

sudo apt install shellcheck bats

Fedora

sudo dnf install ShellCheck bats

🀝 Contributing

Contributions are very welcome! This script needs more testing across different environments and setups. If you:

  • Find a bug β†’ Open an issue
  • Have a platform it doesn't work on β†’ Please help test/fix it
  • Want to add a feature β†’ Pull requests appreciated
  • Have improvement ideas β†’ Let's discuss them

How to Contribute

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/your-feature)
  3. Make your changes
  4. Test thoroughly (especially ./setup.sh --dry-run)
  5. Run tests if possible (./tests/run_tests.sh)
  6. Commit your changes
  7. Push to the branch and open a Pull Request

Testing Help Needed

Especially looking for testing on:

  • macOS (Intel and Apple Silicon)
  • Fedora/RHEL (dnf package manager)
  • Arch Linux (pacman package manager)
  • Different WSL versions and configurations

Even just trying it out and reporting success/failure helps!

πŸ“ Configuration Files

After installation, you'll have:

  • ~/.zshrc - Main zsh configuration
  • ~/.p10k.zsh - Powerlevel10k theme configuration
  • ~/.oh-my-zsh/ - Oh My Zsh installation directory
  • ~/.zsh-setup-backups/ - Backup directory

πŸ› Troubleshooting

Something Broke?

First, check your backups:

ls -la ~/.zsh-setup-backups/
# Restore if needed:
cp ~/.zsh-setup-backups/YYYYMMDD-HHMMSS/.zshrc ~/.zshrc

Zsh Not Default Shell

Manually set zsh as default:

chsh -s $(which zsh)

Fonts Not Showing

  1. Make sure your terminal is using MesloLGS NF font
  2. Restart your terminal
  3. Run p10k configure again

Plugins Not Loading

Check that plugins are sourced in ~/.zshrc:

grep "plugins=" ~/.zshrc

Oh My Zsh Installation Failed

Try installing manually:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Permission Denied

Make sure the script is executable:

chmod +x setup.sh

Still Having Issues?

Please open an issue with:

  • Your OS and version
  • Error messages
  • Output from ./setup.sh --verbose --dry-run

πŸ”’ Security Notes

  • Downloads are from official sources (Oh My Zsh, Powerlevel10k, etc.)
  • Uses HTTPS for remote operations
  • No credentials or sensitive data stored
  • Always review scripts before running them!
  • Use --dry-run first to see what it will do

If you spot any security issues, please report them.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Credits

This builds on the excellent work of:

πŸ“ž Getting Help

πŸ’­ About

Originally created for my own use to quickly set up zsh on new machines. The v2.0.0 rewrite aimed to make it more portable and useful for others, but it still needs more testing across different environments.

If this helps you, great! If you find issues or have improvements, please contribute back.


Made by jesposito

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages