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
098bcda6
Unverified
Commit
098bcda6
authored
Sep 09, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(update): allow updating from branch set up on install
Closes #8788 Co-authored-by:
Nikolas Garofil
<
nikolas@garofil.be
>
parent
7ded6752
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
22 deletions
+37
-22
install.sh
tools/install.sh
+22
-20
upgrade.sh
tools/upgrade.sh
+15
-2
No files found.
tools/install.sh
View file @
098bcda6
...
...
@@ -53,7 +53,7 @@ KEEP_ZSHRC=${KEEP_ZSHRC:-no}
command_exists
()
{
command
-v
"
$@
"
>
/dev/null 2>&1
command
-v
"
$@
"
>
/dev/null 2>&1
}
fmt_error
()
{
...
...
@@ -65,27 +65,27 @@ fmt_underline() {
}
fmt_code
()
{
# shellcheck disable=SC2016 # backtic in single-quote
# shellcheck disable=SC2016 # backtic
k
in single-quote
printf
'`\033[38;5;247m%s%s`\n'
"
$*
"
"
$RESET
"
}
setup_color
()
{
# Only use colors if connected to a terminal
if
[
-t
1
]
;
then
RED
=
$(
printf
'\033[31m'
)
GREEN
=
$(
printf
'\033[32m'
)
YELLOW
=
$(
printf
'\033[33m'
)
BLUE
=
$(
printf
'\033[34m'
)
BOLD
=
$(
printf
'\033[1m'
)
RESET
=
$(
printf
'\033[m'
)
else
RED
=
""
GREEN
=
""
YELLOW
=
""
BLUE
=
""
BOLD
=
""
RESET
=
""
fi
# Only use colors if connected to a terminal
if
[
-t
1
]
;
then
RED
=
$(
printf
'\033[31m'
)
GREEN
=
$(
printf
'\033[32m'
)
YELLOW
=
$(
printf
'\033[33m'
)
BLUE
=
$(
printf
'\033[34m'
)
BOLD
=
$(
printf
'\033[1m'
)
RESET
=
$(
printf
'\033[m'
)
else
RED
=
""
GREEN
=
""
YELLOW
=
""
BLUE
=
""
BOLD
=
""
RESET
=
""
fi
}
setup_ohmyzsh
()
{
...
...
@@ -114,6 +114,8 @@ setup_ohmyzsh() {
-c
fsck.zeroPaddedFilemode
=
ignore
\
-c
fetch.fsck.zeroPaddedFilemode
=
ignore
\
-c
receive.fsck.zeroPaddedFilemode
=
ignore
\
-c
oh-my-zsh.remote
=
origin
\
-c
oh-my-zsh.branch
=
"
$BRANCH
"
\
--depth
=
1
--branch
"
$BRANCH
"
"
$REMOTE
"
"
$ZSH
"
||
{
fmt_error
"git clone of oh-my-zsh repo failed"
exit
1
...
...
@@ -157,9 +159,9 @@ setup_zshrc() {
sed
"/^export ZSH=/ c
\\
export ZSH=
\"
$ZSH
\"
"
"
$ZSH
/templates/zshrc.zsh-template"
>
~/.zshrc-omztemp
mv
-f
~/.zshrc-omztemp ~/.zshrc
mv
-f
~/.zshrc-omztemp ~/.zshrc
echo
echo
}
setup_shell
()
{
...
...
tools/upgrade.sh
View file @
098bcda6
...
...
@@ -66,10 +66,20 @@ git config rebase.autoStash true
local
ret
=
0
# repository settings
remote
=
${
"
$(
git config
--local
oh-my-zsh.remote
)
"
:-
origin
}
branch
=
${
"
$(
git config
--local
oh-my-zsh.branch
)
"
:-
master
}
# repository state
last_head
=
$(
git symbolic-ref
--quiet
--short
HEAD
||
git rev-parse HEAD
)
# checkout update branch
git checkout
-q
"
$branch
"
--
||
exit
1
# branch commit before update (used in changelog)
last_commit
=
$(
git rev-parse
"
$branch
"
)
# Update Oh My Zsh
printf
"
${
BLUE
}
%s
${
RESET
}
\n
"
"Updating Oh My Zsh"
last_commit
=
$(
git rev-parse HEAD
)
if
git pull
--rebase
--stat
origin master
;
then
if
git pull
--rebase
--stat
$remote
$branch
;
then
# Check if it was really updated or not
if
[[
"
$(
git rev-parse HEAD
)
"
=
"
$last_commit
"
]]
;
then
message
=
"Oh My Zsh is already at the latest version."
...
...
@@ -103,6 +113,9 @@ else
printf
"
${
RED
}
%s
${
RESET
}
\n
"
'There was an error updating. Try again later?'
fi
# go back to HEAD previous to update
git checkout
-q
"
$last_head
"
--
# Unset git-config values set just for the upgrade
case
"
$resetAutoStash
"
in
""
)
git config
--unset
rebase.autoStash
;;
...
...
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