view .shell.d/00.path_manipulation.sh @ 42:f0f437b22cea

bash tweak (bash does not like local outside of functions)
author Augie Fackler <durin42@gmail.com>
date Tue, 27 Jan 2009 14:25:15 -0500
parents 62bfb554ab85
children de6d0a9a7e3f
line wrap: on
line source

# Functions for manipulating $PATH. Split out so I can use them in .zshenv if I want.

function insert_path_element() {
    if echo "$PATH" | grep "$1:" >> /dev/null; then
        true
    else
        export PATH="$1:$PATH"
    fi
}

function remove_path_element() {
    if echo "$PATH" | grep "$1:" >> /dev/null; then
        export PATH="`echo $PATH | sed s%$1:%%`"
    else
        echo $1 not in PATH
    fi
}