Tony Perrie ([info]hoyhoy) wrote,
@ 2006-05-11 18:12:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Entry tags:*nix

Pathmunge
This one came from reading RHEL4U3's default /etc/profile today. Before you call me a nerd and go back to your so called life, hear me out on this. So, the good folks in Raleigh decided to add a function called pathmunge to their default profile. This function just allows you to type stuff like pathmunge ~/bin after to add a directory to your search path. Most self-respecting nerds probably sorted this out in 1987, however, I'm an idiot and continue to do things the old fashioned way until I'm bludgeoned with the technology stick. Unfortunately, pathmunge doesn't get added to the default shell environment for all users. So, I just added it to /etc/bashrc on my machines today. Here is how to implement pathmunge in all of its glory...


pathmunge () {
  if ! echo $PATH | /bin/egrep -q '(^|:)$1($|:)' ; then
    if [ "$2" = "after" ] ; then
      PATH=$PATH:$1
    else
      PATH=$1:$PATH
    fi
  fi
}
Feel free to throw this into your ~/.bashrc if you haven't implemented it already.




Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…