作为引导过程的一部分,在Vagrant Box上安装Oh My Zsh

Ala*_*ley 26 vagrant oh-my-zsh

我想将Oh My Zsh添加到我的Vagrant引导程序中,但直接安装不起作用.

通过卷曲:

curl -L http://install.ohmyz.sh | sh
Run Code Online (Sandbox Code Playgroud)

通过wget:

wget --no-check-certificate http://install.ohmyz.sh -O - | sh
Run Code Online (Sandbox Code Playgroud)

Ala*_*ley 30

找到解决方案:

# 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
Run Code Online (Sandbox Code Playgroud)

作为一个很好的补充,所以你的终端在不同的盒子上看起来不太相似

# Change the oh my zsh default theme.
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="3den"/g' ~/.zshrc
Run Code Online (Sandbox Code Playgroud)


Ala*_*ith 20

这是一个完整的Vagrantfile,在Ubuntu 14.04.2 LTS盒子上安装Oh My Zsh并将其设置为标准vagrant用户的默认shell .

这适用于Vagrant 1.7.2.(您的milage可能因版本不同而有所不同.)它使用自述文件的" 手动安装"部分中的说明,而不是尝试使用自动脚本.

# -*- 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
Run Code Online (Sandbox Code Playgroud)

作为奖励,您可以使用以下命令将主机.zshrc文件的一次性副本复制到流浪者盒中:

config.vm.provision "file", source: "~/.zshrc", destination: ".zshrc"
Run Code Online (Sandbox Code Playgroud)

(请记住,由于主机和流浪盒的设置不同,您可能必须先找出最初不起作用的东西.)

  • 如果当前正在运行该框,请尝试运行`vagrant reload --provision`.否则,`vagrant up --provision`如果它没有运行.这对我有用. (2认同)