refactor(script/zsh-xdg-setup): Print the config before writing the file
Also make it more posix-compliant just in case
This commit is contained in:
parent
2139e16219
commit
0d5e65b823
1 changed files with 14 additions and 7 deletions
|
@ -16,17 +16,24 @@ case "$OSTYPE" in
|
||||||
BT_ADDRESS="$(system_profiler SPBluetoothDataType | grep "Address:" | head -1 | sed "s/ *Address: \(.*\)/\1/g")"
|
BT_ADDRESS="$(system_profiler SPBluetoothDataType | grep "Address:" | head -1 | sed "s/ *Address: \(.*\)/\1/g")"
|
||||||
[ "$BT_ADDRESS" = "" ] && \
|
[ "$BT_ADDRESS" = "" ] && \
|
||||||
__EXTRA="" || \
|
__EXTRA="" || \
|
||||||
__EXTRA="""
|
__EXTRA="export BT_DEVICE_ADDRESS=\"$BT_ADDRESS\""
|
||||||
export BT_DEVICE_ADDRESS=\"$BT_ADDRESS\""""
|
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
__EXTRA=""
|
__EXTRA=""
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo """#!/bin/zsh
|
echo_config() {
|
||||||
$__EXTRA
|
echo "#!/bin/zsh"
|
||||||
export ZDOTDIR=\"\${XDG_CONFIG_HOME:-\$HOME/.config}/zsh\"
|
[ "$__EXTRA" = "" ] || echo ""
|
||||||
[ -d \$ZDOTDIR ] || mkdir -p \$ZDOTDIR""" > /etc/__zshenv && \
|
echo "$__EXTRA"
|
||||||
mv -i /etc/__zshenv $ZSHENV_PATH
|
echo "export ZDOTDIR=\"\${XDG_CONFIG_HOME:-\$HOME/.config}/zsh\""
|
||||||
|
echo "[ -d \$ZDOTDIR ] || mkdir -p \$ZDOTDIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_config > /tmp/__zshenv || exit 1
|
||||||
|
echo "========/etc/zshenv========="
|
||||||
|
cat /tmp/__zshenv
|
||||||
|
echo "============================"
|
||||||
|
mv -i /tmp/__zshenv $ZSHENV_PATH
|
||||||
ln -si $ZSHENV_PATH /etc/zsh/zshenv
|
ln -si $ZSHENV_PATH /etc/zsh/zshenv
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue