From aca04c9bf9ffc2aec573750fcee6d733256dcbdf Mon Sep 17 00:00:00 2001 From: gwbeip Date: Wed, 21 Jan 2026 23:04:05 +0800 Subject: [PATCH] config startship in zsh --- zsh/functions/config_starship.sh | 40 +++++++++++++++++--------------- zsh/functions/install.sh | 4 +++- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/zsh/functions/config_starship.sh b/zsh/functions/config_starship.sh index af0d7bd..4c6d3b0 100644 --- a/zsh/functions/config_starship.sh +++ b/zsh/functions/config_starship.sh @@ -1,22 +1,24 @@ -#! /bin/bash - -current_dir=$(dirname $(realpath "$0")) -starship_config_file="$HOME/.config/starship.toml" - -if [ -f $starship_config_file ]; then - if $(file "$starship_config_file" | grep -q "symbolic link") ; then - if [[ $(readlink "$starship_config_file") != $(realpath "$current_dir/../starship/starship.toml") ]]; then - ln -sf "$current_dir/../starship/starship.toml" "$starship_config_file" +function startship_polyjuice() { + if [ ! -n "${STARSHIP_CONFIG_FILE}" ]; then + echo "STARSHIP_CONFIG_FILE is not set. Please source `\$HOME/.zshrc` first." + return + fi + starship_config_file="$HOME/.config/starship.toml" + if [ -f $starship_config_file ]; then + if $(file "$starship_config_file" | grep -q "symbolic link") ; then + if [[ $(readlink "$starship_config_file") != $(realpath "$STARSHIP_CONFIG_FILE") ]]; then + ln -sf "$STARSHIP_CONFIG_FILE" "$starship_config_file" + fi + else + if [ ! -f "$starship_config_file.bkp" ]; then + mv "$starship_config_file" "$starship_config_file.bkp" + ln -s "$STARSHIP_CONFIG_FILE" "$starship_config_file" + else + echo "Backup file already exists. Please remove $starship_config_file.bkp and try again." + return + fi fi else - if [ ! -f "$starship_config_file.bkp" ]; then - mv "$starship_config_file" "$starship_config_file.bkp" - ln -s "$current_dir/../starship/starship.toml" "$starship_config_file" - else - echo "Backup file already exists. Please remove $starship_config_file.bkp and try again." - exit 1 - fi + ln -sf "$STARSHIP_CONFIG_FILE" "$starship_config_file" fi -else - ln -sf "$current_dir/../starship/starship.toml" "$starship_config_file" -fi +} \ No newline at end of file diff --git a/zsh/functions/install.sh b/zsh/functions/install.sh index 869cc1a..ff95fef 100644 --- a/zsh/functions/install.sh +++ b/zsh/functions/install.sh @@ -58,7 +58,7 @@ function install_plugins() { fi fi - # git clone powerlevel10k + # git clone fzf-tab if [ ! -d "$ZSH_PLUGINS_PATH"/fzf-tab ]; then echo "fzf-tab is not downloaded. Downloading..." git clone https://github.com/Aloxaf/fzf-tab.git "$ZSH_PLUGINS_PATH"/fzf-tab @@ -88,4 +88,6 @@ function install_plugins() { git pull fi fi + + echo "All plugins are installed/updated. Run 'exec zsh' to apply changes." }