starship related
This commit is contained in:
@@ -1,24 +1,27 @@
|
|||||||
function starship_polyjuice() {
|
function starship_polyjuice() {
|
||||||
if [ ! -n "${ZSH_POLYJUICE_STARSHIP_CONFIG_FILE}" ]; then
|
local config_file_dir="$(dirname "$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE")"
|
||||||
echo "STARSHIP_CONFIG_FILE is not set. Please source `\$HOME/.zshrc` first."
|
case "$1" in
|
||||||
return
|
list)
|
||||||
fi
|
ls $config_file_dir
|
||||||
starship_config_file="$HOME/.config/starship.toml"
|
;;
|
||||||
if [ -f $starship_config_file ]; then
|
set)
|
||||||
if $(file "$starship_config_file" | grep -q "symbolic link") ; then
|
local _target="$config_file_dir/starship_$2.toml"
|
||||||
if [[ $(readlink "$starship_config_file") != $(realpath "$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE") ]]; then
|
if [ -f "$_target" ]; then
|
||||||
ln -sf "$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE" "$starship_config_file"
|
export STARSHIP_CONFIG=$_target
|
||||||
fi
|
echo "Starship config set to '$_target'"
|
||||||
else
|
|
||||||
if [ ! -f "$starship_config_file.bkp" ]; then
|
|
||||||
mv "$starship_config_file" "$starship_config_file.bkp"
|
|
||||||
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 "Config '$_target' does not exist."
|
||||||
return
|
|
||||||
fi
|
fi
|
||||||
fi
|
;;
|
||||||
else
|
reset)
|
||||||
ln -sf "$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE" "$starship_config_file"
|
export STARSHIP_CONFIG="$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE"
|
||||||
fi
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: starship_polyjuice <command> [args]"
|
||||||
|
echo "Commands:"
|
||||||
|
echo " list List available Starship configs in the polyjuice directory."
|
||||||
|
echo " set <name> Select a config by base name (omit the .toml extension)."
|
||||||
|
echo " reset Reset the Starship configuration to the default polyjuice configuration."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export ZSH_POLYJUICE_PLUGINS_PATH="$ZSH_POLYJUICE_PATH/plugins"
|
|||||||
export ZSH_POLYJUICE_ALIAS_PATH="$ZSH_POLYJUICE_PATH/alias"
|
export ZSH_POLYJUICE_ALIAS_PATH="$ZSH_POLYJUICE_PATH/alias"
|
||||||
export ZSH_POLYJUICE_SETTINGS_PATH="$ZSH_POLYJUICE_PATH/settings"
|
export ZSH_POLYJUICE_SETTINGS_PATH="$ZSH_POLYJUICE_PATH/settings"
|
||||||
export ZSH_POLYJUICE_FUNCTIONS_PATH="$ZSH_POLYJUICE_PATH/functions"
|
export ZSH_POLYJUICE_FUNCTIONS_PATH="$ZSH_POLYJUICE_PATH/functions"
|
||||||
export ZSH_POLYJUICE_STARSHIP_CONFIG_FILE="$ZSH_POLYJUICE_PATH/../starship/starship.toml"
|
export ZSH_POLYJUICE_STARSHIP_CONFIG_FILE="$ZSH_POLYJUICE_PATH/../starship/starship_default.toml"
|
||||||
|
|
||||||
# Load basic settings `zsh/settings`
|
# Load basic settings `zsh/settings`
|
||||||
for _file in "$ZSH_POLYJUICE_SETTINGS_PATH"/*.sh; do
|
for _file in "$ZSH_POLYJUICE_SETTINGS_PATH"/*.sh; do
|
||||||
@@ -59,6 +59,7 @@ fi
|
|||||||
|
|
||||||
# using starship as prompt
|
# using starship as prompt
|
||||||
if (( $+commands[starship] )); then
|
if (( $+commands[starship] )); then
|
||||||
|
export STARSHIP_CONFIG="$ZSH_POLYJUICE_STARSHIP_CONFIG_FILE"
|
||||||
eval "$(starship init zsh)"
|
eval "$(starship init zsh)"
|
||||||
else
|
else
|
||||||
echo '[starship] not found, please install it.'
|
echo '[starship] not found, please install it.'
|
||||||
|
|||||||
Reference in New Issue
Block a user