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

This commit is contained in:
Bram Kelchtermans 2024-06-27 21:57:47 +02:00
parent b063bf304d
commit 810c8253c2
1 changed files with 3 additions and 2 deletions

View File

@ -33,17 +33,18 @@ configure_starship() {
overwrite_starship_toml() { overwrite_starship_toml() {
local icon="$1" local icon="$1"
local starship_toml_path="./terminal/starship.toml" local starship_toml_path="./terminal/starship.toml"
local destination_path="$HOME/.config/starship.toml"
if [ -f "$starship_toml_path" ]; then if [ -f "$starship_toml_path" ]; then
echo "Overwriting starship.toml..." echo "Overwriting starship.toml..."
mkdir -p ~/.config/starship
# Insert icon before hostname if provided # Insert icon before hostname if provided
if [ -n "$icon" ]; then if [ -n "$icon" ]; then
sed -i "s/format = \"\"\"/format = \"\"\"\[ $icon \](fg:color_fg0)\\n/" "$starship_toml_path" sed -i "s/format = \"\"\"/format = \"\"\"\[ $icon \](fg:color_fg0)\\n/" "$starship_toml_path"
fi fi
cp "$starship_toml_path" ~/.config/starship/starship.toml mkdir -p $(dirname "$destination_path")
cp "$starship_toml_path" "$destination_path"
else else
echo "starship.toml not found in the repository." echo "starship.toml not found in the repository."
exit 1 exit 1