From b3026487f0c89a68df795c1a645814008ee00ec2 Mon Sep 17 00:00:00 2001 From: lachtan obecny Date: Mon, 13 Jul 2026 06:06:18 +0200 Subject: [PATCH] Opravy z macos --- bashrc | 1 + functions.sh | 15 ++++++++++++++- rc/03-values.sh | 24 +++++++++++++----------- rc/{linuxbrew.sh => brew.sh} | 8 +++++--- rc/sdkman.sh | 2 +- 5 files changed, 34 insertions(+), 16 deletions(-) rename rc/{linuxbrew.sh => brew.sh} (79%) diff --git a/bashrc b/bashrc index 912d5a6..3ea7131 100644 --- a/bashrc +++ b/bashrc @@ -22,4 +22,5 @@ source_directory_sh "$HOME/.bashrc.d" append_path "$LWS/bin" append_path "$LWS/opt/bin" +set_system_paths set_uniq_path diff --git a/functions.sh b/functions.sh index 30ac627..14c478f 100644 --- a/functions.sh +++ b/functions.sh @@ -60,6 +60,12 @@ function append_path() { fi } +function append_path_to_end() { + local path="$1" + remove_path "$path" + append_path "$path" +} + function append_path_try() { if [[ -e "$1" ]]; then append_path "$1" @@ -79,7 +85,14 @@ function prepend_path_try() { } function remove_path() { - PATH=$(path | grep -v "$1" | tr "\n" ":") + PATH=$(path | grep -v "^$1$" | tr "\n" ":") +} + +function set_system_paths() { + append_path_to_end /usr/bin + append_path_to_end /bin + append_path_to_end /usr/sbin + append_path_to_end /sbin } function uniq_path() { diff --git a/rc/03-values.sh b/rc/03-values.sh index 8d126c3..d52be81 100644 --- a/rc/03-values.sh +++ b/rc/03-values.sh @@ -1,12 +1,14 @@ -# Terminal colors -LWS_RED=$(tput setaf 1) -LWS_GREEN=$(tput setaf 2) -LWS_CYAN=$(tput setaf 6) -LWS_COLOR_RESET=$(tput sgr0) +if [[ -n "${TERM:-}" ]] && can_run tput; then + # Terminal colors + LWS_RED=$(tput setaf 1) + LWS_GREEN=$(tput setaf 2) + LWS_CYAN=$(tput setaf 6) + LWS_COLOR_RESET=$(tput sgr0) -# Bash prompt escape sequences -LWS_PS1_USER='\u' -LWS_PS1_HOST='\h' -LWS_PS1_DIR='\w' -LWS_PS1_TYPE='\$' -LWS_PS1_USER_HOST="${LWS_GREEN}${LWS_PS1_USER}@${LWS_PS1_HOST}${LWS_COLOR_RESET}:${LWS_CYAN}${LWS_PS1_DIR}${LWS_COLOR_RESET}" + # Bash prompt escape sequences + LWS_PS1_USER='\u' + LWS_PS1_HOST='\h' + LWS_PS1_DIR='\w' + LWS_PS1_TYPE='\$' + LWS_PS1_USER_HOST="${LWS_GREEN}${LWS_PS1_USER}@${LWS_PS1_HOST}${LWS_COLOR_RESET}:${LWS_CYAN}${LWS_PS1_DIR}${LWS_COLOR_RESET}" +fi diff --git a/rc/linuxbrew.sh b/rc/brew.sh similarity index 79% rename from rc/linuxbrew.sh rename to rc/brew.sh index d942491..851f1ff 100644 --- a/rc/linuxbrew.sh +++ b/rc/brew.sh @@ -1,9 +1,11 @@ # Homebrew initialization # Can set BREW_HOME in advance -xlog "Homebrew initialization" +xlog "Homebrew/Linuxbrew initialization" BREW_LOCATIONS=( + "/opt/homebrew" + "/usr/local/Homebrew" "$HOME/.local/share/linuxbrew" "$HOME/.linuxbrew" "/home/linuxbrew/.linuxbrew" @@ -28,8 +30,8 @@ if [[ -e "$BREW" ]]; then eval "$($BREW shellenv)" PATH="$path_backup" - append_path "$HOMEBREW_PREFIX/bin" - append_path "$HOMEBREW_PREFIX/sbin" + prepend_path "$HOMEBREW_PREFIX/bin" + prepend_path "$HOMEBREW_PREFIX/sbin" fi unset BREW diff --git a/rc/sdkman.sh b/rc/sdkman.sh index c8a6274..25dd175 100644 --- a/rc/sdkman.sh +++ b/rc/sdkman.sh @@ -1,4 +1,4 @@ -nop "${SDKMAN_DIR:=$HOME/.sdkman}" +: "${SDKMAN_DIR:=$HOME/.sdkman}" if [[ -d $SDKMAN_DIR ]]; then export SDKMAN_DIR source_try "$SDKMAN_DIR/bin/sdkman-init.sh"