forked from extern/ohmyzsh
fix(cli): respect ZDOTDIR
in plugin/theme change commands (#10520)
Fixes #10520
This commit is contained in:
parent
a1ec96d125
commit
8ae373130c
49
lib/cli.zsh
49
lib/cli.zsh
@ -276,9 +276,10 @@ multi == 1 && length(\$0) > 0 {
|
|||||||
{ print \$0 }
|
{ print \$0 }
|
||||||
"
|
"
|
||||||
|
|
||||||
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
|
local zdot="${ZDOTDIR:-$HOME}"
|
||||||
&& command mv -f ~/.zshrc ~/.zshrc.bck \
|
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
|
||||||
&& command mv -f ~/.zshrc.new ~/.zshrc
|
&& 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
|
# Exit if the new .zshrc file wasn't created correctly
|
||||||
[[ $? -eq 0 ]] || {
|
[[ $? -eq 0 ]] || {
|
||||||
@ -288,10 +289,10 @@ multi == 1 && length(\$0) > 0 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Exit if the new .zshrc file has syntax errors
|
# Exit if the new .zshrc file has syntax errors
|
||||||
if ! zsh -n ~/.zshrc; then
|
if ! zsh -n "$zdot/.zshrc"; then
|
||||||
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
|
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
||||||
command mv -f ~/.zshrc ~/.zshrc.new
|
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
|
||||||
command mv -f ~/.zshrc.bck ~/.zshrc
|
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -351,9 +352,10 @@ multi == 1 && /^[^#]*\)/ {
|
|||||||
{ print \$0 }
|
{ print \$0 }
|
||||||
"
|
"
|
||||||
|
|
||||||
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
|
local zdot="${ZDOTDIR:-$HOME}"
|
||||||
&& command mv -f ~/.zshrc ~/.zshrc.bck \
|
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
|
||||||
&& command mv -f ~/.zshrc.new ~/.zshrc
|
&& 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
|
# Exit if the new .zshrc file wasn't created correctly
|
||||||
[[ $? -eq 0 ]] || {
|
[[ $? -eq 0 ]] || {
|
||||||
@ -363,10 +365,10 @@ multi == 1 && /^[^#]*\)/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Exit if the new .zshrc file has syntax errors
|
# Exit if the new .zshrc file has syntax errors
|
||||||
if ! zsh -n ~/.zshrc; then
|
if ! zsh -n "$zdot/.zshrc"; then
|
||||||
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
|
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
||||||
command mv -f ~/.zshrc ~/.zshrc.new
|
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
|
||||||
command mv -f ~/.zshrc.bck ~/.zshrc
|
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
|
||||||
return 1
|
return 1
|
||||||
fi
|
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
|
# Prepend ZSH_THEME= line to .zshrc if it doesn't exist
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
ZSH_THEME="$1" # set by \`omz\`
|
ZSH_THEME="$1" # set by \`omz\`
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
cat ~/.zshrc
|
cat "$zdot/.zshrc"
|
||||||
} > ~/.zshrc.new \
|
} > "$zdot/.zshrc.new" \
|
||||||
&& command mv -f ~/.zshrc ~/.zshrc.bck \
|
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
|
||||||
&& command mv -f ~/.zshrc.new ~/.zshrc
|
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
|
||||||
|
|
||||||
# Exit if the new .zshrc file wasn't created correctly
|
# Exit if the new .zshrc file wasn't created correctly
|
||||||
[[ $? -eq 0 ]] || {
|
[[ $? -eq 0 ]] || {
|
||||||
@ -718,10 +721,10 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Exit if the new .zshrc file has syntax errors
|
# Exit if the new .zshrc file has syntax errors
|
||||||
if ! zsh -n ~/.zshrc; then
|
if ! zsh -n "$zdot/.zshrc"; then
|
||||||
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
|
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
||||||
command mv -f ~/.zshrc ~/.zshrc.new
|
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
|
||||||
command mv -f ~/.zshrc.bck ~/.zshrc
|
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user