Whenever I’m updating my
zshrc and have to source it a lot, I dislike the way the path variable keeps duplicating itself so
one:two:three:one:two:three, etc. So, since I’ve been learning Ruby the past couple of months, I wrote a little script for myself to fix that.
It’s a good example of how Ruby can be used as a stand in for AWK. Place it at the end of your
zshrc and you can re-source as much as you want without creating duplicates.
export PATH=$(echo $PATH | ruby -F: -ane 'puts $F.uniq.join(":").chomp')