Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Setting Up Zsh and Oh-My-Zsh on Homestead for Enhanced Terminal Experience

Tech May 12 2

Installing Zsh on Homestead

Homestead ships with bash as the default shell. While functional, it lacks modern conveniences like intelligent auto-completion, powerful plugins, and customizable themes. Zsh combined with Oh-My-Zsh provides a significantly improved terminal workflow.

Start the Homestead environment and SSH into it:

homestead up
homestead ssh

Once inside the virtual machine, install Zsh using apt:

sudo apt update
sudo apt install zsh -y

Verify the installtaion:

zsh --version

Switch to Zsh as the default shell:

chsh -s $(which zsh)

Log out and reconnect to apply the change. Confirm the switch:

echo $SHELL

Installing Oh-My-Zsh

The Oh-My-Zsh framework provides plugin management, theme support, and auto-updates. The installation script is hosted on GitHub:

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

Alternatively, using wget:

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

After installation completes, exit and reconnect to the SSH session.

Customizing the Shell Configuration

The main configuration file is located at ~/.zshrc. Open it with your preferred editor:

vim ~/.zshrc

Selecting a Theme

Oh-My-Zsh includes numerous built-in themes. Locate the ZSH_THEME variable and specify your preferred theme:

ZSH_THEME="robbyrussell"

Browse available themes in the themes directory:

ls ~/.oh-my-zsh/themes

Popular alternatives include agnoster, powerlevel10k, and steeef. Some theme require Powerline fonts for proper rendering.

Enabling Plugins

Add plugins to the plugins array in your configuration:

plugins=(git node npm docker vscode extract z)

The default plugins include git, which provides alias shortcuts for common commands. Additional useful plugins include:

  • zsh-autosuggestions - Fish-like auto-suggestions based on command history
  • zsh-syntax-highlighting - Syntax highlighting for commands
  • fzf - Fuzzy finder integration

Install the auto-suggestions plugin:

git clone https://github.com/zsh-users/zsh-autosuggestions \
  ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Add it to your plugins list and reload the configuration:

source ~/.zshrc

Optional: Auto-Complete Enhancement

For enhanced auto-completion, download the incr plugin:

wget https://mimosa-pudica.net/src/incr-0.2.zsh -O ~/.oh-my-zsh/custom/incr.zsh

The plugin loads automatically when sourcing .zshrc due to the custom plugins directory structure.

Applying Changes

After modifying .zshrc, apply the new configuration:

source ~/.zshrc

If changes do not appear immediately, close and reopen the terminal session.

Troubleshooting

If Oh-My-Zsh fails to install, verify network connectivity to GitHub and ensure curl or wget is available:

which curl wget

For permission errors, ensure the current user has write access to the home directory. As a last resort, manually clone the repository:

git clone https://github.com/ohmyzsh/ohmyzsh ~/.oh-my-zsh

Then manually create the .zshrc from the template provided in the repo.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.