refactor: Update starship.toml file path and add optional icon parameter in setup.sh

This commit is contained in:
Bram Kelchtermans 2024-06-27 22:21:03 +02:00
parent 23ce374822
commit 88c42a3dbd
1 changed files with 4 additions and 2 deletions

View File

@ -34,12 +34,14 @@ overwrite_starship_toml() {
if [ -f "./terminal/starship.toml" ]; then if [ -f "./terminal/starship.toml" ]; then
echo "Overwriting starship.toml..." echo "Overwriting starship.toml..."
mkdir -p ~/.config/starship mkdir -p ~/.config/starship
cp ./terminal/starship.toml ~/.config/starship.toml cp ./terminal/starship.toml ~/.config/starship/starship.toml
# Check if icon parameter is provided # Check if icon parameter is provided
if [ ! -z "$icon" ]; then if [ ! -z "$icon" ]; then
echo "Adding icon [$icon](bg:color_purple fg:color_white) to starship.toml..." echo "Adding icon [$icon](bg:color_purple fg:color_white) to starship.toml..."
sed -i "5i\icon = \"$icon\"" ~/.config/starship.toml # Escape special characters in icon variable for sed
escaped_icon=$(printf '%s\n' "$icon" | sed -e 's/[]\/$*.^[]/\\&/g')
sed -i "5i\icon = \"$escaped_icon\"" ~/.config/starship/starship.toml
fi fi
else else