update check functions

This commit is contained in:
2026-01-23 10:57:23 +08:00
parent 771604ecba
commit 85a41413a3
4 changed files with 52 additions and 52 deletions

View File

@@ -2,27 +2,27 @@
function check_zsh_polyjuice() { function check_zsh_polyjuice() {
# check for zsh-autosuggestions # check for zsh-autosuggestions
if [[ ! -f $ZSH_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then if [[ ! -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
echo "zsh-autosuggestions is not installed." echo "zsh-autosuggestions is not installed."
fi fi
# check for zsh-syntax-highlighting # check for zsh-syntax-highlighting
if [[ ! -f $ZSH_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then if [[ ! -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
echo "zsh-syntax-highlighting is not installed." echo "zsh-syntax-highlighting is not installed."
fi fi
# check for zsh-autocomplete # check for zsh-autocomplete
if [[ ! -f $ZSH_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh ]]; then if [[ ! -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh ]]; then
echo "zsh-autocomplete is not installed." echo "zsh-autocomplete is not installed."
fi fi
# check for fzf-tab # check for fzf-tab
if [[ ! -f $ZSH_PLUGINS_PATH/fzf-tab/fzf-tab.zsh ]]; then if [[ ! -f $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.zsh ]]; then
echo "fzf-tab is not installed." echo "fzf-tab is not installed."
fi fi
# check for oh-my-zsh # check for oh-my-zsh
if [[ ! -d $ZSH_PLUGINS_PATH/ohmyzsh ]]; then if [[ ! -d $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh ]]; then
echo "oh-my-zsh is not installed." echo "oh-my-zsh is not installed."
fi fi
@@ -45,8 +45,8 @@ function check_zsh_polyjuice() {
if (( ! $+commands[python3] )); then if (( ! $+commands[python3] )); then
echo "python3 is not installed." echo "python3 is not installed."
fi fi
echo "Using `install_plugins` function to install missing plugins." echo "Using \`install_plugins\` function to install missing plugins."
} }
function check_tools() { function check_tools() {

View File

@@ -1,24 +1,24 @@
function startship_polyjuice() { function startship_polyjuice() {
if [ ! -n "${STARSHIP_CONFIG_FILE}" ]; then if [ ! -n "${ZSH_POLYJUICE_STARSHIP_CONFIG_FILE}" ]; then
echo "STARSHIP_CONFIG_FILE is not set. Please source `\$HOME/.zshrc` first." echo "STARSHIP_CONFIG_FILE is not set. Please source `\$HOME/.zshrc` first."
return return
fi fi
starship_config_file="$HOME/.config/starship.toml" starship_config_file="$HOME/.config/starship.toml"
if [ -f $starship_config_file ]; then if [ -f $starship_config_file ]; then
if $(file "$starship_config_file" | grep -q "symbolic link") ; then if $(file "$starship_config_file" | grep -q "symbolic link") ; then
if [[ $(readlink "$starship_config_file") != $(realpath "$STARSHIP_CONFIG_FILE") ]]; then if [[ $(readlink "$starship_config_file") != $(realpath "$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE") ]]; then
ln -sf "$STARSHIP_CONFIG_FILE" "$starship_config_file" ln -sf "$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE" "$starship_config_file"
fi fi
else else
if [ ! -f "$starship_config_file.bkp" ]; then if [ ! -f "$starship_config_file.bkp" ]; then
mv "$starship_config_file" "$starship_config_file.bkp" mv "$starship_config_file" "$starship_config_file.bkp"
ln -s "$STARSHIP_CONFIG_FILE" "$starship_config_file" ln -s "$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE" "$starship_config_file"
else else
echo "Backup file already exists. Please remove $starship_config_file.bkp and try again." echo "Backup file already exists. Please remove $starship_config_file.bkp and try again."
return return
fi fi
fi fi
else else
ln -sf "$STARSHIP_CONFIG_FILE" "$starship_config_file" ln -sf "$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE" "$starship_config_file"
fi fi
} }

View File

@@ -4,20 +4,20 @@ function install_plugins() {
return return
fi fi
if [ ! -n "${ZSH_PLUGINS_PATH}" ]; then if [ ! -n "${ZSH_POLYJUICE_PLUGINS_PATH}" ]; then
echo "ZSH_PLUGINS_PATH is not set. Please set it and try again." echo "ZSH_POLYJUICE_PLUGINS_PATH is not set. Please set it and try again."
return return
fi fi
# git clone zsh-autosuggestions # git clone zsh-autosuggestions
if [ ! -d "$ZSH_PLUGINS_PATH"/zsh-autosuggestions ]; then if [ ! -d "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-autosuggestions ]; then
echo "Zsh Autosuggestions is not downloaded. Downloading..." echo "Zsh Autosuggestions is not downloaded. Downloading..."
# git clone https://github.com/zsh-users/zsh-autosuggestions.git "$ZSH_PLUGINS_PATH"/zsh-autosuggestions # git clone https://github.com/zsh-users/zsh-autosuggestions.git "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-autosuggestions
git clone https://gitee.com/mirrors/zsh-autosuggestions.git "$ZSH_PLUGINS_PATH"/zsh-autosuggestions git clone https://gitee.com/mirrors/zsh-autosuggestions.git "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-autosuggestions
else else
cd "$ZSH_PLUGINS_PATH"/zsh-autosuggestions cd "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-autosuggestions
if [ ! -d .git ]; then if [ ! -d .git ]; then
echo "Zsh Autosuggestions is not a git repository. Please remove $ZSH_PLUGINS_PATH/zsh-autosuggestions and try again." echo "Zsh Autosuggestions is not a git repository. Please remove $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autosuggestions and try again."
else else
echo "Zsh Autosuggestions is already exist. Updating..." echo "Zsh Autosuggestions is already exist. Updating..."
git pull git pull
@@ -26,14 +26,14 @@ function install_plugins() {
fi fi
# git clone zsh-syntax-highlighting # git clone zsh-syntax-highlighting
if [ ! -d "$ZSH_PLUGINS_PATH"/zsh-syntax-highlighting ]; then if [ ! -d "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-syntax-highlighting ]; then
echo "Zsh Syntax Highlighting is not downloaded. Downloading..." echo "Zsh Syntax Highlighting is not downloaded. Downloading..."
# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_PLUGINS_PATH"/zsh-syntax-highlighting # git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-syntax-highlighting
git clone https://gitee.com/mirrors/zsh-syntax-highlighting.git "$ZSH_PLUGINS_PATH"/zsh-syntax-highlighting git clone https://gitee.com/mirrors/zsh-syntax-highlighting.git "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-syntax-highlighting
else else
cd "$ZSH_PLUGINS_PATH"/zsh-syntax-highlighting cd "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-syntax-highlighting
if [ ! -d .git ]; then if [ ! -d .git ]; then
echo "Zsh Syntax Highlighting is not a git repository. Please remove $ZSH_PLUGINS_PATH/zsh-syntax-highlighting and try again." echo "Zsh Syntax Highlighting is not a git repository. Please remove $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting and try again."
else else
echo "Zsh Syntax Highlighting is already exist. Updating..." echo "Zsh Syntax Highlighting is already exist. Updating..."
git pull git pull
@@ -42,14 +42,14 @@ function install_plugins() {
fi fi
# git clone zsh-autocomplete # git clone zsh-autocomplete
if [ ! -d "$ZSH_PLUGINS_PATH"/zsh-autocomplete ]; then if [ ! -d "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-autocomplete ]; then
echo "Zsh Autocomplete is not downloaded. Downloading..." echo "Zsh Autocomplete is not downloaded. Downloading..."
# git clone https://github.com/marlonrichert/zsh-autocomplete.git "$ZSH_PLUGINS_PATH"/zsh-autocomplete # git clone https://github.com/marlonrichert/zsh-autocomplete.git "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-autocomplete
git clone https://gitee.com/mirrors/zsh-autocomplete.git "$ZSH_PLUGINS_PATH"/zsh-autocomplete git clone https://gitee.com/mirrors/zsh-autocomplete.git "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-autocomplete
else else
cd "$ZSH_PLUGINS_PATH"/zsh-autocomplete cd "$ZSH_POLYJUICE_PLUGINS_PATH"/zsh-autocomplete
if [ ! -d .git ]; then if [ ! -d .git ]; then
echo "Zsh Autocomplete is not a git repository. Please remove $ZSH_PLUGINS_PATH/zsh-autocomplete and try again." echo "Zsh Autocomplete is not a git repository. Please remove $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autocomplete and try again."
else else
echo "Zsh Autocomplete is already exist. Updating..." echo "Zsh Autocomplete is already exist. Updating..."
git pull git pull
@@ -58,13 +58,13 @@ function install_plugins() {
fi fi
# git clone fzf-tab # git clone fzf-tab
if [ ! -d "$ZSH_PLUGINS_PATH"/fzf-tab ]; then if [ ! -d "$ZSH_POLYJUICE_PLUGINS_PATH"/fzf-tab ]; then
echo "fzf-tab is not downloaded. Downloading..." echo "fzf-tab is not downloaded. Downloading..."
git clone https://github.com/Aloxaf/fzf-tab.git "$ZSH_PLUGINS_PATH"/fzf-tab git clone https://github.com/Aloxaf/fzf-tab.git "$ZSH_POLYJUICE_PLUGINS_PATH"/fzf-tab
else else
cd "$ZSH_PLUGINS_PATH"/fzf-tab cd "$ZSH_POLYJUICE_PLUGINS_PATH"/fzf-tab
if [ ! -d .git ]; then if [ ! -d .git ]; then
echo "fzf-tab is not a git repository. Please remove $ZSH_PLUGINS_PATH/fzf-tab and try again." echo "fzf-tab is not a git repository. Please remove $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab and try again."
else else
echo "fzf-tab is already exist. Updating..." echo "fzf-tab is already exist. Updating..."
git pull git pull
@@ -73,14 +73,14 @@ function install_plugins() {
fi fi
# git clone oh-my-zsh # git clone oh-my-zsh
if [ ! -d "$ZSH_PLUGINS_PATH"/ohmyzsh ]; then if [ ! -d "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh ]; then
echo "Oh My Zsh is not downloaded. Downloading..." echo "Oh My Zsh is not downloaded. Downloading..."
# git clone https://github.com/ohmyzsh/ohmyzsh.git "$PATH_OHMYZSH" # git clone https://github.com/ohmyzsh/ohmyzsh.git "$PATH_OHMYZSH"
git clone https://gitee.com/mirrors/ohmyzsh.git "$ZSH_PLUGINS_PATH"/ohmyzsh git clone https://gitee.com/mirrors/ohmyzsh.git "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
else else
cd "$ZSH_PLUGINS_PATH"/ohmyzsh cd "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
if [ ! -d .git ]; then if [ ! -d .git ]; then
echo "Oh My Zsh is not a git repository. Please remove $ZSH_PLUGINS_PATH/ohmyzsh and try again." echo "Oh My Zsh is not a git repository. Please remove $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh and try again."
else else
echo "Oh My Zsh is already exist. Updating..." echo "Oh My Zsh is already exist. Updating..."
git pull git pull

View File

@@ -16,41 +16,41 @@ function get_current_dir_name {
# Set basic path to zsh-polyjuice installation # Set basic path to zsh-polyjuice installation
export ZSH_POLYJUICE_PATH=$(get_current_dir_name) export ZSH_POLYJUICE_PATH=$(get_current_dir_name)
export ZSH_PLUGINS_PATH="$ZSH_POLYJUICE_PATH/plugins" export ZSH_POLYJUICE_PLUGINS_PATH="$ZSH_POLYJUICE_PATH/plugins"
export ZSH_ALIAS_PATH="$ZSH_POLYJUICE_PATH/alias" export ZSH_POLYJUICE_ALIAS_PATH="$ZSH_POLYJUICE_PATH/alias"
export ZSH_SETTINGS_PATH="$ZSH_POLYJUICE_PATH/settings" export ZSH_POLYJUICE_SETTINGS_PATH="$ZSH_POLYJUICE_PATH/settings"
export ZSH_FUNCTIONS_PATH="$ZSH_POLYJUICE_PATH/functions" export ZSH_POLYJUICE_FUNCTIONS_PATH="$ZSH_POLYJUICE_PATH/functions"
export STARSHIP_CONFIG_FILE="$ZSH_POLYJUICE_PATH/../starship/starship.toml" export ZSH_POLYJUICE_STARSHIP_CONFIG_FILE="$ZSH_POLYJUICE_PATH/../starship/starship.toml"
# Load basic settings `zsh/settings` # Load basic settings `zsh/settings`
for _file in "$ZSH_SETTINGS_PATH"/*.sh; do for _file in "$ZSH_POLYJUICE_SETTINGS_PATH"/*.sh; do
source "$_file" source "$_file"
done done
unset _file unset _file
# Load Aliases `zsh/alias` # Load Aliases `zsh/alias`
for _file in "$ZSH_ALIAS_PATH"/*.sh; do for _file in "$ZSH_POLYJUICE_ALIAS_PATH"/*.sh; do
source "$_file" source "$_file"
done done
unset _file unset _file
# Load self-defined functions # Load self-defined functions
for _file in "$ZSH_FUNCTIONS_PATH"/*.sh; do for _file in "$ZSH_POLYJUICE_FUNCTIONS_PATH"/*.sh; do
source "$_file" source "$_file"
done done
unset _file unset _file
# Load Plugins # Load Plugins
source $ZSH_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_STRATEGY=(history completion) ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
bindkey '^[l' autosuggest-accept # alt-L to accept autosuggestion bindkey '^[l' autosuggest-accept # alt-L to accept autosuggestion
source $ZSH_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh
source $ZSH_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source $ZSH_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh source $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh
source $ZSH_PLUGINS_PATH/ohmyzsh/plugins/fzf/fzf.plugin.zsh source $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh/plugins/fzf/fzf.plugin.zsh
source $ZSH_PLUGINS_PATH/ohmyzsh/plugins/zoxide/zoxide.plugin.zsh source $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh/plugins/zoxide/zoxide.plugin.zsh
source $ZSH_PLUGINS_PATH/ohmyzsh/plugins/python/python.plugin.zsh source $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh/plugins/python/python.plugin.zsh
# using starship as prompt # using starship as prompt