Skip to content

Instantly share code, notes, and snippets.

View ccoomber's full-sized avatar

Chris Coomber ccoomber

View GitHub Profile
@ccoomber
ccoomber / gist:8071535
Last active January 1, 2016 01:18
Bash: Redirect All To Log File
# Redirect stdout and stderr to tee. Append all to logFile
# and leave on standard streams.
logFile="foo.log"
exec > >(tee -a "${logFile}")
exec 2> >(tee -a "${logFile}" >&2)
@ccoomber
ccoomber / gist:5886028
Last active December 19, 2015 02:49
Bash: Add to PATH
# addToPATH funciton for adding a directory to PATH.
# Prevents duplicate entries and ensures directory exists.
# $1 = Directory to add to PATH
addToPATH(){
if [ -d "${1}" ]; then
case ":${PATH}:" in
*":${1}:"*);; #Directory already in PATH
*) PATH="${PATH}:${1}";; #Append directory to PATH
esac
fi