Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
c7221c5f
Unverified
Commit
c7221c5f
authored
Jan 24, 2022
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style(installer): prefix formatting variables with `FMT_`
parent
3f5402e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
39 deletions
+39
-39
install.sh
tools/install.sh
+39
-39
No files found.
tools/install.sh
View file @
c7221c5f
...
@@ -190,24 +190,24 @@ fmt_code() {
...
@@ -190,24 +190,24 @@ fmt_code() {
}
}
fmt_error
()
{
fmt_error
()
{
printf
'%sError: %s%s\n'
"
$
BOLD$RED
"
"
$*
"
"
$
RESET
"
>
&2
printf
'%sError: %s%s\n'
"
$
{
FMT_BOLD
}${
FMT_RED
}
"
"
$*
"
"
$FMT_
RESET
"
>
&2
}
}
setup_color
()
{
setup_color
()
{
# Only use colors if connected to a terminal
# Only use colors if connected to a terminal
if
!
is_tty
;
then
if
!
is_tty
;
then
RAINBOW
=
""
FMT_
RAINBOW
=
""
RED
=
""
FMT_
RED
=
""
GREEN
=
""
FMT_
GREEN
=
""
YELLOW
=
""
FMT_
YELLOW
=
""
BLUE
=
""
FMT_
BLUE
=
""
BOLD
=
""
FMT_
BOLD
=
""
RESET
=
""
FMT_
RESET
=
""
return
return
fi
fi
if
supports_truecolor
;
then
if
supports_truecolor
;
then
RAINBOW
=
"
FMT_
RAINBOW
=
"
$(
printf
'\033[38;2;255;0;0m'
)
$(
printf
'\033[38;2;255;0;0m'
)
$(
printf
'\033[38;2;255;97;0m'
)
$(
printf
'\033[38;2;255;97;0m'
)
$(
printf
'\033[38;2;247;255;0m'
)
$(
printf
'\033[38;2;247;255;0m'
)
...
@@ -217,7 +217,7 @@ setup_color() {
...
@@ -217,7 +217,7 @@ setup_color() {
$(
printf
'\033[38;2;245;0;172m'
)
$(
printf
'\033[38;2;245;0;172m'
)
"
"
else
else
RAINBOW
=
"
FMT_
RAINBOW
=
"
$(
printf
'\033[38;5;196m'
)
$(
printf
'\033[38;5;196m'
)
$(
printf
'\033[38;5;202m'
)
$(
printf
'\033[38;5;202m'
)
$(
printf
'\033[38;5;226m'
)
$(
printf
'\033[38;5;226m'
)
...
@@ -228,12 +228,12 @@ setup_color() {
...
@@ -228,12 +228,12 @@ setup_color() {
"
"
fi
fi
RED
=
$(
printf
'\033[31m'
)
FMT_
RED
=
$(
printf
'\033[31m'
)
GREEN
=
$(
printf
'\033[32m'
)
FMT_
GREEN
=
$(
printf
'\033[32m'
)
YELLOW
=
$(
printf
'\033[33m'
)
FMT_
YELLOW
=
$(
printf
'\033[33m'
)
BLUE
=
$(
printf
'\033[34m'
)
FMT_
BLUE
=
$(
printf
'\033[34m'
)
BOLD
=
$(
printf
'\033[1m'
)
FMT_
BOLD
=
$(
printf
'\033[1m'
)
RESET
=
$(
printf
'\033[0m'
)
FMT_
RESET
=
$(
printf
'\033[0m'
)
}
}
setup_ohmyzsh
()
{
setup_ohmyzsh
()
{
...
@@ -244,7 +244,7 @@ setup_ohmyzsh() {
...
@@ -244,7 +244,7 @@ setup_ohmyzsh() {
# precedence over umasks except for filesystems mounted with option "noacl".
# precedence over umasks except for filesystems mounted with option "noacl".
umask
g-w,o-w
umask
g-w,o-w
echo
"
${
BLUE
}
Cloning Oh My Zsh...
${
RESET
}
"
echo
"
${
FMT_BLUE
}
Cloning Oh My Zsh...
${
FMT_
RESET
}
"
command_exists git
||
{
command_exists git
||
{
fmt_error
"git is not installed"
fmt_error
"git is not installed"
...
@@ -276,14 +276,14 @@ setup_zshrc() {
...
@@ -276,14 +276,14 @@ setup_zshrc() {
# Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones
# Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones
# with datestamp of installation that moved them aside, so we never actually
# with datestamp of installation that moved them aside, so we never actually
# destroy a user's original zshrc
# destroy a user's original zshrc
echo
"
${
BLUE
}
Looking for an existing zsh config...
${
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
=
~/.zshrc.pre-oh-my-zsh
if
[
-f
~/.zshrc
]
||
[
-h
~/.zshrc
]
;
then
if
[
-f
~/.zshrc
]
||
[
-h
~/.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
"
${
YELLOW
}
Found ~/.zshrc.
${
RESET
}
${
GREEN
}
Keeping...
${
RESET
}
"
echo
"
${
FMT_YELLOW
}
Found ~/.zshrc.
${
FMT_RESET
}
${
FMT_GREEN
}
Keeping...
${
FMT_
RESET
}
"
return
return
fi
fi
if
[
-e
"
$OLD_ZSHRC
"
]
;
then
if
[
-e
"
$OLD_ZSHRC
"
]
;
then
...
@@ -295,14 +295,14 @@ setup_zshrc() {
...
@@ -295,14 +295,14 @@ setup_zshrc() {
fi
fi
mv
"
$OLD_ZSHRC
"
"
${
OLD_OLD_ZSHRC
}
"
mv
"
$OLD_ZSHRC
"
"
${
OLD_OLD_ZSHRC
}
"
echo
"
${
YELLOW
}
Found old ~/.zshrc.pre-oh-my-zsh."
\
echo
"
${
FMT_
YELLOW
}
Found old ~/.zshrc.pre-oh-my-zsh."
\
"
${
GREEN
}
Backing up to
${
OLD_OLD_ZSHRC
}${
RESET
}
"
"
${
FMT_GREEN
}
Backing up to
${
OLD_OLD_ZSHRC
}${
FMT_
RESET
}
"
fi
fi
echo
"
${
YELLOW
}
Found ~/.zshrc.
${
RESET
}
${
GREEN
}
Backing up to
${
OLD_ZSHRC
}${
RESET
}
"
echo
"
${
FMT_YELLOW
}
Found ~/.zshrc.
${
FMT_RESET
}
${
FMT_GREEN
}
Backing up to
${
OLD_ZSHRC
}${
FMT_
RESET
}
"
mv
~/.zshrc
"
$OLD_ZSHRC
"
mv
~/.zshrc
"
$OLD_ZSHRC
"
fi
fi
echo
"
${
GREEN
}
Using the Oh My Zsh template file and adding it to ~/.zshrc.
${
RESET
}
"
echo
"
${
FMT_GREEN
}
Using the Oh My Zsh template file and adding it to ~/.zshrc.
${
FMT_
RESET
}
"
# Replace $HOME path with '$HOME' in $ZSH variable in .zshrc file
# Replace $HOME path with '$HOME' in $ZSH variable in .zshrc file
omz
=
$(
echo
"
$ZSH
"
|
sed
"s|^
$HOME
/|
\$
HOME/|"
)
omz
=
$(
echo
"
$ZSH
"
|
sed
"s|^
$HOME
/|
\$
HOME/|"
)
...
@@ -327,16 +327,16 @@ setup_shell() {
...
@@ -327,16 +327,16 @@ setup_shell() {
if
!
command_exists chsh
;
then
if
!
command_exists chsh
;
then
cat
<<
EOF
cat
<<
EOF
I can't change your shell automatically because this system does not have chsh.
I can't change your shell automatically because this system does not have chsh.
${
BLUE
}
Please manually change your default shell to zsh
${
RESET
}
${
FMT_BLUE
}
Please manually change your default shell to zsh
${
FMT_
RESET
}
EOF
EOF
return
return
fi
fi
echo
"
${
BLUE
}
Time to change your default shell to zsh:
${
RESET
}
"
echo
"
${
FMT_BLUE
}
Time to change your default shell to zsh:
${
FMT_
RESET
}
"
# Prompt for user choice on changing the default login shell
# Prompt for user choice on changing the default login shell
printf
'%sDo you want to change your default shell to zsh? [Y/n]%s '
\
printf
'%sDo you want to change your default shell to zsh? [Y/n]%s '
\
"
$
YELLOW
"
"
$
RESET
"
"
$
FMT_YELLOW
"
"
$FMT_
RESET
"
read
-r
opt
read
-r
opt
case
$opt
in
case
$opt
in
y
*
|
Y
*
|
""
)
;;
y
*
|
Y
*
|
""
)
;;
...
@@ -402,30 +402,30 @@ EOF
...
@@ -402,30 +402,30 @@ EOF
fmt_error
"chsh command unsuccessful. Change your default shell manually."
fmt_error
"chsh command unsuccessful. Change your default shell manually."
else
else
export
SHELL
=
"
$zsh
"
export
SHELL
=
"
$zsh
"
echo
"
${
GREEN
}
Shell successfully changed to '
$zsh
'.
${
RESET
}
"
echo
"
${
FMT_GREEN
}
Shell successfully changed to '
$zsh
'.
${
FMT_
RESET
}
"
fi
fi
echo
echo
}
}
# shellcheck disable=SC2183 # printf string has more %s than arguments ($RAINBOW expands to multiple arguments)
# shellcheck disable=SC2183 # printf string has more %s than arguments ($
FMT_
RAINBOW expands to multiple arguments)
print_success
()
{
print_success
()
{
printf
'%s %s__ %s %s %s %s %s__ %s\n'
$
RAINBOW
$
RESET
printf
'%s %s__ %s %s %s %s %s__ %s\n'
$
FMT_RAINBOW
$FMT_
RESET
printf
'%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n'
$
RAINBOW
$
RESET
printf
'%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n'
$
FMT_RAINBOW
$FMT_
RESET
printf
'%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n'
$
RAINBOW
$
RESET
printf
'%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n'
$
FMT_RAINBOW
$FMT_
RESET
printf
'%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n'
$
RAINBOW
$
RESET
printf
'%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n'
$
FMT_RAINBOW
$FMT_
RESET
printf
'%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n'
$
RAINBOW
$
RESET
printf
'%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n'
$
FMT_RAINBOW
$FMT_
RESET
printf
'%s %s %s %s /____/ %s %s %s %s....is now installed!%s\n'
$
RAINBOW
$GREEN
$
RESET
printf
'%s %s %s %s /____/ %s %s %s %s....is now installed!%s\n'
$
FMT_RAINBOW
$FMT_GREEN
$FMT_
RESET
printf
'\n'
printf
'\n'
printf
'\n'
printf
'\n'
printf
"%s %s %s
\n
"
"Before you scream
${
BOLD
}${
YELLOW
}
Oh My Zsh!
${
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://
$HOME
/.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
)
"
printf
'%s\n'
"• Join our Discord community:
$(
fmt_link
"Discord server"
https://discord.gg/ohmyzsh
)
"
printf
'%s\n'
"• Join our Discord community:
$(
fmt_link
"Discord server"
https://discord.gg/ohmyzsh
)
"
printf
'%s\n'
"• Get stickers, t-shirts, coffee mugs and more:
$(
fmt_link
"Planet Argon Shop"
https://shop.planetargon.com/collections/oh-my-zsh
)
"
printf
'%s\n'
"• Get stickers, t-shirts, coffee mugs and more:
$(
fmt_link
"Planet Argon Shop"
https://shop.planetargon.com/collections/oh-my-zsh
)
"
printf
'%s\n'
$RESET
printf
'%s\n'
$
FMT_
RESET
}
}
main
()
{
main
()
{
...
@@ -448,12 +448,12 @@ main() {
...
@@ -448,12 +448,12 @@ main() {
setup_color
setup_color
if
!
command_exists zsh
;
then
if
!
command_exists zsh
;
then
echo
"
${
YELLOW
}
Zsh is not installed.
${
RESET
}
Please install zsh first."
echo
"
${
FMT_YELLOW
}
Zsh is not installed.
${
FMT_
RESET
}
Please install zsh first."
exit
1
exit
1
fi
fi
if
[
-d
"
$ZSH
"
]
;
then
if
[
-d
"
$ZSH
"
]
;
then
echo
"
${
YELLOW
}
The
\$
ZSH folder already exists (
$ZSH
).
${
RESET
}
"
echo
"
${
FMT_YELLOW
}
The
\$
ZSH folder already exists (
$ZSH
).
${
FMT_
RESET
}
"
if
[
"
$custom_zsh
"
=
yes
]
;
then
if
[
"
$custom_zsh
"
=
yes
]
;
then
cat
<<
EOF
cat
<<
EOF
...
@@ -481,7 +481,7 @@ EOF
...
@@ -481,7 +481,7 @@ EOF
print_success
print_success
if
[
$RUNZSH
=
no
]
;
then
if
[
$RUNZSH
=
no
]
;
then
echo
"
${
YELLOW
}
Run zsh to try it out.
${
RESET
}
"
echo
"
${
FMT_YELLOW
}
Run zsh to try it out.
${
FMT_
RESET
}
"
exit
exit
fi
fi
...
...
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