Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct setup for Brew + Zsh + Oh My Zsh on multiple admin users on Mac OS X?

My question is what would be a good way to run two admin accounts for developing in regards to running Homebrew, Zsh and Oh My Zsh and configuring the .zshrc file?

My reasoning for this is that I recently started a new job and would like to use my Mac with two accounts, both of which will be admins and both of which I will require devtools so as to keep my work life/dev and personal life/dev cleanly separated. I just erased my hard drive and cleanly installed OS X 10.12.3 and created two Admin accounts.

I've had a shot at setting it up however keep getting permission errors whenever I switch accounts and run terminal, usually specific to zsh completions.

My steps:

  1. Install Homebrew on both users /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)".
  2. Install zsh with brew brew install zsh and change to it chsh -s /bin/zsh.
  3. Install oh my zsh with curl via sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)".
  4. run sudo chown -R $(whoami):admin /usr/local.

Then I've tried a whole mess of things which I'll refrain from adding as I believe they may only lead others down a dark path.

like image 385
joshuatvernon Avatar asked Oct 30 '22 10:10

joshuatvernon


1 Answers

Although this step is safe to run as root, I still recommend running the installation as non-root user to prevent catastrophic problems with root switching shell while the shell isn't working. superuser shell should never be changed.

Here's the proper way to install oh-my-zsh for multiple users.

Step 1: Ensure umask is not stricter than 022. If not set it to 022.

$ umask 022

Step 2: set and export ZSH with the destination path where the shared oh-my-zsh will be installed.

export ZSH=/usr/local/.zsh/oh-my-zsh

Step 3: Create the parent directory and make it owned by the user installing the scripts.

$ sudo mkdir /usr/local/.zsh
$ sudo chown ${USER} /usr/local/.zsh

Step 4: Run the installer.

$ bash -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Step 5: Change ownership of the installation path back to root.

$ sudo chown -R root /usr/local/.zsh

Step 6: Update location of ZSH in ${ZSH}/templates/zshrc.zsh-template

$ sudo sed -i 's|export ZSH=.*|export ZSH='${ZSH}'|' ${ZSH}/templates/zshrc.zsh-template

(Optional) Step 7: Disable auto update. This is recommended as the installation is now owned by root.

$ sudo sed -i 's/# DISABLE_AUTO_UPDATE="true"/DISABLE_AUTO_UPDATE="true"/' ${ZSH}/templates/zshrc.zsh-template

From here on, each user can copy ${ZSH}/templates/zshrc.zsh-template as ~/.zshrc

like image 61
alvits Avatar answered Nov 15 '22 08:11

alvits