Files
q-tools/rc
Ville Rantanen a895b90030 typo
2015-07-20 08:30:31 +03:00

26 lines
707 B
Plaintext

# source me to enable tools
TOOLSPATH=$( readlink -f $( dirname "$BASH_SOURCE" ) )
PATH=$PATH:"$TOOLSPATH"/bin
# remove duplicate path
PATH=$( echo $PATH | awk -F: '{for (i=1;i<=NF;i++) { if ( !x[$i]++ ) printf("%s:",$i); }}' | sed 's,:\+$,,g' )
export PATH
. "$TOOLSPATH"/qcd_function
# Update self weekly
[[ -f "$TOOLSPATH"/.lastupdate ]] || touch -t 0101010101 "$TOOLSPATH"/.lastupdate 2> /dev/null
[[ -f "$TOOLSPATH"/.lastupdate ]] || return
TOOLS_LASTUPDATE=$(( $( date +%s ) - $( stat -c %Y "$TOOLSPATH"/.lastupdate ) ))
[[ "$TOOLS_LASTUPDATE" -gt 604800 ]] && {
touch "$TOOLSPATH"/.lastupdate
pushd "$TOOLSPATH" > /dev/null
hg pull -u
popd > /dev/null
}
unset TOOLS_LASTUPDATE