3935ccce647c722bcfdaa771b01613079db20935

Author
Dario Vladović <d.vladimyr@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

cli: add update command (#9094)

Co-authored-by: Marc Cornellà <marc.cornella@live.com>

Diff

 1diff --git a/lib/cli.zsh b/lib/cli.zsh
 2index 73ac5a8463f94d4b3503913cd4dedcdb01337944..3c09cdab82c45603ff3130009249389274d97d3e 100644
 3--- a/lib/cli.zsh
 4+++ b/lib/cli.zsh
 5@@ -23,6 +23,7 @@ function _omz {
 6     local -a cmds subcmds
 7     cmds=(
 8         'help:Usage information'
 9+        'update:Update Oh My Zsh'
10         'pr:Commands for Oh My Zsh Pull Requests'
11     )
12 
13@@ -48,6 +49,7 @@ Usage: omz <command> [options]
14 Available commands:
15 
16     help                Print this help message
17+    update              Update Oh My Zsh
18     pr <command>        Commands for Oh My Zsh Pull Requests
19 
20 EOF
21@@ -197,3 +199,12 @@ function _omz::pr::test {
22         }
23     )
24 }
25+
26+function _omz::update {
27+    env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
28+    # Update last updated file
29+    zmodload zsh/datetime
30+    echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
31+    # Remove update lock if it exists
32+    command rm -rf "$ZSH/log/update.lock"
33+}
34diff --git a/lib/functions.zsh b/lib/functions.zsh
35index 678e29ce7b3de5f8d2d8fadff677e3a3e536cdbe..e85b867a56824b9bf11e86a772340ef85ced21dd 100644
36--- a/lib/functions.zsh
37+++ b/lib/functions.zsh
38@@ -7,8 +7,8 @@ function uninstall_oh_my_zsh() {
39 }
40 
41 function upgrade_oh_my_zsh() {
42-  env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
43-  command rm -rf "$ZSH/log/update.lock"
44+  echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
45+  omz update
46 }
47 
48 function take() {