# HG changeset patch # User Meredith Howard # Date 1458105401 14400 # Node ID dda2a7f4d485b46c8f93499003687392d4e6ce4f # Parent 368d0e4449edeba95466322a3f46f53863cd809c nice up bashrc and xsessionrc diff --git a/.bashrc b/.bashrc --- a/.bashrc +++ b/.bashrc @@ -5,19 +5,15 @@ if [ -f ~/.bashrc.dist ]; then source ~/.bashrc.dist fi -source ~/.profile.common +source .bashrc.lib -if [ -d ~/bin ]; then - export PATH="$HOME/bin:$PATH" -fi +path-prepend "$HOME/bin" -if [ -d ~/.plenv ]; then - export PATH="$HOME/.plenv/bin:$PATH" +if path-prepend "$HOME/.plenv/bin"; then eval "$(plenv init -)" fi -if [ -d ~/.rbenv ]; then - export PATH="$HOME/.rbenv/bin:$PATH" +if path-prepend "$HOME/.rbenv/bin"; then eval "$(rbenv init -)" fi @@ -26,3 +22,5 @@ if [ -f ~/.bashrc.local ]; then source ~/.bashrc.local fi +source ~/.profile.common + diff --git a/.bashrc.lib b/.bashrc.lib new file mode 100644 --- /dev/null +++ b/.bashrc.lib @@ -0,0 +1,18 @@ +# vim: ft=sh + +path-append() { + if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then + PATH="${PATH:+"$PATH:"}$1" + return 0 + fi + return 1 +} + +path-prepend() { + if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then + PATH="$1${PATH:+":$PATH"}" + return 0 + fi + return 1 +} + diff --git a/.xsessionrc b/.xsessionrc --- a/.xsessionrc +++ b/.xsessionrc @@ -1,25 +1,11 @@ -#!/usr/bin/env bash - -if [ -d ~/bin ]; then - export PATH="$HOME/bin:$PATH" -fi +#!/bin/bash -if [ -d ~/.plenv ]; then - export PATH="$HOME/.plenv/bin:$PATH" - eval "$( plenv init - )" -fi - -if [ -d ~/.rbenv ]; then - export PATH="$HOME/.rbenv/bin:$PATH" - eval "$( rbenv init - )" -fi - +source .bashrc if [ "$(uname -s)" = "OpenBSD" ]; then PATH="/usr/X11R6/bin:$PATH" fi - xcompmgr -n &>/dev/null