From 64afc072500b6cb7cf3f4d366825e7628d411e75 Mon Sep 17 00:00:00 2001 From: Sir Blob Date: Mon, 21 Sep 2026 01:07:27 +0000 Subject: [PATCH] Start the starship prompt and build it from the active theme --- .../themed/starship.toml.tpl | 26 +++++++++++++------ docs/install.md | 4 +++ docs/themes.md | 23 +++++++++++++--- install.sh | 1 + install/steps/config.sh | 21 +++++++++++++++ install/steps/theme.sh | 1 + session/bashrc | 8 ++++++ uninstall.sh | 2 ++ 8 files changed, 74 insertions(+), 12 deletions(-) rename config/starship.toml => default/themed/starship.toml.tpl (58%) create mode 100644 session/bashrc diff --git a/config/starship.toml b/default/themed/starship.toml.tpl similarity index 58% rename from config/starship.toml rename to default/themed/starship.toml.tpl index 36f15d1..f41a97c 100644 --- a/config/starship.toml +++ b/default/themed/starship.toml.tpl @@ -1,31 +1,41 @@ add_newline = true command_timeout = 200 format = "[$directory$git_branch$git_status]($style)$character" +palette = "blob" + +[palettes.blob] +accent = "{{ accent }}" +foreground = "{{ foreground }}" +muted = "{{ muted }}" +success = "{{ green }}" +warning = "{{ yellow }}" +error = "{{ red }}" [character] -error_symbol = "[✗](bold cyan)" -success_symbol = "[❯](bold cyan)" +error_symbol = "[✗](bold error)" +success_symbol = "[❯](bold accent)" [directory] +style = "foreground" truncation_length = 2 truncation_symbol = "…/" -repo_root_style = "bold cyan" +repo_root_style = "bold accent" repo_root_format = "[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) " [git_branch] format = "[$branch]($style) " -style = "italic cyan" +style = "italic accent" [git_status] format = '[$all_status]($style)' -style = "cyan" +style = "warning" ahead = "⇡${count} " diverged = "⇕⇡${ahead_count}⇣${behind_count} " behind = "⇣${count} " -conflicted = " " -up_to_date = " " +conflicted = " " +up_to_date = " " untracked = "? " -modified = " " +modified = " " stashed = "" staged = "" renamed = "" diff --git a/docs/install.md b/docs/install.md index 00a26e1..2533294 100644 --- a/docs/install.md +++ b/docs/install.md @@ -42,6 +42,10 @@ with `--check`. panels come up full of blanks. `fonts.conf` binds `monospace` to `JetBrainsMono Nerd Font`; `blob font set` rewrites the same file, and the installer then reports it as a local change and keeps your choice. + `~/.bashrc` gets one line sourcing `session/bashrc`, which is what starts + the starship prompt and puts `blob` on `PATH` in an interactive shell. The + line is added once, a `.bak` is kept, and a `~/.bashrc` that already has it + is left alone. `session/profile.sh` also goes to `/etc/profile.d/blob.sh`, which sources `session/env-bootstrap` and is what puts `blob` on `PATH` in a login shell. Without it `BLOB_PATH` and `$BLOB_PATH/bin` are only set by diff --git a/docs/themes.md b/docs/themes.md index bc1da8a..9ebb831 100644 --- a/docs/themes.md +++ b/docs/themes.md @@ -30,12 +30,13 @@ the shell and the CLI never disagree about what a slot means. Each rendered file is picked up differently: `foot.ini` and `kitty.conf` by an `include` in the shipped terminal config, `hyprland.lua` through Hyprland's Lua module path, `shell.toml` and `chromium.theme` read straight from the state -directory, and `btop.theme`, `neovim.lua` and `gtk.css` through symlinks the -installer makes into those apps' own config trees. +directory, and `btop.theme`, `neovim.lua`, `gtk.css` and `starship.toml` +through symlinks the installer makes into those apps' own config trees. `default/themed/*.tpl` are rendered per theme into -`~/.local/state/blob/current/theme/`. Ten ship: foot, kitty, btop, chromium, -hyprland, the screenshare picker, neovim, `shell.toml`, zen, and `gtk.css`. +`~/.local/state/blob/current/theme/`. Eleven ship: foot, kitty, btop, chromium, +hyprland, the screenshare picker, neovim, `shell.toml`, zen, `gtk.css`, and +`starship.toml`. An app picks its colors up in one of two ways. Most include the generated file directly, so nothing has to run: @@ -65,6 +66,20 @@ so an app that was already open keeps its old colors until it is restarted. Adding a template for another app means dropping a `.tpl` in `default/themed/` and, if it cannot include a file, adding an applier to that list. +## The prompt + +`starship.toml` is linked to `~/.config/starship.toml`. It carries a +`[palettes.blob]` block built from the theme - `accent`, `foreground`, `muted`, +`success`, `warning`, `error` - and every style in the file names one of those +rather than a literal color, so the prompt moves with the theme. Starship reads +its config on each prompt, so a theme change shows up on the next command, in +shells that are already open. + +`starship init bash` runs from `session/bashrc`, which `install.sh` sources from +`~/.bashrc` with a single line. That file returns immediately in a +non-interactive shell, so it cannot disturb `scp` or `rsync`, and it also +sources `session/env-bootstrap` so `blob` is on `PATH` in any interactive shell. + ## The three ways to set a theme | Command | Does | diff --git a/install.sh b/install.sh index d437708..1eae786 100755 --- a/install.sh +++ b/install.sh @@ -65,6 +65,7 @@ install_packages install_shipped_config refresh_font_cache install_shell_profile +install_bash_integration install_user_units install_systemd_dropins install_zen_config diff --git a/install/steps/config.sh b/install/steps/config.sh index 2283269..742b3f7 100644 --- a/install/steps/config.sh +++ b/install/steps/config.sh @@ -63,6 +63,27 @@ install_shipped_config() { install_file "$repo_dir/fonts/omarchy.ttf" "$font_dir/omarchy.ttf" "fonts/omarchy.ttf" } +bashrc_line='[ -r "$HOME/.local/share/blob/session/bashrc" ] && . "$HOME/.local/share/blob/session/bashrc"' + +install_bash_integration() { + local bashrc="$HOME/.bashrc" + + if [[ -f $bashrc ]] && grep -Fqx "$bashrc_line" "$bashrc"; then + say "ok bashrc" + return 0 + fi + + note_change + if [[ $check == true ]]; then + say "would source session/bashrc from ~/.bashrc" + return 0 + fi + + [[ -f $bashrc ]] && cp "$bashrc" "$bashrc.bak" + printf '\n%s\n' "$bashrc_line" >>"$bashrc" + say "write bashrc" +} + refresh_font_cache() { if ! command -v fc-cache &>/dev/null; then say "SKIP font cache (fc-cache not installed)" diff --git a/install/steps/theme.sh b/install/steps/theme.sh index 4a1f4dc..0758552 100644 --- a/install/steps/theme.sh +++ b/install/steps/theme.sh @@ -133,6 +133,7 @@ link_app_themes() { link_theme_file btop.theme "$config_dir/btop/themes/current.theme" "btop theme" link_theme_file gtk.css "$config_dir/gtk-3.0/gtk.css" "gtk-3.0 theme" link_theme_file gtk.css "$config_dir/gtk-4.0/gtk.css" "gtk-4.0 theme" + link_theme_file starship.toml "$config_dir/starship.toml" "starship prompt" if [[ -d $config_dir/nvim/lua/plugins ]]; then link_theme_file neovim.lua "$config_dir/nvim/lua/plugins/theme.lua" "neovim theme" diff --git a/session/bashrc b/session/bashrc new file mode 100644 index 0000000..9437be9 --- /dev/null +++ b/session/bashrc @@ -0,0 +1,8 @@ +case $- in + *i*) ;; + *) return 0 ;; +esac + +[ -r "$HOME/.local/share/blob/session/env-bootstrap" ] && . "$HOME/.local/share/blob/session/env-bootstrap" + +command -v starship >/dev/null 2>&1 && eval "$(starship init bash)" diff --git a/uninstall.sh b/uninstall.sh index 66e924a..e536323 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -112,6 +112,8 @@ for lua in hyprland.lua monitors.lua input.lua looknfeel.lua bindings.lua autost restore_or_remove "$config_dir/hypr/$lua" "hypr/$lua" done +[[ -L $config_dir/starship.toml ]] && restore_or_remove "$config_dir/starship.toml" "starship.toml" + for gtk in gtk-3.0 gtk-4.0; do [[ -L $config_dir/$gtk/gtk.css ]] && restore_or_remove "$config_dir/$gtk/gtk.css" "$gtk/gtk.css" done