Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
b2313ec7
Commit
b2313ec7
authored
Oct 23, 2020
by
Alex
Committed by
Marc Cornellà
Jan 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(installer): respect and install in `$ZDOTDIR` if set (#9376)
Fixes #9001 Fixes #10479 Closes #9376 Co-authored-by:
Marc Cornellà
<
hello@mcornella.com
>
parent
39525e5e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
15 deletions
+30
-15
install.sh
tools/install.sh
+30
-15
No files found.
tools/install.sh
View file @
b2313ec7
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
# ZSH=~/.zsh sh install.sh
# ZSH=~/.zsh sh install.sh
#
#
# Respects the following environment variables:
# Respects the following environment variables:
# ZDOTDIR - path to Zsh dotfiles directory (default: unset). See [1][2]
# [1] https://zsh.sourceforge.io/Doc/Release/Parameters.html#index-ZDOTDIR
# [2] https://zsh.sourceforge.io/Doc/Release/Files.html#index-ZDOTDIR_002c-use-of
# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)
# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)
# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)
# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)
# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)
# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)
...
@@ -53,8 +56,17 @@ HOME="${HOME:-$(eval echo ~$USER)}"
...
@@ -53,8 +56,17 @@ HOME="${HOME:-$(eval echo ~$USER)}"
# Track if $ZSH was provided
# Track if $ZSH was provided
custom_zsh
=
${
ZSH
:+yes
}
custom_zsh
=
${
ZSH
:+yes
}
# Default settings
# Use $zdot to keep track of where the directory is for zsh dotfiles
# To check if $ZDOTDIR was provided, explicitly check for $ZDOTDIR
zdot
=
"
${
ZDOTDIR
:-
$HOME
}
"
# Default value for $ZSH
# a) if $ZDOTDIR is supplied: $ZDOTDIR/ohmyzsh
# b) otherwise, $HOME/.oh-my-zsh
ZSH
=
"
${
ZSH
:-${
ZDOTDIR
:+
$ZDOTDIR
/ohmyzsh
}}
"
ZSH
=
"
${
ZSH
:-
$HOME
/.oh-my-zsh
}
"
ZSH
=
"
${
ZSH
:-
$HOME
/.oh-my-zsh
}
"
# Default settings
REPO
=
${
REPO
:-
ohmyzsh
/ohmyzsh
}
REPO
=
${
REPO
:-
ohmyzsh
/ohmyzsh
}
REMOTE
=
${
REMOTE
:-
https
://github.com/
${
REPO
}
.git
}
REMOTE
=
${
REMOTE
:-
https
://github.com/
${
REPO
}
.git
}
BRANCH
=
${
BRANCH
:-
master
}
BRANCH
=
${
BRANCH
:-
master
}
...
@@ -311,11 +323,11 @@ setup_zshrc() {
...
@@ -311,11 +323,11 @@ setup_zshrc() {
echo
"
${
FMT_BLUE
}
Looking for an existing zsh config...
${
FMT_RESET
}
"
echo
"
${
FMT_BLUE
}
Looking for an existing zsh config...
${
FMT_RESET
}
"
# Must use this exact name so uninstall.sh can find it
# Must use this exact name so uninstall.sh can find it
OLD_ZSHRC
=
~/.zshrc.pre-oh-my-zsh
OLD_ZSHRC
=
"
$zdot
/.zshrc.pre-oh-my-zsh"
if
[
-f
~/.zshrc
]
||
[
-h
~/.zshrc
]
;
then
if
[
-f
"
$zdot
/.zshrc"
]
||
[
-h
"
$zdot
/.zshrc"
]
;
then
# Skip this if the user doesn't want to replace an existing .zshrc
# Skip this if the user doesn't want to replace an existing .zshrc
if
[
"
$KEEP_ZSHRC
"
=
yes
]
;
then
if
[
"
$KEEP_ZSHRC
"
=
yes
]
;
then
echo
"
${
FMT_YELLOW
}
Found
~
/.zshrc.
${
FMT_RESET
}
${
FMT_GREEN
}
Keeping...
${
FMT_RESET
}
"
echo
"
${
FMT_YELLOW
}
Found
${
zdot
}
/.zshrc.
${
FMT_RESET
}
${
FMT_GREEN
}
Keeping...
${
FMT_RESET
}
"
return
return
fi
fi
if
[
-e
"
$OLD_ZSHRC
"
]
;
then
if
[
-e
"
$OLD_ZSHRC
"
]
;
then
...
@@ -327,19 +339,22 @@ setup_zshrc() {
...
@@ -327,19 +339,22 @@ setup_zshrc() {
fi
fi
mv
"
$OLD_ZSHRC
"
"
${
OLD_OLD_ZSHRC
}
"
mv
"
$OLD_ZSHRC
"
"
${
OLD_OLD_ZSHRC
}
"
echo
"
${
FMT_YELLOW
}
Found old
~/
.zshrc.pre-oh-my-zsh."
\
echo
"
${
FMT_YELLOW
}
Found old .zshrc.pre-oh-my-zsh."
\
"
${
FMT_GREEN
}
Backing up to
${
OLD_OLD_ZSHRC
}${
FMT_RESET
}
"
"
${
FMT_GREEN
}
Backing up to
${
OLD_OLD_ZSHRC
}${
FMT_RESET
}
"
fi
fi
echo
"
${
FMT_YELLOW
}
Found
~
/.zshrc.
${
FMT_RESET
}
${
FMT_GREEN
}
Backing up to
${
OLD_ZSHRC
}${
FMT_RESET
}
"
echo
"
${
FMT_YELLOW
}
Found
${
zdot
}
/.zshrc.
${
FMT_RESET
}
${
FMT_GREEN
}
Backing up to
${
OLD_ZSHRC
}${
FMT_RESET
}
"
mv
~/.zshrc
"
$OLD_ZSHRC
"
mv
"
$zdot
/.zshrc"
"
$OLD_ZSHRC
"
fi
fi
echo
"
${
FMT_GREEN
}
Using the Oh My Zsh template file and adding it to ~/.zshrc.
${
FMT_RESET
}
"
echo
"
${
FMT_GREEN
}
Using the Oh My Zsh template file and adding it to
$zdot
/.zshrc.
${
FMT_RESET
}
"
# Modify $ZSH variable in .zshrc directory to use the literal $ZDOTDIR or $HOME
omz
=
"
$ZSH
"
[
-z
"
$ZDOTDIR
"
]
||
omz
=
$(
echo
"
$omz
"
|
sed
"s|^
$ZDOTDIR
/|
\$
ZDOTDIR/|"
)
omz
=
$(
echo
"
$omz
"
|
sed
"s|^
$HOME
/|
\$
HOME/|"
)
# Replace $HOME path with '$HOME' in $ZSH variable in .zshrc file
sed
"s|^export ZSH=.*
$|
export ZSH=
\"
${
omz
}
\"
|"
"
$ZSH
/templates/zshrc.zsh-template"
>
"
$zdot
/.zshrc-omztemp"
omz
=
$(
echo
"
$ZSH
"
|
sed
"s|^
$HOME
/|
\$
HOME/|"
)
mv
-f
"
$zdot
/.zshrc-omztemp"
"
$zdot
/.zshrc"
sed
"s|^export ZSH=.*
$|
export ZSH=
\"
${
omz
}
\"
|"
"
$ZSH
/templates/zshrc.zsh-template"
>
~/.zshrc-omztemp
mv
-f
~/.zshrc-omztemp ~/.zshrc
echo
echo
}
}
...
@@ -407,9 +422,9 @@ EOF
...
@@ -407,9 +422,9 @@ EOF
# We're going to change the default shell, so back up the current one
# We're going to change the default shell, so back up the current one
if
[
-n
"
$SHELL
"
]
;
then
if
[
-n
"
$SHELL
"
]
;
then
echo
"
$SHELL
"
>
~/.shell.pre-oh-my-zsh
echo
"
$SHELL
"
>
"
$zdot
/.shell.pre-oh-my-zsh"
else
else
grep
"^
$USER
:"
/etc/passwd |
awk
-F
:
'{print $7}'
>
~/.shell.pre-oh-my-zsh
grep
"^
$USER
:"
/etc/passwd |
awk
-F
:
'{print $7}'
>
"
$zdot
/.shell.pre-oh-my-zsh"
fi
fi
echo
"Changing your shell to
$zsh
..."
echo
"Changing your shell to
$zsh
..."
...
@@ -451,7 +466,7 @@ print_success() {
...
@@ -451,7 +466,7 @@ print_success() {
printf
'\n'
printf
'\n'
printf
'\n'
printf
'\n'
printf
"%s %s %s
\n
"
"Before you scream
${
FMT_BOLD
}${
FMT_YELLOW
}
Oh My Zsh!
${
FMT_RESET
}
look over the"
\
printf
"%s %s %s
\n
"
"Before you scream
${
FMT_BOLD
}${
FMT_YELLOW
}
Oh My Zsh!
${
FMT_RESET
}
look over the"
\
"
$(
fmt_code
"
$(
fmt_link
".zshrc"
"file://
$
HOME
/.zshrc"
--text
)
"
)
"
\
"
$(
fmt_code
"
$(
fmt_link
".zshrc"
"file://
$
zdot
/.zshrc"
--text
)
"
)
"
\
"file to select plugins, themes, and options."
"file to select plugins, themes, and options."
printf
'\n'
printf
'\n'
printf
'%s\n'
"• Follow us on Twitter:
$(
fmt_link @ohmyzsh https://twitter.com/ohmyzsh
)
"
printf
'%s\n'
"• Follow us on Twitter:
$(
fmt_link @ohmyzsh https://twitter.com/ohmyzsh
)
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment