From 5b55457597773a3050520cded474d01950392fad Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Fri, 19 Dec 2025 17:14:47 -0300 Subject: [PATCH 1/4] feat(ublue-bling): clean up script considerably and allow for overrides Signed-off-by: Tulip Blossom --- .../bluefin/usr/share/ublue-os/bling/env.sh | 2 + .../usr/share/ublue-os/just/system.just | 2 +- system_files/shared/usr/bin/ublue-bling | 261 +++--------------- 3 files changed, 45 insertions(+), 220 deletions(-) create mode 100644 system_files/bluefin/usr/share/ublue-os/bling/env.sh diff --git a/system_files/bluefin/usr/share/ublue-os/bling/env.sh b/system_files/bluefin/usr/share/ublue-os/bling/env.sh new file mode 100644 index 0000000..4fe52b3 --- /dev/null +++ b/system_files/bluefin/usr/share/ublue-os/bling/env.sh @@ -0,0 +1,2 @@ +export BLING_MESSAGE_ENABLE="Enable the bluefin-cli enhanced terminal experience?" +export BLING_MESSAGE_DISABLE="Disable the bluefin-cli enhanced terminal experience?" diff --git a/system_files/bluefin/usr/share/ublue-os/just/system.just b/system_files/bluefin/usr/share/ublue-os/just/system.just index c610762..c6cc079 100644 --- a/system_files/bluefin/usr/share/ublue-os/just/system.just +++ b/system_files/bluefin/usr/share/ublue-os/just/system.just @@ -4,7 +4,7 @@ # Configure Bluefin-CLI Terminal Experience with Brew [group('System')] bluefin-cli: - @/usr/bin/ublue-bling + @ublue-bling # alias for toggle-devmode devmode: diff --git a/system_files/shared/usr/bin/ublue-bling b/system_files/shared/usr/bin/ublue-bling index 5e6adc8..30ebd12 100755 --- a/system_files/shared/usr/bin/ublue-bling +++ b/system_files/shared/usr/bin/ublue-bling @@ -2,234 +2,57 @@ set -eou pipefail -# coloring / ugum chooser -source /usr/lib/ujust/ujust.sh - -get_config() { - MOTD_CONFIG_FILE="${MOTD_CONFIG_FILE:-/etc/ublue-os/bling.json}" - QUERY="$1" - FALLBACK="$2" - shift - shift - OUTPUT="$(jq -r "$QUERY" "$MOTD_CONFIG_FILE" 2>/dev/null || echo "$FALLBACK")" - if [ "$OUTPUT" == "null" ] ; then - echo "$FALLBACK" - return - fi - echo "$OUTPUT" -} - - -# Exit Handling -function Exiting() { - printf "%s%sExiting...%s\n" "${red}" "${bold}" "${normal}" - printf "Rerun script with %s%sujust $BLING_CLI_NAME%s\n" "${blue}" "${bold}" "${normal}" - exit 0 -} - -# Trap function -function ctrl_c() { - printf "\n%s\n" "Signal SIGINT caught" - Exiting -} - -# Brew Bundle Install -function brew-bundle() { - echo 'Installing bling from Homebrew 🍻🍻🍻' - brew bundle --file "$BLING_BREW_BUNDLE_PATH" -} - -# Pixi Install Global -function pixi-install-global() { - echo 'Installing bling with pixi (global install) 🐍🐍🐍' - - if [ ! -f "$BLING_PIXI_PACKAGES_FILE" ]; then - echo "Error: Pixi packages file not found at $BLING_PIXI_PACKAGES_FILE" +BLING_CLI_DIRECTORY="/usr/share/ublue-os/bling" + +BLING_SCRIPT_SOURCE="" +TARGET_CONFIG_FILE="" +shell="$(basename "${SHELL}")" +case "${shell}" in + "fish") + BLING_SCRIPT_SOURCE="bling.fish" + TARGET_CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish" + ;; + "zsh") + BLING_SCRIPT_SOURCE="bling.sh" + TARGET_CONFIG_FILE="${ZDOTDIR:-$HOME}/.zshrc" + ;; + "bash") + BLING_SCRIPT_SOURCE="bling.sh" + TARGET_CONFIG_FILE="${HOME}/.bashrc" + ;; + *) + echo 'Unknown shell. You are on your own.' exit 1 - fi - - packages="$(cat "$BLING_PIXI_PACKAGES_FILE" | grep -v '^#' | grep -v '^$' | tr '\n' ' ')" - - if [ -z "$packages" ]; then - echo "Error: No packages found in $BLING_PIXI_PACKAGES_FILE" - exit 1 - fi - - pixi global install $packages -} + ;; +esac -# Check if bling is already sourced -# 0 for yes -# 1 for no function is-bling-installed() { - shell="$1" - shift - - line="" - BLING_SCRIPT_SOURCE="bling.sh" - TARGET_CONFIG_FILE="${HOME}/.bashrc" - case "${shell}" in - "fish") - BLING_SCRIPT_SOURCE="bling.fish" - TARGET_CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish" - ;; - "zsh") - BLING_SCRIPT_SOURCE="bling.sh" - TARGET_CONFIG_FILE="${ZDOTDIR:-$HOME}/.zshrc" - ;; - "bash") - BLING_SCRIPT_SOURCE="bling.sh" - TARGET_CONFIG_FILE="${HOME}/.bashrc" - ;; - *) - echo 'Unknown shell. You are on your own.' - exit 1 - ;; - esac - # Prevents grep erroring out when theres no config file for the shell - touch "$TARGET_CONFIG_FILE" - line="$(grep -n "source $BLING_CLI_DIRECTORY/$BLING_SCRIPT_SOURCE" "$TARGET_CONFIG_FILE")" - line="$(grep -Eo '^[^:]+' <<< "$line")" + [ -f "$TARGET_CONFIG_FILE" ] || return 1 - if [[ -n "${line}" ]]; then + if [ -n "$(grep -n "source $BLING_CLI_DIRECTORY/$BLING_SCRIPT_SOURCE" "$TARGET_CONFIG_FILE" | grep -Eo '^[^:]+')" ]; then return 0 fi return 1 } -# Add Bling -function add-bling() { - shell="$1" - shift - - if [[ "${BLING_USE_PIXI}" == "1" ]]; then - pixi-install-global || Exiting - else - brew-bundle || Exiting - fi - - echo 'Setting up your Shell 🐚🐚🐚' - case "${shell}" in - "fish") - echo 'Adding bling to your config.fish 🐟🐟🐟' - cat<> "${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish" -### bling.fish source start -test -f $BLING_CLI_DIRECTORY/bling.fish && source $BLING_CLI_DIRECTORY/bling.fish -### bling.fish source end -EOF - ;; - "zsh") - echo 'Adding bling to your .zshrc 💤💤💤' - cat<> "${ZDOTDIR:-$HOME}/.zshrc" -### bling.sh source start -test -f $BLING_CLI_DIRECTORY/bling.sh && source $BLING_CLI_DIRECTORY/bling.sh -### bling.sh source end -EOF - ;; - "bash") - echo 'Adding bling to your .bashrc 💥💥💥' - cat<> "${HOME}/.bashrc" -### bling.sh source start -test -f $BLING_CLI_DIRECTORY/bling.sh && source $BLING_CLI_DIRECTORY/bling.sh -### bling.sh source end -EOF - ;; - *) - echo 'Unknown shell. You are on your own.' - exit 1 - ;; - esac -} +[ -f "${BLING_ENV_SCRIPT:-/usr/share/ublue-os/bling/env.sh}" ] && . "${BLING_ENV_SCRIPT:-/usr/share/ublue-os/bling/env.sh}" -# Remove bling, handle if old method -function remove-bling() { - shell="$1" - shift +BLING_MESSAGE_ENABLE="${BLING_MESSAGE_ENABLE:-Enable bling for ${shell}?}" +BLING_MESSAGE_DISABLE="${BLING_MESSAGE_DISABLE:-Disable bling for ${shell}?}" - case "${shell}" in - "fish") - sed -i '/### bling.fish source start/,/### bling.fish source end/d' \ - "${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish" \ - || \ - line=$(grep -n "source $BLING_CLI_DIRECTORY/bling.fish" \ - "${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish" \ - | grep -Eo '^[^:]+') \ - && \ - sed -i "${line}"d "${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish" - ;; - "zsh") - sed -i '/### bling.sh source start/,/### bling.sh source end/d' \ - "${ZDOTDIR:-$HOME}/.zshrc" \ - || \ - line=$(grep -n "source $BLING_CLI_DIRECTORY/bling.sh" \ - "${ZDOTDIR:-$HOME}/.zshrc" \ - | grep -Eo '^[^:]+') && sed -i "${line}"d \ - "${ZDOTDIR:-$HOME}/.zshrc" - ;; - "bash") - sed -i '/### bling.sh source start/,/### bling.sh source end/d' \ - "${HOME}/.bashrc" \ - || \ - line=$(grep -n "source $BLING_CLI_DIRECTORY/bling.sh" \ - "${HOME}/.bashrc" \ - | grep -Eo '^[^:]+') && sed -i "${line}"d \ - "${HOME}/.bashrc" - ;; - esac -} - -function main() { - # Get Shell - shell=$(basename "$SHELL") - reentry="$1" - clear - if [[ -n "${reentry:-}" ]]; then - printf "%s%s%s\n\n" "${bold}" "$reentry" "$normal" +if is-bling-installed "${shell}" ; then + gum confirm "${BLING_MESSAGE_DISABLE}" + if ! sed -i "/### ${BLING_SCRIPT_SOURCE} source start/,/### ${BLING_SCRIPT_SOURCE} source end/d" "${TARGET_CONFIG_FILE}" ; then + sed -i "$(grep -n "source ${BLING_SCRIPT_SOURCE}" "${TARGET_CONFIG_FILE}" | grep -Eo '^[^:]+')"d "${HOME}/.bashrc" fi - - # Check if bling is enabled and display - printf "Shell:\t%s%s%s%s\n" "${green}" "${bold}" "${shell}" "${normal}" - if is-bling-installed "${shell}"; then - printf "Bling:\t%s%sEnabled%s\n" "${green}" "${bold}" "${normal}" - else - printf "Bling:\t%s%sDisabled%s\n" "${red}" "${bold}" "${normal}" - fi - - # ugum enable/disable - CHOICE=$(Choose enable disable cancel) - - # Enable/Disable. Recurse if bad option. - case "${CHOICE,,}" in - "enable") - if is-bling-installed "${shell}"; then - main "Bling is already configured ..." - fi - trap ctrl_c SIGINT - add-bling "${shell}" - printf "%s%sInstallation Complete%s ... please close and reopen your terminal!" "${green}" "${bold}" "${normal}" - printf "Check out the documentation at: https://docs.projectbluefin.io/command-line\n" - exit 0 - ;; - "disable") - if ! is-bling-installed "${shell}"; then - main "Bling is not yet configured ..." - fi - trap ctrl_c SIGINT - remove-bling "${shell}" - printf "%s%sBling Removed%s ... please close and reopen your terminal\n" "${red}" "${bold}" "${normal}" - exit 0 - ;; - *) - Exiting - ;; - esac -} - -BLING_CLI_NAME="$(get_config '."bling-cli-name"' "bluefin-cli")" -BLING_CLI_DIRECTORY="$(get_config '."bling-cli-path"' "/usr/share/ublue-os/bling")" -BLING_BREW_BUNDLE_PATH="$(get_config '."bling-brew-bundle-path"' "/usr/share/ublue-os/homebrew/$BLING_CLI_NAME.Brewfile")" -BLING_PIXI_PACKAGES_FILE="$(get_config '."bling-pixi-package-path"' "/usr/share/ublue-os/bling/${BLING_CLI_NAME}.pixi.list")" -BLING_USE_PIXI="$(get_config '."use-pixi-bling"' "0")" - -# Entrypoint -main "" + echo "Bling removed. Reopen your terminal so that the configurations may be removed" +else + gum confirm "${BLING_MESSAGE_ENABLE}" --affirmative="Bling me up!" --negative "No, I'm boring" + echo "Adding bling to your $(basename "${TARGET_CONFIG_FILE}")" + cat<> "${TARGET_CONFIG_FILE}" +### ${BLING_SCRIPT_SOURCE} source start +test -f ${BLING_CLI_DIRECTORY}/${BLING_SCRIPT_SOURCE} && source ${BLING_CLI_DIRECTORY}/${BLING_SCRIPT_SOURCE} +### ${BLING_SCRIPT_SOURCE} source end +EOF + echo "Installation complete. Reopen your terminal so that the configurations may be applied" +fi From ba8612835210e3748060830cbbd89635f94f84e5 Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Fri, 19 Dec 2025 17:20:45 -0300 Subject: [PATCH 2/4] chore(bluefin-cli): clean up a few old tools we dont want on bluefin-cli anymore Signed-off-by: Tulip Blossom --- .../shared/usr/share/ublue-os/homebrew/cli.Brewfile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/system_files/shared/usr/share/ublue-os/homebrew/cli.Brewfile b/system_files/shared/usr/share/ublue-os/homebrew/cli.Brewfile index b32e4db..5860952 100644 --- a/system_files/shared/usr/share/ublue-os/homebrew/cli.Brewfile +++ b/system_files/shared/usr/share/ublue-os/homebrew/cli.Brewfile @@ -9,14 +9,10 @@ brew "dysk" brew "eza" brew "fd" brew "gh" -brew "glab" -brew "rg" +brew "ripgrep" brew "starship" -brew "shellcheck" -brew "stress-ng" brew "tealdeer" brew "trash-cli" -brew "television" brew "uutils-coreutils" brew "ugrep" brew "yq" From 3664649e03afecc60cfa3e88b9bd0d63b2ee8a7a Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Fri, 19 Dec 2025 17:30:59 -0300 Subject: [PATCH 3/4] chore(bling): slightly clean up bling.sh Signed-off-by: Tulip Blossom --- .../shared/usr/share/ublue-os/bling/bling.sh | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/system_files/shared/usr/share/ublue-os/bling/bling.sh b/system_files/shared/usr/share/ublue-os/bling/bling.sh index 3d346ac..b48445d 100755 --- a/system_files/shared/usr/share/ublue-os/bling/bling.sh +++ b/system_files/shared/usr/share/ublue-os/bling/bling.sh @@ -1,5 +1,7 @@ #!/usr/bin/env sh +# KEEP THIS POSIX - Needs to work on Bash and ZSH + # Check if bling has already been sourced so that we dont break atuin. https://github.com/atuinsh/atuin/issues/380#issuecomment-1594014644 [ "${BLING_SOURCED:-0}" -eq 1 ] && return BLING_SOURCED=1 @@ -25,30 +27,24 @@ fi # bat for cat alias cat='bat --style=plain --pager=never' 2>/dev/null -HOMEBREW_PREFIX="${HOMEBREW_PREFIX:-/home/linuxbrew/.linuxbrew}" - # set ATUIN_INIT_FLAGS in your ~/.bashrc before ublue-bling is sourced. # Atuin allows these flags: "--disable-up-arrow" and/or "--disable-ctrl-r" -ATUIN_INIT_FLAGS=${ATUIN_INIT_FLAGS:-""} +ATUIN_INIT_FLAGS="${ATUIN_INIT_FLAGS:-}" -if [ "$(basename $(readlink /proc/$$/exe))" = "bash" ]; then - # Initialize direnv before bash-preexec to avoid PROMPT_COMMAND conflicts - # See: https://github.com/rcaloras/bash-preexec/pull/143 - [ "$(command -v direnv)" ] && eval "$(direnv hook bash)" +BLING_SHELL="$(basename "$(readlink /proc/$$/exe)")" + +# Initialize direnv before bash-preexec to avoid PROMPT_COMMAND conflicts +# See: https://github.com/rcaloras/bash-preexec/pull/143 +if [ "${BLING_SHELL}" = "bash" ]; then [ -f "/etc/profile.d/bash-preexec.sh" ] && . "/etc/profile.d/bash-preexec.sh" [ -f "/usr/share/bash-prexec" ] && . "/usr/share/bash-prexec" [ -f "/usr/share/bash-prexec.sh" ] && . "/usr/share/bash-prexec.sh" [ -f "${HOMEBREW_PREFIX}/etc/profile.d/bash-preexec.sh" ] && . "${HOMEBREW_PREFIX}/etc/profile.d/bash-preexec.sh" - # Initialize atuin before starship to ensure proper command history capture - # See: https://github.com/atuinsh/atuin/issues/2804 - [ "$(command -v atuin)" ] && eval "$(atuin init bash ${ATUIN_INIT_FLAGS})" - [ "$(command -v starship)" ] && eval "$(starship init bash)" - [ "$(command -v zoxide)" ] && eval "$(zoxide init bash)" -elif [ "$(basename $(readlink /proc/$$/exe))" = "zsh" ]; then - # Initialize direnv before atuin to avoid PROMPT_COMMAND conflicts - [ "$(command -v direnv)" ] && eval "$(direnv hook zsh)" - # Initialize atuin before starship to ensure proper command history capture - [ "$(command -v atuin)" ] && eval "$(atuin init zsh ${ATUIN_INIT_FLAGS})" - [ "$(command -v starship)" ] && eval "$(starship init zsh)" - [ "$(command -v zoxide)" ] && eval "$(zoxide init zsh)" fi + +[ "$(command -v direnv)" ] && eval "$(direnv hook "${BLING_SHELL}")" +# Initialize atuin before starship to ensure proper command history capture +# See: https://github.com/atuinsh/atuin/issues/2804 +[ "$(command -v atuin)" ] && eval "$(atuin init "${BLING_SHELL}" ${ATUIN_INIT_FLAGS})" +[ "$(command -v starship)" ] && eval "$(starship init "${BLING_SHELL}")" +[ "$(command -v zoxide)" ] && eval "$(zoxide init "${BLING_SHELL}")" From f284a164459aa113fe40ea8b8079bd38fc4239cc Mon Sep 17 00:00:00 2001 From: renner <80410025+renner0e@users.noreply.github.com> Date: Sat, 20 Dec 2025 18:03:03 +0100 Subject: [PATCH 4/4] fix: shebang for env.sh --- system_files/bluefin/usr/share/ublue-os/bling/env.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/system_files/bluefin/usr/share/ublue-os/bling/env.sh b/system_files/bluefin/usr/share/ublue-os/bling/env.sh index 4fe52b3..8bd6b51 100644 --- a/system_files/bluefin/usr/share/ublue-os/bling/env.sh +++ b/system_files/bluefin/usr/share/ublue-os/bling/env.sh @@ -1,2 +1,3 @@ +#!/usr/bin/env sh export BLING_MESSAGE_ENABLE="Enable the bluefin-cli enhanced terminal experience?" export BLING_MESSAGE_DISABLE="Disable the bluefin-cli enhanced terminal experience?"