Wed, 16 Mar 2016 01:16:41 -0400
nice up bashrc and xsessionrc
.bashrc | file | annotate | diff | comparison | revisions | |
.bashrc.lib | file | annotate | diff | comparison | revisions | |
.xsessionrc | file | annotate | diff | comparison | revisions |
--- 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 +
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 +} +
--- 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 </dev/null & xmodmap ~/.xmodmaprc