refactor: Update starship.toml file path and add optional icon parameter in setup.sh
This commit is contained in:
parent
001fdd06a6
commit
ef396d6c1a
30
setup.sh
30
setup.sh
|
@ -31,20 +31,10 @@ configure_starship() {
|
||||||
|
|
||||||
# Function to overwrite starship.toml
|
# Function to overwrite starship.toml
|
||||||
overwrite_starship_toml() {
|
overwrite_starship_toml() {
|
||||||
local icon="$1"
|
if [ -f "./terminal/starship.toml" ]; then
|
||||||
local starship_toml_path="./terminal/starship.toml"
|
|
||||||
local destination_path="$HOME/.config/starship.toml"
|
|
||||||
|
|
||||||
if [ -f "$starship_toml_path" ]; then
|
|
||||||
echo "Overwriting starship.toml..."
|
echo "Overwriting starship.toml..."
|
||||||
|
mkdir -p ~/.config/starship
|
||||||
# Insert icon before hostname if provided
|
cp ./terminal/starship.toml ~/.config/starship.toml
|
||||||
if [ -n "$icon" ]; then
|
|
||||||
sed -i "s/format = \"\"\"/format = \"\"\"\[ $icon \](fg:color_fg0)\\n/" "$starship_toml_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -56,18 +46,6 @@ install_fish
|
||||||
set_default_fish
|
set_default_fish
|
||||||
install_starship
|
install_starship
|
||||||
configure_starship
|
configure_starship
|
||||||
|
overwrite_starship_toml
|
||||||
# Check for the optional icon parameter
|
|
||||||
icon_param=""
|
|
||||||
while getopts ":i:" opt; then
|
|
||||||
case $opt in
|
|
||||||
i) icon_param="$OPTARG"
|
|
||||||
;;
|
|
||||||
\?) echo "Invalid option -$OPTARG" >&2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
overwrite_starship_toml "$icon_param"
|
|
||||||
|
|
||||||
echo "Fish shell and Starship prompt setup complete!"
|
echo "Fish shell and Starship prompt setup complete!"
|
||||||
|
|
Loading…
Reference in New Issue