From 22425e5d12a943f86ad302013edbaa5459c5ade6 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Sat, 6 Jul 2024 10:04:55 +0300 Subject: [PATCH] {bash,zsh}rc: fix $PATH mainly for rbenv --- rc/bashrc | 18 +++++++++--------- rc/zshrc | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/rc/bashrc b/rc/bashrc index 14ee7905..92600542 100755 --- a/rc/bashrc +++ b/rc/bashrc @@ -210,14 +210,6 @@ TZ=$(date +%Z) # Sets PATH. To add another path, add : to string below. PATH=$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/usr/local/bin:/usr/local/sbin:/usr/local/games:/snap/bin:/usr/bin:/usr/sbin:/usr/games:/bin:/sbin:/games:$PATH -# Add RubyGems to PATH -if hash ruby 2> /dev/null; then - PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH" -fi - -# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896 -PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}') - # Colours to less # Copied from https://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html export LESS_TERMCAP_mb=$'\E[01;31m' @@ -276,12 +268,17 @@ fi # https://github.com/rbenv/rbenv if [ -d ~/.rbenv/bin ]; then - PATH="$HOME/.rbenv/bin:$PATH" + PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH" rbenv init > /dev/null 2>&1 # Remember! And verify it before running! # git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build fi +# Add RubyGems to PATH +if hash ruby 2> /dev/null; then + PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH" +fi + # https://github.com/pyenv/pyenv if [ -d ~/.pyenv/bin ]; then PATH="$HOME/.pyenv/bin:$PATH" @@ -296,6 +293,9 @@ if [ -d ~/.nodenv/bin ]; then # git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build fi +# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896 +PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}') + ##### Aliases RJ706I ##### # To get sudo work with aliases. diff --git a/rc/zshrc b/rc/zshrc index 9d96a515..1ed6581f 100755 --- a/rc/zshrc +++ b/rc/zshrc @@ -177,14 +177,6 @@ TZ=$(date +%Z) # Sets PATH. To add another path, add : to string below. PATH=$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/usr/local/bin:/usr/local/sbin:/usr/local/games:/snap/bin:/usr/bin:/usr/sbin:/usr/games:/bin:/sbin:/games:$PATH -# Add RubyGems to PATH -if hash ruby 2>/dev/null; then - PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH" -fi - -# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896 -PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}') - # Colours to less # Copied from https://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html export LESS_TERMCAP_mb=$'\E[01;31m' @@ -242,12 +234,17 @@ fi # https://github.com/rbenv/rbenv if [ -d ~/.rbenv/bin ]; then - PATH="$HOME/.rbenv/bin:$PATH" + PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH" rbenv init >/dev/null 2>&1 # Remember! And verify it before running! # git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build fi +# Add RubyGems to PATH +if hash ruby 2>/dev/null; then + PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH" +fi + # https://github.com/pyenv/pyenv if [ -d ~/.pyenv/bin ]; then PATH="$HOME/.pyenv/bin:$PATH" @@ -262,6 +259,9 @@ if [ -d ~/.nodenv/bin ]; then # git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build fi +# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896 +PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}') + ##### Aliases RJ706I ##### # To get sudo work with aliases.