Commit 09396c56 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

moved .profile:pathmunge to .shell/funcs:manage_path

parent bbf32073
Loading
Loading
Loading
Loading
+10 −30
Original line number Diff line number Diff line
@@ -14,45 +14,25 @@ export PROMPTCOLOUR=$((($(hostname|cksum|cut -f1 -d\ ) % 6) + 31))
# "~/.local"
PREFIX=":/usr:/usr/local"

pathmunge()
{
	local var="$1" val="$2"; shift 2
	eval local cur=\$$var
	case ":$cur:" in
		*:$val:*) return ;;
	esac
	local pre="$cur" post=
	while [ $# -gt 0 ]; do
		case "$1" in
			begin*|before|infront)
				post="$cur"
				pre=
				;;
			check)
				test -d "$val" || return 0 ;;
		esac
		shift
	done
	eval $var="'${pre:+$pre:}$val${post:+:$post}'"
}
. ~/.shell/funcs

pathmunge PATH ~/.local/bin before check
pathmunge LD_LIBRARY_PATH ~/.local/lib before check
pathmunge PKG_CONFIG_PATH ~/.local/lib/pkgconfig before check
pathmunge PREFIX ~/.local
manage_path PATH ~/.local/bin before check
manage_path LD_LIBRARY_PATH ~/.local/lib before check
manage_path PKG_CONFIG_PATH ~/.local/lib/pkgconfig before check
manage_path PREFIX ~/.local

# Other local bin paths
pathmunge PATH ~/.bin check
pathmunge PATH ~/bin check
manage_path PATH ~/.bin check
manage_path PATH ~/bin check

# Super user bin paths
pathmunge PATH /sbin
pathmunge PATH /usr/sbin
manage_path PATH /sbin
manage_path PATH /usr/sbin

export PATH
export LD_LIBRARY_PATH
export PKG_CONFIG_PATH
unset -f pathmunge
unset -f manage_path


## MacOSX Specific
+23 −1
Original line number Diff line number Diff line
#!/bin/bash
#!/bin/sh

source_first()
{
@@ -27,3 +27,25 @@ get_platform()
		*) echo $OSTYPE ;;
	esac
}

manage_path()
{
	local var="$1" val="$2"; shift 2
	eval local cur=\$$var
	case ":$cur:" in
		*:$val:*) return ;;
	esac
	local pre="$cur" post=
	while [ $# -gt 0 ]; do
		case "$1" in
			begin*|before|infront)
				post="$cur"
				pre=
				;;
			check)
				test -d "$val" || return 0 ;;
		esac
		shift
	done
	eval $var="'${pre:+$pre:}$val${post:+:$post}'"
}