Rvm: Configuration

From FVue
(Redirected from Rvm: Source on first use)
Jump to: navigation, search

Problem

Duplicates in PATH in tmux sessions.

Solution (testing)

$ proj

This will start a Konsole session in directory ~/proj with a tmux session "proj" with the correct rvm installation.

How to do this: Create an alias to initiate working on project PROJ:

alias proj='cd ~/proj; tmuxp load proj'


# ~/.bashrc.d/prefix_path_unique.sh
# prefix_path_unique.sh
# See: https://unix.stackexchange.com/a/4973
# Example run: prefix_path_unique ~/perl5/bin ~/.bin
prefix_path_unique () {
  for d; do
    d=$({ cd -- "$d" && { pwd -P || pwd; } } 2>/dev/null)  # canonicalize symbolic links
    if [ -z "$d" ]; then continue; fi  # skip nonexistent directory
    case ":$PATH:" in
      *":$d:"*) :;;
      *) PATH=$d:$PATH;;
    esac
  done
}
# ~/.profile
...
prefix_path_unique /usr/local/share/bin
prefix_path_unique ~/bin
prefix_path_unique ~/.local/bin
...
# ~/.bash_profile
[[ -f ~/.profile ]] && . ~/.profile
 
# No unnecessary default loading of rvm
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"