mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-06-05 05:03:16 +02:00
Supports custom home folder path
This allows Oh My Zsh to be installed by root for another user. Useful when using tools like Chef and Ansible to setup a system.
This commit is contained in:
parent
a0b8eab5f0
commit
5b427df37d
1 changed files with 13 additions and 9 deletions
|
|
@ -29,8 +29,12 @@ main() {
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -n "$ZSH_PATH" ]; then
|
||||||
|
ZSH_PATH=~
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -n "$ZSH" ]; then
|
if [ ! -n "$ZSH" ]; then
|
||||||
ZSH=~/.oh-my-zsh
|
ZSH=$ZSH_PATH/.oh-my-zsh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "$ZSH" ]; then
|
if [ -d "$ZSH" ]; then
|
||||||
|
|
@ -66,17 +70,17 @@ main() {
|
||||||
|
|
||||||
|
|
||||||
printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
|
printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
|
||||||
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
|
if [ -f $ZSH_PATH/.zshrc ] || [ -h $ZSH_PATH/.zshrc ]; then
|
||||||
printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n";
|
printf "${YELLOW}Found $ZSH_PATH/.zshrc.${NORMAL} ${GREEN}Backing up to $ZSH_PATH/.zshrc.pre-oh-my-zsh${NORMAL}\n";
|
||||||
mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
|
mv $ZSH_PATH/.zshrc $ZSH_PATH/.zshrc.pre-oh-my-zsh;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n"
|
printf "${BLUE}Using the Oh My Zsh template file and adding it to $ZSH_PATH/.zshrc${NORMAL}\n"
|
||||||
cp "$ZSH"/templates/zshrc.zsh-template ~/.zshrc
|
cp "$ZSH"/templates/zshrc.zsh-template $ZSH_PATH/.zshrc
|
||||||
sed "/^export ZSH=/ c\\
|
sed "/^export ZSH=/ c\\
|
||||||
export ZSH=\"$ZSH\"
|
export ZSH=\"$ZSH\"
|
||||||
" ~/.zshrc > ~/.zshrc-omztemp
|
" $ZSH_PATH/.zshrc > $ZSH_PATH/.zshrc-omztemp
|
||||||
mv -f ~/.zshrc-omztemp ~/.zshrc
|
mv -f $ZSH_PATH/.zshrc-omztemp $ZSH_PATH/.zshrc
|
||||||
|
|
||||||
# If this user's login shell is not already "zsh", attempt to switch.
|
# If this user's login shell is not already "zsh", attempt to switch.
|
||||||
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
|
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
|
||||||
|
|
@ -101,7 +105,7 @@ main() {
|
||||||
echo ' /____/ ....is now installed!'
|
echo ' /____/ ....is now installed!'
|
||||||
echo ''
|
echo ''
|
||||||
echo ''
|
echo ''
|
||||||
echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.'
|
echo 'Please look over the $ZSH_PATH/.zshrc file to select plugins, themes, and options.'
|
||||||
echo ''
|
echo ''
|
||||||
echo 'p.s. Follow us at https://twitter.com/ohmyzsh.'
|
echo 'p.s. Follow us at https://twitter.com/ohmyzsh.'
|
||||||
echo ''
|
echo ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue