mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
merge
This commit is contained in:
parent
a8c56f5231
commit
8274156fae
296 changed files with 6279 additions and 3141 deletions
|
|
@ -106,6 +106,9 @@ function parse-commit {
|
|||
message="${match[1]}"
|
||||
# remove CR characters (might be inserted in GitHub UI commit description form)
|
||||
message="${message//$'\r'/}"
|
||||
# remove lines containing only whitespace
|
||||
local nlnl=$'\n\n'
|
||||
message="${message//$'\n'[[:space:]]##$'\n'/$nlnl}"
|
||||
# skip next paragraphs (separated by two newlines or more)
|
||||
message="${message%%$'\n\n'*}"
|
||||
# ... and replace newlines with spaces
|
||||
|
|
@ -157,6 +160,94 @@ function parse-commit {
|
|||
fi
|
||||
}
|
||||
|
||||
################################
|
||||
# SUPPORTS HYPERLINKS FUNCTION #
|
||||
################################
|
||||
|
||||
# The code for checking if a terminal supports hyperlinks is copied from install.sh
|
||||
|
||||
# The [ -t 1 ] check only works when the function is not called from
|
||||
# a subshell (like in `$(...)` or `(...)`, so this hack redefines the
|
||||
# function at the top level to always return false when stdout is not
|
||||
# a tty.
|
||||
if [ -t 1 ]; then
|
||||
is_tty() {
|
||||
true
|
||||
}
|
||||
else
|
||||
is_tty() {
|
||||
false
|
||||
}
|
||||
fi
|
||||
|
||||
# This function uses the logic from supports-hyperlinks[1][2], which is
|
||||
# made by Kat Marchán (@zkat) and licensed under the Apache License 2.0.
|
||||
# [1] https://github.com/zkat/supports-hyperlinks
|
||||
# [2] https://crates.io/crates/supports-hyperlinks
|
||||
#
|
||||
# Copyright (c) 2021 Kat Marchán
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
supports_hyperlinks() {
|
||||
# $FORCE_HYPERLINK must be set and be non-zero (this acts as a logic bypass)
|
||||
if [ -n "$FORCE_HYPERLINK" ]; then
|
||||
[ "$FORCE_HYPERLINK" != 0 ]
|
||||
return $?
|
||||
fi
|
||||
|
||||
# If stdout is not a tty, it doesn't support hyperlinks
|
||||
is_tty || return 1
|
||||
|
||||
# DomTerm terminal emulator (domterm.org)
|
||||
if [ -n "$DOMTERM" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# VTE-based terminals above v0.50 (Gnome Terminal, Guake, ROXTerm, etc)
|
||||
if [ -n "$VTE_VERSION" ]; then
|
||||
[ $VTE_VERSION -ge 5000 ]
|
||||
return $?
|
||||
fi
|
||||
|
||||
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
||||
case "$TERM_PROGRAM" in
|
||||
Hyper|iTerm.app|terminology|WezTerm|vscode) return 0 ;;
|
||||
esac
|
||||
|
||||
# These termcap entries support hyperlinks
|
||||
case "$TERM" in
|
||||
xterm-kitty|alacritty|alacritty-direct) return 0 ;;
|
||||
esac
|
||||
|
||||
# xfce4-terminal supports hyperlinks
|
||||
if [ "$COLORTERM" = "xfce4-terminal" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Windows Terminal also supports hyperlinks
|
||||
if [ -n "$WT_SESSION" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Konsole supports hyperlinks, but it's an opt-in setting that can't be detected
|
||||
# https://github.com/ohmyzsh/ohmyzsh/issues/10964
|
||||
# if [ -n "$KONSOLE_VERSION" ]; then
|
||||
# return 0
|
||||
# fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#############################
|
||||
# RELEASE CHANGELOG DISPLAY #
|
||||
#############################
|
||||
|
|
@ -206,10 +297,17 @@ function display-release {
|
|||
function fmt:hash {
|
||||
#* Uses $hash from outer scope
|
||||
local hash="${1:-$hash}"
|
||||
local short_hash="${hash:0:7}" # 7 characters sha, top level sha is 12 characters
|
||||
case "$output" in
|
||||
raw) printf '%s' "$hash" ;;
|
||||
text) printf '\e[33m%s\e[0m' "$hash" ;; # red
|
||||
md) printf '[`%s`](https://github.com/ohmyzsh/ohmyzsh/commit/%s)' "$hash" "$hash" ;;
|
||||
raw) printf '%s' "$short_hash" ;;
|
||||
text)
|
||||
local text="\e[33m$short_hash\e[0m"; # red
|
||||
if supports_hyperlinks; then
|
||||
printf "\e]8;;%s\a%s\e]8;;\a" "https://github.com/ohmyzsh/ohmyzsh/commit/$hash" $text;
|
||||
else
|
||||
echo $text;
|
||||
fi ;;
|
||||
md) printf '[`%s`](https://github.com/ohmyzsh/ohmyzsh/commit/%s)' "$short_hash" "$hash" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +370,12 @@ function display-release {
|
|||
case "$output" in
|
||||
raw) printf '%s' "$subject" ;;
|
||||
# In text mode, highlight (#<issue>) and dim text between `backticks`
|
||||
text) sed -E $'s|#([0-9]+)|\e[32m#\\1\e[0m|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject" ;;
|
||||
text)
|
||||
if supports_hyperlinks; then
|
||||
sed -E $'s|#([0-9]+)|\e]8;;https://github.com/ohmyzsh/ohmyzsh/issues/\\1\a\e[32m#\\1\e[0m\e]8;;\a|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject"
|
||||
else
|
||||
sed -E $'s|#([0-9]+)|\e[32m#\\1\e[0m|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject"
|
||||
fi ;;
|
||||
# In markdown mode, link to (#<issue>) issues
|
||||
md) sed -E 's|#([0-9]+)|[#\1](https://github.com/ohmyzsh/ohmyzsh/issues/\1)|g' <<< "$subject" ;;
|
||||
esac
|
||||
|
|
@ -415,13 +518,13 @@ function main {
|
|||
# Git log options
|
||||
# -z: commits are delimited by null bytes
|
||||
# --format: [7-char hash]<field sep>[ref names]<field sep>[subject]<field sep>[body]
|
||||
# --abbrev=7: force commit hashes to be 7 characters long
|
||||
# --abbrev=7: force commit hashes to be 12 characters long
|
||||
# --no-merges: merge commits are omitted
|
||||
# --first-parent: commits from merged branches are omitted
|
||||
local SEP="0mZmAgIcSeP"
|
||||
local -a raw_commits
|
||||
raw_commits=(${(0)"$(command git -c log.showSignature=false log -z \
|
||||
--format="%h${SEP}%D${SEP}%s${SEP}%b" --abbrev=7 \
|
||||
--format="%h${SEP}%D${SEP}%s${SEP}%b" --abbrev=12 \
|
||||
--no-merges --first-parent $range)"})
|
||||
|
||||
local raw_commit
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ fi
|
|||
# - prompt (default): the user is asked before updating when it's time to update
|
||||
# - auto: the update is performed automatically when it's time
|
||||
# - reminder: a reminder is shown to the user when it's time to update
|
||||
# - background-alpha: an experimental update-on-the-background option
|
||||
# - disabled: automatic update is turned off
|
||||
zstyle -s ':omz:update' mode update_mode || {
|
||||
update_mode=prompt
|
||||
|
|
@ -91,12 +92,37 @@ function is_update_available() {
|
|||
}
|
||||
|
||||
function update_last_updated_file() {
|
||||
echo "LAST_EPOCH=$(current_epoch)" >! "${ZSH_CACHE_DIR}/.zsh-update"
|
||||
local exit_status="$1" error="$2"
|
||||
|
||||
if [[ -z "${1}${2}" ]]; then
|
||||
echo "LAST_EPOCH=$(current_epoch)" >! "${ZSH_CACHE_DIR}/.zsh-update"
|
||||
return
|
||||
fi
|
||||
|
||||
cat >! "${ZSH_CACHE_DIR}/.zsh-update" <<EOD
|
||||
LAST_EPOCH=$(current_epoch)
|
||||
EXIT_STATUS=${exit_status}
|
||||
ERROR='${error//\'/’}'
|
||||
EOD
|
||||
}
|
||||
|
||||
function update_ohmyzsh() {
|
||||
if ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive; then
|
||||
local verbose_mode
|
||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||
|
||||
if [[ "$update_mode" != background-alpha ]] \
|
||||
&& LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode; then
|
||||
update_last_updated_file
|
||||
return $?
|
||||
fi
|
||||
|
||||
local exit_status error
|
||||
if error=$(LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v silent 2>&1); then
|
||||
update_last_updated_file 0 "Update successful"
|
||||
else
|
||||
exit_status=$?
|
||||
update_last_updated_file $exit_status "$error"
|
||||
return $exit_status
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -125,87 +151,145 @@ function has_typed_input() {
|
|||
}
|
||||
}
|
||||
|
||||
() {
|
||||
emulate -L zsh
|
||||
function handle_update() {
|
||||
() {
|
||||
emulate -L zsh
|
||||
|
||||
local epoch_target mtime option LAST_EPOCH
|
||||
local epoch_target mtime option LAST_EPOCH
|
||||
|
||||
# Remove lock directory if older than a day
|
||||
zmodload zsh/datetime
|
||||
zmodload -F zsh/stat b:zstat
|
||||
if mtime=$(zstat +mtime "$ZSH/log/update.lock" 2>/dev/null); then
|
||||
if (( (mtime + 3600 * 24) < EPOCHSECONDS )); then
|
||||
command rm -rf "$ZSH/log/update.lock"
|
||||
# Remove lock directory if older than a day
|
||||
zmodload zsh/datetime
|
||||
zmodload -F zsh/stat b:zstat
|
||||
if mtime=$(zstat +mtime "$ZSH/log/update.lock" 2>/dev/null); then
|
||||
if (( (mtime + 3600 * 24) < EPOCHSECONDS )); then
|
||||
command rm -rf "$ZSH/log/update.lock"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for lock directory
|
||||
if ! command mkdir "$ZSH/log/update.lock" 2>/dev/null; then
|
||||
return
|
||||
fi
|
||||
# Check for lock directory
|
||||
if ! command mkdir "$ZSH/log/update.lock" 2>/dev/null; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Remove lock directory on exit. `return $ret` is important for when trapping a SIGINT:
|
||||
# The return status from the function is handled specially. If it is zero, the signal is
|
||||
# assumed to have been handled, and execution continues normally. Otherwise, the shell
|
||||
# will behave as interrupted except that the return status of the trap is retained.
|
||||
# This means that for a CTRL+C, the trap needs to return the same exit status so that
|
||||
# the shell actually exits what it's running.
|
||||
trap "
|
||||
ret=\$?
|
||||
unset update_mode
|
||||
unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh 2>/dev/null
|
||||
command rm -rf '$ZSH/log/update.lock'
|
||||
return \$ret
|
||||
" EXIT INT QUIT
|
||||
# Remove lock directory on exit. `return $ret` is important for when trapping a SIGINT:
|
||||
# The return status from the function is handled specially. If it is zero, the signal is
|
||||
# assumed to have been handled, and execution continues normally. Otherwise, the shell
|
||||
# will behave as interrupted except that the return status of the trap is retained.
|
||||
# This means that for a CTRL+C, the trap needs to return the same exit status so that
|
||||
# the shell actually exits what it's running.
|
||||
trap "
|
||||
ret=\$?
|
||||
unset update_mode
|
||||
unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh handle_update 2>/dev/null
|
||||
command rm -rf '$ZSH/log/update.lock'
|
||||
return \$ret
|
||||
" EXIT INT QUIT
|
||||
|
||||
# Create or update .zsh-update file if missing or malformed
|
||||
if ! source "${ZSH_CACHE_DIR}/.zsh-update" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then
|
||||
update_last_updated_file
|
||||
return
|
||||
fi
|
||||
# Create or update .zsh-update file if missing or malformed
|
||||
if ! source "${ZSH_CACHE_DIR}/.zsh-update" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then
|
||||
update_last_updated_file
|
||||
return
|
||||
fi
|
||||
|
||||
# Number of days before trying to update again
|
||||
zstyle -s ':omz:update' frequency epoch_target || epoch_target=${UPDATE_ZSH_DAYS:-13}
|
||||
# Test if enough time has passed until the next update
|
||||
if (( ( $(current_epoch) - $LAST_EPOCH ) < $epoch_target )); then
|
||||
return
|
||||
fi
|
||||
# Number of days before trying to update again
|
||||
zstyle -s ':omz:update' frequency epoch_target || epoch_target=${UPDATE_ZSH_DAYS:-13}
|
||||
# Test if enough time has passed until the next update
|
||||
if (( ( $(current_epoch) - $LAST_EPOCH ) < $epoch_target )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# Test if Oh My Zsh directory is a git repository
|
||||
if ! (builtin cd -q "$ZSH" && LANG= git rev-parse &>/dev/null); then
|
||||
echo >&2 "[oh-my-zsh] Can't update: not a git repository."
|
||||
return
|
||||
fi
|
||||
# Test if Oh My Zsh directory is a git repository
|
||||
if ! (builtin cd -q "$ZSH" && LANG= git rev-parse &>/dev/null); then
|
||||
echo >&2 "[oh-my-zsh] Can't update: not a git repository."
|
||||
return
|
||||
fi
|
||||
|
||||
# Check if there are updates available before proceeding
|
||||
if ! is_update_available; then
|
||||
return
|
||||
fi
|
||||
# Check if there are updates available before proceeding
|
||||
if ! is_update_available; then
|
||||
update_last_updated_file
|
||||
return
|
||||
fi
|
||||
|
||||
# If in reminder mode or user has typed input, show reminder and exit
|
||||
if [[ "$update_mode" = reminder ]] || has_typed_input; then
|
||||
printf '\r\e[0K' # move cursor to first column and clear whole line
|
||||
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
|
||||
return 0
|
||||
fi
|
||||
# If in reminder mode or user has typed input, show reminder and exit
|
||||
if [[ "$update_mode" = reminder ]] || { [[ "$update_mode" != background-alpha ]] && has_typed_input }; then
|
||||
printf '\r\e[0K' # move cursor to first column and clear whole line
|
||||
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Don't ask for confirmation before updating if in auto mode
|
||||
if [[ "$update_mode" = auto ]]; then
|
||||
update_ohmyzsh
|
||||
return $?
|
||||
fi
|
||||
# Don't ask for confirmation before updating if in auto mode
|
||||
if [[ "$update_mode" = (auto|background-alpha) ]]; then
|
||||
update_ohmyzsh
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Ask for confirmation and only update on 'y', 'Y' or Enter
|
||||
# Otherwise just show a reminder for how to update
|
||||
echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
|
||||
read -r -k 1 option
|
||||
[[ "$option" = $'\n' ]] || echo
|
||||
case "$option" in
|
||||
[yY$'\n']) update_ohmyzsh ;;
|
||||
[nN]) update_last_updated_file ;&
|
||||
*) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
|
||||
esac
|
||||
# Ask for confirmation and only update on 'y', 'Y' or Enter
|
||||
# Otherwise just show a reminder for how to update
|
||||
echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
|
||||
read -r -k 1 option
|
||||
[[ "$option" = $'\n' ]] || echo
|
||||
case "$option" in
|
||||
[yY$'\n']) update_ohmyzsh ;;
|
||||
[nN]) update_last_updated_file ;&
|
||||
*) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
unset update_mode
|
||||
unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh handle_update
|
||||
}
|
||||
|
||||
unset update_mode
|
||||
unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh
|
||||
case "$update_mode" in
|
||||
background-alpha)
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
_omz_bg_update() {
|
||||
# do the update in a subshell
|
||||
(handle_update) &|
|
||||
|
||||
# register update results function
|
||||
add-zsh-hook precmd _omz_bg_update_status
|
||||
|
||||
# deregister background function
|
||||
add-zsh-hook -d precmd _omz_bg_update
|
||||
unset -f _omz_bg_update
|
||||
}
|
||||
|
||||
_omz_bg_update_status() {
|
||||
{
|
||||
local LAST_EPOCH EXIT_STATUS ERROR
|
||||
if [[ ! -f "$ZSH_CACHE_DIR"/.zsh-update ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# check update results until timeout is reached
|
||||
. "$ZSH_CACHE_DIR/.zsh-update"
|
||||
if [[ -z "$EXIT_STATUS" || -z "$ERROR" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ "$EXIT_STATUS" -eq 0 ]]; then
|
||||
print -P "\n%F{green}[oh-my-zsh] Update successful.%f"
|
||||
return 0
|
||||
elif [[ "$EXIT_STATUS" -ne 0 ]]; then
|
||||
print -P "\n%F{red}[oh-my-zsh] There was an error updating:%f"
|
||||
printf "\n${fg[yellow]}%s${reset_color}" "$ERROR"
|
||||
return 0
|
||||
fi
|
||||
} always {
|
||||
if (( TRY_BLOCK_ERROR == 0 )); then
|
||||
# if last update results have been handled, remove them from the status file
|
||||
update_last_updated_file
|
||||
|
||||
# deregister background function
|
||||
add-zsh-hook -d precmd _omz_bg_update_status
|
||||
unset -f _omz_bg_update_status
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
add-zsh-hook precmd _omz_bg_update
|
||||
;;
|
||||
*)
|
||||
handle_update ;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ zdot="${ZDOTDIR:-$HOME}"
|
|||
# Default value for $ZSH
|
||||
# a) if $ZDOTDIR is supplied and not $HOME: $ZDOTDIR/ohmyzsh
|
||||
# b) otherwise, $HOME/.oh-my-zsh
|
||||
[ "$ZDOTDIR" = "$HOME" ] || ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}"
|
||||
if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then
|
||||
ZSH="${ZSH:-$ZDOTDIR/ohmyzsh}"
|
||||
fi
|
||||
ZSH="${ZSH:-$HOME/.oh-my-zsh}"
|
||||
|
||||
# Default settings
|
||||
|
|
@ -84,6 +86,10 @@ command_exists() {
|
|||
user_can_sudo() {
|
||||
# Check if sudo is installed
|
||||
command_exists sudo || return 1
|
||||
# Termux can't run sudo, so we can detect it and exit the function early.
|
||||
case "$PREFIX" in
|
||||
*com.termux*) return 1 ;;
|
||||
esac
|
||||
# The following command has 3 parts:
|
||||
#
|
||||
# 1. Run `sudo` with `-v`. Does the following:
|
||||
|
|
@ -160,11 +166,16 @@ supports_hyperlinks() {
|
|||
|
||||
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
||||
case "$TERM_PROGRAM" in
|
||||
Hyper|iTerm.app|terminology|WezTerm) return 0 ;;
|
||||
Hyper|iTerm.app|terminology|WezTerm|vscode) return 0 ;;
|
||||
esac
|
||||
|
||||
# kitty supports hyperlinks
|
||||
if [ "$TERM" = xterm-kitty ]; then
|
||||
# These termcap entries support hyperlinks
|
||||
case "$TERM" in
|
||||
xterm-kitty|alacritty|alacritty-direct) return 0 ;;
|
||||
esac
|
||||
|
||||
# xfce4-terminal supports hyperlinks
|
||||
if [ "$COLORTERM" = "xfce4-terminal" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
|
||||
old_shell=$(cat ~/.shell.pre-oh-my-zsh)
|
||||
echo "Switching your shell back to '$old_shell':"
|
||||
if chsh -s "$old_shell"; then
|
||||
rm -f ~/.shell.pre-oh-my-zsh
|
||||
else
|
||||
echo "Could not change default shell. Change it manually by running chsh"
|
||||
echo "or editing the /etc/passwd file."
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation
|
||||
if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
|
||||
echo "Uninstall cancelled"
|
||||
|
|
@ -25,16 +37,5 @@ else
|
|||
echo "No original zsh config found"
|
||||
fi
|
||||
|
||||
if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
|
||||
old_shell=$(cat ~/.shell.pre-oh-my-zsh)
|
||||
echo "Switching your shell back to '$old_shell':"
|
||||
if chsh -s "$old_shell"; then
|
||||
rm -f ~/.shell.pre-oh-my-zsh
|
||||
else
|
||||
echo "Could not change default shell. Change it manually by running chsh"
|
||||
echo "or editing the /etc/passwd file."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
|
||||
echo "Don't forget to restart your terminal!"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
#!/usr/bin/env zsh
|
||||
set +u # disable nounset
|
||||
|
||||
local ret=0 # exit code
|
||||
|
||||
# Protect against running with shells other than zsh
|
||||
if [ -z "$ZSH_VERSION" ]; then
|
||||
|
|
@ -12,6 +15,23 @@ esac
|
|||
|
||||
cd "$ZSH"
|
||||
|
||||
verbose_mode="default"
|
||||
interactive=false
|
||||
|
||||
while getopts "v:i" opt; do
|
||||
case $opt in
|
||||
v)
|
||||
if [[ $OPTARG == default || $OPTARG == minimal || $OPTARG == silent ]]; then
|
||||
verbose_mode=$OPTARG
|
||||
else
|
||||
echo "[oh-my-zsh] update verbosity '$OPTARG' is not valid"
|
||||
echo "[oh-my-zsh] valid options are 'default', 'minimal' and 'silent'"
|
||||
fi
|
||||
;;
|
||||
i) interactive=true ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Use colors, but only if connected to a terminal
|
||||
# and that terminal supports them.
|
||||
|
||||
|
|
@ -70,11 +90,16 @@ supports_hyperlinks() {
|
|||
|
||||
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
||||
case "$TERM_PROGRAM" in
|
||||
Hyper|iTerm.app|terminology|WezTerm) return 0 ;;
|
||||
Hyper|iTerm.app|terminology|WezTerm|vscode) return 0 ;;
|
||||
esac
|
||||
|
||||
# kitty supports hyperlinks
|
||||
if [ "$TERM" = xterm-kitty ]; then
|
||||
# These termcap entries support hyperlinks
|
||||
case "$TERM" in
|
||||
xterm-kitty|alacritty|alacritty-direct) return 0 ;;
|
||||
esac
|
||||
|
||||
# xfce4-terminal supports hyperlinks
|
||||
if [ "$COLORTERM" = "xfce4-terminal" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
|
@ -164,17 +189,23 @@ fi
|
|||
# Update upstream remote to ohmyzsh org
|
||||
git remote -v | while read remote url extra; do
|
||||
case "$url" in
|
||||
https://github.com/robbyrussell/oh-my-zsh(|.git))
|
||||
git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
|
||||
break ;;
|
||||
git@github.com:robbyrussell/oh-my-zsh(|.git))
|
||||
git remote set-url "$remote" "git@github.com:ohmyzsh/ohmyzsh.git"
|
||||
break ;;
|
||||
# Update out-of-date "unauthenticated git protocol on port 9418" to https
|
||||
git://github.com/robbyrussell/oh-my-zsh(|.git))
|
||||
git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
|
||||
break ;;
|
||||
# Update out-of-date "unauthenticated git protocol on port 9418" to https
|
||||
git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git" ;;
|
||||
https://github.com/robbyrussell/oh-my-zsh(|.git))
|
||||
git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git" ;;
|
||||
git@github.com:robbyrussell/oh-my-zsh(|.git))
|
||||
git remote set-url "$remote" "git@github.com:ohmyzsh/ohmyzsh.git" ;;
|
||||
https://github.com/ohmyzsh/ohmyzsh(|.git)) ;;
|
||||
git@github.com:ohmyzsh/ohmyzsh(|.git)) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
|
||||
# If we reach this point we have found the proper ohmyzsh upstream remote. If we don't,
|
||||
# we'll only update from the set remote if `oh-my-zsh.remote` has been set to a remote,
|
||||
# as when installing from a fork.
|
||||
git config --local oh-my-zsh.remote "$remote"
|
||||
break
|
||||
done
|
||||
|
||||
# Set git-config values known to fix git errors
|
||||
|
|
@ -203,7 +234,9 @@ git checkout -q "$branch" -- || exit 1
|
|||
last_commit=$(git rev-parse "$branch")
|
||||
|
||||
# Update Oh My Zsh
|
||||
printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
|
||||
if [[ $verbose_mode != silent ]]; then
|
||||
printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
|
||||
fi
|
||||
if LANG= git pull --quiet --rebase $remote $branch; then
|
||||
# Check if it was really updated or not
|
||||
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
|
||||
|
|
@ -215,24 +248,30 @@ if LANG= git pull --quiet --rebase $remote $branch; then
|
|||
git config oh-my-zsh.lastVersion "$last_commit"
|
||||
|
||||
# Print changelog to the terminal
|
||||
if [[ "$1" = --interactive ]]; then
|
||||
if [[ $interactive == true && $verbose_mode == default ]]; then
|
||||
"$ZSH/tools/changelog.sh" HEAD "$last_commit"
|
||||
fi
|
||||
|
||||
printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog with" "omz changelog"
|
||||
if [[ $verbose_mode != silent ]]; then
|
||||
printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog with" "omz changelog"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
|
||||
printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
|
||||
printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET
|
||||
printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET
|
||||
printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
|
||||
printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET
|
||||
printf '\n'
|
||||
printf "${BLUE}%s${RESET}\n\n" "$message"
|
||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "$(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
|
||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Want to get involved in the community? Join our Discord:" "$(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
|
||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Get your Oh My Zsh swag at:" "$(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
|
||||
if [[ $verbose_mode == default ]]; then
|
||||
printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
|
||||
printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
|
||||
printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET
|
||||
printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET
|
||||
printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
|
||||
printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET
|
||||
printf '\n'
|
||||
printf "${BLUE}%s${RESET}\n\n" "$message"
|
||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "$(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
|
||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Want to get involved in the community? Join our Discord:" "$(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
|
||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Get your Oh My Zsh swag at:" "$(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
|
||||
elif [[ $verbose_mode == minimal ]]; then
|
||||
printf "${BLUE}%s${RESET}\n" "$message"
|
||||
fi
|
||||
else
|
||||
ret=$?
|
||||
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue