2024-06-27 21:28:17 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit immediately if a command exits with a non-zero status.
|
|
|
|
set -e
|
|
|
|
|
2024-06-27 22:22:33 +02:00
|
|
|
# Default icon value (empty if not provided)
|
|
|
|
icon=""
|
|
|
|
|
|
|
|
# Function to display script usage
|
|
|
|
usage() {
|
|
|
|
echo "Usage: $0 [--icon <nerd font symbol>]"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Parse command-line options
|
2024-06-27 22:27:05 +02:00
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
key="$1"
|
|
|
|
|
|
|
|
case $key in
|
|
|
|
--icon)
|
|
|
|
icon="$2"
|
|
|
|
shift # past argument
|
|
|
|
shift # past value
|
2024-06-27 22:22:33 +02:00
|
|
|
;;
|
2024-06-27 22:27:05 +02:00
|
|
|
*)
|
|
|
|
# unknown option
|
2024-06-27 22:22:33 +02:00
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2024-06-27 21:28:17 +02:00
|
|
|
# Function to install Fish shell
|
|
|
|
install_fish() {
|
|
|
|
echo "Installing Fish shell..."
|
|
|
|
sudo apt update
|
|
|
|
sudo apt install -y fish
|
|
|
|
}
|
2024-06-27 22:31:20 +02:00
|
|
|
|
2024-06-27 21:28:17 +02:00
|
|
|
# Function to set Fish as the default shell
|
|
|
|
set_default_fish() {
|
|
|
|
echo "Setting Fish as the default shell..."
|
|
|
|
chsh -s $(which fish)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to install Starship
|
|
|
|
install_starship() {
|
|
|
|
echo "Installing Starship..."
|
|
|
|
curl -sS https://starship.rs/install.sh | sh -s -- -y
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to configure Starship for Fish
|
|
|
|
configure_starship() {
|
|
|
|
echo "Configuring Starship for Fish..."
|
|
|
|
mkdir -p ~/.config/fish
|
|
|
|
echo 'starship init fish | source' >> ~/.config/fish/config.fish
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to overwrite starship.toml
|
|
|
|
overwrite_starship_toml() {
|
2024-06-27 22:04:59 +02:00
|
|
|
if [ -f "./terminal/starship.toml" ]; then
|
2024-06-27 21:28:17 +02:00
|
|
|
echo "Overwriting starship.toml..."
|
2024-06-27 22:31:20 +02:00
|
|
|
cp ./terminal/starship.toml ~/.config/starship.toml
|
2024-06-27 22:16:25 +02:00
|
|
|
|
|
|
|
# Check if icon parameter is provided
|
|
|
|
if [ ! -z "$icon" ]; then
|
|
|
|
echo "Adding icon [$icon](bg:color_purple fg:color_white) to starship.toml..."
|
2024-06-27 22:21:03 +02:00
|
|
|
# Escape special characters in icon variable for sed
|
|
|
|
escaped_icon=$(printf '%s\n' "$icon" | sed -e 's/[]\/$*.^[]/\\&/g')
|
2024-06-27 22:40:57 +02:00
|
|
|
sed -i "5i\[$escaped_icon](fg:color_white bg:color_purple)\\\\" ~/.config/starship.toml
|
2024-06-27 22:16:25 +02:00
|
|
|
fi
|
|
|
|
|
2024-06-27 21:28:17 +02:00
|
|
|
else
|
|
|
|
echo "starship.toml not found in the repository."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Main script execution
|
|
|
|
install_fish
|
|
|
|
set_default_fish
|
|
|
|
install_starship
|
|
|
|
configure_starship
|
2024-06-27 22:04:59 +02:00
|
|
|
overwrite_starship_toml
|
2024-06-27 21:28:17 +02:00
|
|
|
|
|
|
|
echo "Fish shell and Starship prompt setup complete!"
|