Merge pull request #8 from mcataford/feat/starship-configuration
feat: add starship configuration
This commit is contained in:
commit
c26b0c1d8c
4 changed files with 124 additions and 16 deletions
14
.github/workflows/ci.yaml
vendored
14
.github/workflows/ci.yaml
vendored
|
@ -1,14 +0,0 @@
|
||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
validate:
|
|
||||||
name: Validate bootstrap
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- run: . ./bootstrap.sh
|
|
|
@ -3,14 +3,19 @@
|
||||||
# Ensuring steps are defined.
|
# Ensuring steps are defined.
|
||||||
. ./steps.sh
|
. ./steps.sh
|
||||||
|
|
||||||
TOTAL_STEPS=6
|
TOTAL_STEPS=8
|
||||||
|
|
||||||
# Refer to steps.sh for step definition.
|
# Refer to steps.sh for step definition.
|
||||||
bootstrap() {
|
bootstrap() {
|
||||||
ensure_apt_up_to_date
|
ensure_apt_up_to_date
|
||||||
ensure_apt_dependencies
|
ensure_apt_dependencies
|
||||||
ensure_omz
|
install_rust
|
||||||
ensure_nvm
|
ensure_nvm
|
||||||
|
|
||||||
|
# Shell & prompt setup
|
||||||
|
ensure_omz
|
||||||
|
install_and_configure_starship
|
||||||
|
|
||||||
inject_shell_configuration
|
inject_shell_configuration
|
||||||
inject_vim_configuration
|
inject_vim_configuration
|
||||||
}
|
}
|
||||||
|
|
73
files/starship.toml
Normal file
73
files/starship.toml
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
format = """
|
||||||
|
[](#9A348E)\
|
||||||
|
$username\
|
||||||
|
$os\
|
||||||
|
[](bg:#33658a fg:#9A348E)\
|
||||||
|
$time\
|
||||||
|
[](bg:#DA627D fg:#33658a)\
|
||||||
|
$directory\
|
||||||
|
[](fg:#DA627D bg:#3208e0)\
|
||||||
|
$git_branch\
|
||||||
|
$git_status\
|
||||||
|
[](fg:#4208e0 bg:#9A348E)\
|
||||||
|
$python\
|
||||||
|
[](fg:#9A348E)
|
||||||
|
>
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Disable the blank line at the start of the prompt
|
||||||
|
add_newline = true
|
||||||
|
|
||||||
|
[python]
|
||||||
|
style = "bg:#9A348E"
|
||||||
|
format = '[${symbol}${pyenv_prefix}(${version} )(\($virtualenv\) )]($style)'
|
||||||
|
|
||||||
|
|
||||||
|
# You can also replace your username with a neat symbol like or disable this
|
||||||
|
# and use the os module below
|
||||||
|
[username]
|
||||||
|
show_always = true
|
||||||
|
style_user = "bg:#9A348E"
|
||||||
|
style_root = "bg:#9A348E"
|
||||||
|
format = '[$user ]($style)'
|
||||||
|
disabled = false
|
||||||
|
|
||||||
|
# An alternative to the username module which displays a symbol that
|
||||||
|
# represents the current operating system
|
||||||
|
[os]
|
||||||
|
style = "bg:#9A348E"
|
||||||
|
disabled = true # Disabled by default
|
||||||
|
|
||||||
|
[directory]
|
||||||
|
style = "bg:#DA627D"
|
||||||
|
format = "[ $path ]($style)"
|
||||||
|
truncation_length = 3
|
||||||
|
truncation_symbol = "…/"
|
||||||
|
|
||||||
|
# Here is how you can shorten some long paths by text replacement
|
||||||
|
# similar to mapped_locations in Oh My Posh:
|
||||||
|
[directory.substitutions]
|
||||||
|
"Documents" = " "
|
||||||
|
"Downloads" = " "
|
||||||
|
"Music" = " "
|
||||||
|
"Pictures" = " "
|
||||||
|
# Keep in mind that the order matters. For example:
|
||||||
|
# "Important Documents" = " "
|
||||||
|
# will not be replaced, because "Documents" was already substituted before.
|
||||||
|
# So either put "Important Documents" before "Documents" or use the substituted version:
|
||||||
|
# "Important " = " "
|
||||||
|
|
||||||
|
[git_branch]
|
||||||
|
symbol = ""
|
||||||
|
style = "bg:#4208e0"
|
||||||
|
format = '[ $symbol $branch ]($style)'
|
||||||
|
|
||||||
|
[git_status]
|
||||||
|
style = "bg:#4208e0"
|
||||||
|
format = '[$all_status$ahead_behind ]($style)'
|
||||||
|
|
||||||
|
[time]
|
||||||
|
time_format = "%T"
|
||||||
|
style = "bg:#33658A"
|
||||||
|
format = '[ $time ]($style)'
|
||||||
|
disabled = false
|
44
steps.sh
44
steps.sh
|
@ -1,13 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
STEP_COUNT=0
|
STEP_COUNT=0
|
||||||
|
SUBSTEP_COUNT=0
|
||||||
|
|
||||||
# Helpers to pretty-print step titles and count.
|
# Helpers to pretty-print step titles and count.
|
||||||
pre_step() {
|
pre_step() {
|
||||||
STEP_COUNT=$(($STEP_COUNT + 1))
|
STEP_COUNT=$(($STEP_COUNT + 1))
|
||||||
|
SUBSTEP_COUNT=0
|
||||||
echo -e "\e[1m[$STEP_COUNT/$TOTAL_STEPS] <====== $1 =======>\e[0m"
|
echo -e "\e[1m[$STEP_COUNT/$TOTAL_STEPS] <====== $1 =======>\e[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre_substep() {
|
||||||
|
SUBSTEP_COUNT=$(($SUBSTEP_COUNT + 1))
|
||||||
|
echo -e "\e[1m[$STEP_COUNT.$SUBSTEP_COUNT] <====== $1 =======>\e[0m"
|
||||||
|
}
|
||||||
|
|
||||||
# Ensures that all existing Apt packages are up-to-date.
|
# Ensures that all existing Apt packages are up-to-date.
|
||||||
ensure_apt_up_to_date() {
|
ensure_apt_up_to_date() {
|
||||||
pre_step "Ensuring apt packages are up-to-date"
|
pre_step "Ensuring apt packages are up-to-date"
|
||||||
|
@ -38,11 +45,48 @@ ensure_apt_dependencies() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Installs the rustup toolchain if not installed.
|
||||||
|
# If installed, the toolchain is updated.
|
||||||
|
install_rust() {
|
||||||
|
pre_step "Install and configure Rust toolchain"
|
||||||
|
|
||||||
|
if [ -z "$(rustup --version 2> /dev/null)" ]; then
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||||
|
else
|
||||||
|
rustup update
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
ensure_omz() {
|
ensure_omz() {
|
||||||
pre_step "Installs Oh My ZSH"
|
pre_step "Installs Oh My ZSH"
|
||||||
curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | bash
|
curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | bash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Installs the Starship prompt and adds an initialization
|
||||||
|
# command to the shell configuration file.
|
||||||
|
#
|
||||||
|
# Requires: install_rust
|
||||||
|
install_and_configure_starship() {
|
||||||
|
pre_step "Install and configure Starship"
|
||||||
|
|
||||||
|
pre_substep "Install Starship via cargo"
|
||||||
|
cargo install starship --locked
|
||||||
|
|
||||||
|
pre_substep "Add initialization command to shell configuration"
|
||||||
|
STARSHIP_INIT_COMMAND='eval "$(starship init zsh)"'
|
||||||
|
if [ -z "$(rg "starship init zsh" ~/.zshrc)" ]; then
|
||||||
|
echo "#Initialize Starship prompt\n$STARSHIP_INIT_COMMAND" >> ~/.zshrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
pre_substep "Copy configuration in configuration directory"
|
||||||
|
STARSHIP_CONFIGURATION_PATH=~/.config/starship.toml
|
||||||
|
if [ -f $STARSHIP_CONFIGURATION_PATH ]; then
|
||||||
|
cp $STARSHIP_CONFIGURATION_PATH $STARSHIP_CONFIGURATION_PATH.old
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp ./files/starship.toml $STARSHIP_CONFIGURATION_PATH
|
||||||
|
}
|
||||||
|
|
||||||
ensure_nvm() {
|
ensure_nvm() {
|
||||||
pre_step "Installing nvm to manage node version"
|
pre_step "Installing nvm to manage node version"
|
||||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||||
|
|
Loading…
Reference in a new issue