From MacLeod Cartoons:


I get a fair amount of visitors looking for the recycling logo, due to the this article: Logo recycling, so I decided to actually make that visit worthwhile, instead of just a “disappointment”.
So, without further ado, here are the universal recycling and green point logos.

GreenDot (WikiPedia)

Green dot symbol
This file is from the Open Clip Art Library, which released it explicitly into the public domain, using the Creative Commons Public Domain Dedication.

[Original URL] [SVG (zip)]

Universal Recycling Symbol (WikiPedia)

Universal Recycling
This work was previously under Public Domain, or a Free License. It has been digitally enhanced and/or modified. This derivative work has been (or is hereby) released into the public domain by its author, Cbuckley at the English Wikipedia project. This applies worldwide.
In some countries this is not legally possible; if so:Cbuckley grants anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

[SVG (zip)]

If you, like me, strive to keep a well organized and modular configuration setup, sooner or later will split your bash configuration into multiple files. And if you want it to be valid for multiple machines you’ll appreciate the following function:


1
2
3
source_if_exists () {
    for i_; do test -f "$i_" && source "$i_"; done
}

This way, you can try to process other configuration fragments only when they exist:


1
source_if_exists ${HOME}/etc/bash_completion

Another common need for bash configuration is to either append or prepend paths to an environment variable. When doing a configuration for multiple machines it is always a pain to make sure those paths exist. These functions take care of that making adding directories to the path a breeze:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
safe_prepend_path() {
    VAR=$1
    shift
    VAL=$(eval echo \$${VAR})
    for i_; do
        test -d "$i_" && VAL=$i_${VAL:+":$VAL"}
    done
    eval export ${VAR}=$(echo ${VAL})
}

safe_append_path() {
    VAR=$1
    shift
    VAL=$(eval echo \$${VAR})
    for i_; do
        test -d "$i_" && VAL=${VAL:+"$VAL:"}$i_
    done
    eval export ${VAR}=$(echo ${VAL})
}

Example:


1
2
safe_prepend_path PATH /opt/local/bin ${HOME}/bin
safe_append_path MANPATH /opt/local/man ${HOME}/man

Also, it is not unusual to have some path variables with duplicate entries, which is not very efficient. This function makes sure that a path only occurs once, and retains only the first occurrence, thus keeping the search order intact.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
unique_path() {
    eval export $1=$(echo $(eval echo \$${1}) | \
        awk -F:                   \
        '{ a[$1];                 \
           printf "%s",$1;        \
           for(i=2;i<=NF;i++) {   \
             if(!($i in a)) {     \
               printf ":%s",$i;   \
             };                   \
             a[$i];               \
           };                     \
           printf "\n";           \
         }'
)
}

Example:


1
2
unique_path PATH
unique_path MANPATH

%d bloggers like this: