mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-19 20:29:45 +01:00
fix(cli): respect ZDOTDIR
in plugin/theme change commands (#10520)
Fixes #10520
This commit is contained in:
parent
a1ec96d125
commit
8ae373130c
1 changed files with 26 additions and 23 deletions
49
lib/cli.zsh
49
lib/cli.zsh
|
@ -276,9 +276,10 @@ multi == 1 && length(\$0) > 0 {
|
|||
{ print \$0 }
|
||||
"
|
||||
|
||||
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
|
||||
&& command mv -f ~/.zshrc ~/.zshrc.bck \
|
||||
&& command mv -f ~/.zshrc.new ~/.zshrc
|
||||
local zdot="${ZDOTDIR:-$HOME}"
|
||||
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
|
||||
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
|
||||
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
|
||||
|
||||
# Exit if the new .zshrc file wasn't created correctly
|
||||
[[ $? -eq 0 ]] || {
|
||||
|
@ -288,10 +289,10 @@ multi == 1 && length(\$0) > 0 {
|
|||
}
|
||||
|
||||
# Exit if the new .zshrc file has syntax errors
|
||||
if ! zsh -n ~/.zshrc; then
|
||||
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
|
||||
command mv -f ~/.zshrc ~/.zshrc.new
|
||||
command mv -f ~/.zshrc.bck ~/.zshrc
|
||||
if ! zsh -n "$zdot/.zshrc"; then
|
||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
||||
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
|
||||
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -351,9 +352,10 @@ multi == 1 && /^[^#]*\)/ {
|
|||
{ print \$0 }
|
||||
"
|
||||
|
||||
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
|
||||
&& command mv -f ~/.zshrc ~/.zshrc.bck \
|
||||
&& command mv -f ~/.zshrc.new ~/.zshrc
|
||||
local zdot="${ZDOTDIR:-$HOME}"
|
||||
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
|
||||
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
|
||||
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
|
||||
|
||||
# Exit if the new .zshrc file wasn't created correctly
|
||||
[[ $? -eq 0 ]] || {
|
||||
|
@ -363,10 +365,10 @@ multi == 1 && /^[^#]*\)/ {
|
|||
}
|
||||
|
||||
# Exit if the new .zshrc file has syntax errors
|
||||
if ! zsh -n ~/.zshrc; then
|
||||
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
|
||||
command mv -f ~/.zshrc ~/.zshrc.new
|
||||
command mv -f ~/.zshrc.bck ~/.zshrc
|
||||
if ! zsh -n "$zdot/.zshrc"; then
|
||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
||||
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
|
||||
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -698,17 +700,18 @@ END {
|
|||
}
|
||||
'
|
||||
|
||||
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
|
||||
local zdot="${ZDOTDIR:-$HOME}"
|
||||
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
|
||||
|| {
|
||||
# Prepend ZSH_THEME= line to .zshrc if it doesn't exist
|
||||
cat <<EOF
|
||||
ZSH_THEME="$1" # set by \`omz\`
|
||||
|
||||
EOF
|
||||
cat ~/.zshrc
|
||||
} > ~/.zshrc.new \
|
||||
&& command mv -f ~/.zshrc ~/.zshrc.bck \
|
||||
&& command mv -f ~/.zshrc.new ~/.zshrc
|
||||
cat "$zdot/.zshrc"
|
||||
} > "$zdot/.zshrc.new" \
|
||||
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
|
||||
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
|
||||
|
||||
# Exit if the new .zshrc file wasn't created correctly
|
||||
[[ $? -eq 0 ]] || {
|
||||
|
@ -718,10 +721,10 @@ EOF
|
|||
}
|
||||
|
||||
# Exit if the new .zshrc file has syntax errors
|
||||
if ! zsh -n ~/.zshrc; then
|
||||
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
|
||||
command mv -f ~/.zshrc ~/.zshrc.new
|
||||
command mv -f ~/.zshrc.bck ~/.zshrc
|
||||
if ! zsh -n "$zdot/.zshrc"; then
|
||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
||||
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
|
||||
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue