Skip to content

Instantly share code, notes, and snippets.

@benharold
Created October 23, 2018 19:54
Show Gist options
  • Save benharold/4ab4ff5c473b9de0a1ecda86a6d1e474 to your computer and use it in GitHub Desktop.
Save benharold/4ab4ff5c473b9de0a1ecda86a6d1e474 to your computer and use it in GitHub Desktop.
Setup zsh with oh-my-zsh and the spaceship prompt
#!/bin/bash
# Install oh-my-zsh and the spaceship theme.
# This script is to be run by a provisioner as root.
# Change this to the appropriate user.
USER_NAME="vagrant"
ZSH_CUSTOM="/home/$USER_NAME/.oh-my-zsh/custom"
# install oh-my-zsh
runuser -l $USER_NAME -c 'sh -c "$(wget --quiet https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"'
# install spaceship prompt
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"
ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
# set the spaceship prompt as the theme
echo 'ZSH_THEME="spaceship"' > ${ZSH_CUSTOM}/theme.zsh
echo -e '# run `ls -lah` when readline receives a single return character (and nothing else)
accept-line() {: "${BUFFER:="ls -lah"}"; zle ".$WIDGET"}
zle -N accept-line' > ${ZSH_CUSTOM}/lazy-list.zsh
# use zsh as the default shell for the user
chsh -s $(which zsh) $USER_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment