62 lines
1.9 KiB
Bash
62 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
current_dir=$(dirname $(realpath "$0"))
|
|
|
|
[[ -f "$HOME/.zshenv" ]] || touch "$HOME/.zshenv"
|
|
if cat "$HOME/.zshenv" | grep -q "TERMINAL_POLYJUICE"; then
|
|
if [[ "$current_dir" != "$TERMINAL_POLYJUICE" ]]; then
|
|
line_number=$(grep -n "TERMINAL_POLYJUICE" "$HOME/.zshenv" | cut -d: -f1)
|
|
sed -i "${line_number}c\\export TERMINAL_POLYJUICE=$current_dir" "$HOME/.zshenv"
|
|
fi
|
|
else
|
|
echo "export TERMINAL_POLYJUICE=$current_dir" >> "$HOME/.zshenv"
|
|
fi
|
|
|
|
for i in "$@"; do
|
|
if [ "$i" = "install" ]; then
|
|
echo "Installing related software..."
|
|
zsh "$current_dir/function/install.sh"
|
|
if [ $? -ne 0 ]; then
|
|
echo "related software installation failed."
|
|
exit 1
|
|
fi
|
|
elif [ "$i" = "config_starship" ]; then
|
|
echo "Config Starship..."
|
|
zsh "$current_dir/function/config_starship.sh"
|
|
if [ $? -ne 0 ]; then
|
|
echo "Starship configuration failed."
|
|
exit 1
|
|
fi
|
|
elif [ "$i" = "check" ]; then
|
|
echo "Checking uninstalled software..."
|
|
zsh "$current_dir/function/check.sh"
|
|
if [ $? -ne 0 ]; then
|
|
echo "Check failed."
|
|
exit 1
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# copying $HOME/.zshrc
|
|
current_dir=$(dirname $(realpath "$0"))
|
|
|
|
if [ -f "$HOME/.zshrc" ]; then
|
|
if $(file "$HOME/.zshrc" | grep -q "symbolic link") ; then
|
|
if [[ $(readlink "$HOME/.zshrc") != "$current_dir/zshrc" ]]; then
|
|
ln -sf "$current_dir/zshrc" "$HOME/.zshrc"
|
|
fi
|
|
else
|
|
if [ ! -f "$HOME/.zshrc.bkp" ]; then
|
|
mv "$HOME/.zshrc" "$HOME/.zshrc.bkp"
|
|
ln -s "$current_dir/zshrc" "$HOME/.zshrc"
|
|
else
|
|
echo "Backup file already exists. Please remove $HOME/.zshrc.bkp and try again."
|
|
exit 1
|
|
fi
|
|
fi
|
|
else
|
|
ln -s "$current_dir/zshrc" "$HOME/.zshrc"
|
|
fi
|
|
|
|
echo "Run \"exec zsh\" to apply changes."
|
|
# exec zsh |