Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Oh My Zsh on a Vagrant Box as part of the bootstrap process

I'd like to add Oh My Zsh to my Vagrant bootstrap process, but a straight install isn't working.

via curl:

curl -L http://install.ohmyz.sh | sh 

via wget:

wget --no-check-certificate http://install.ohmyz.sh -O - | sh 
like image 500
Alan Quigley Avatar asked Sep 10 '14 10:09

Alan Quigley


People also ask

Should I install zsh Before oh my zsh?

Oh My Zsh is a framework for Zsh, the Z shell. In order for Oh My Zsh to work, Zsh must be installed. Please run zsh --version to confirm.

Where are zsh themes installed?

Theme installation with oh-my-zsh If you're using oh-my-zsh you can keep your themes in the ~/. oh-my-zsh/themes directory as a . zsh-theme file. You'll see that this directory is prepopulated with over 100 themes already!


2 Answers

Found the solution:

# Added zsh shell. sudo apt-get install zsh wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh  sudo chsh -s /bin/zsh vagrant zsh 

As an nice addition, so that your terminals don't look too similar on the different boxes

# Change the oh my zsh default theme. sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="3den"/g' ~/.zshrc 
like image 102
Alan Quigley Avatar answered Sep 21 '22 13:09

Alan Quigley


Here's a complete Vagrantfile that installs Oh My Zsh on an Ubuntu 14.04.2 LTS box and sets it as the default shell for standard vagrant user.

This works with Vagrant 1.7.2. (Your milage may vary with different versions.) It uses the directions from the Manual Installation section of the Readme instead of trying to use the automatic scripts.

# -*- mode: ruby -*- # vi: set ft=ruby :  VAGRANTFILE_API_VERSION = "2"  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|    # Pick a box to use:   config.vm.box = "ubuntu/trusty64"    ############################################################   # Oh My ZSH Install section    # Install git and zsh prerequisites    config.vm.provision :shell, inline: "apt-get -y install git"   config.vm.provision :shell, inline: "apt-get -y install zsh"    # Clone Oh My Zsh from the git repo   config.vm.provision :shell, privileged: false,     inline: "git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh"    # Copy in the default .zshrc config file   config.vm.provision :shell, privileged: false,     inline: "cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc"    # Change the vagrant user's shell to use zsh   config.vm.provision :shell, inline: "chsh -s /bin/zsh vagrant"    ############################################################   end 

As a bonus, you can do a one time copy of your host machine's .zshrc file to the vagrant box with:

config.vm.provision "file", source: "~/.zshrc", destination: ".zshrc" 

(Keep in mind, You may have to figure things that don't work initially because of differences between the host machine and the vagrant box's setups.)

like image 23
Alan W. Smith Avatar answered Sep 21 '22 13:09

Alan W. Smith