forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.functions
54 lines (47 loc) · 1012 Bytes
/
.functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# check if a command exists
function f_isset() {
type $1 &>/dev/null
}
# assert the command exists or exit with error
# TODO: can we just return instead
function f_assert_isset() {
if ! f_isset $1 ;then
f_debug "echo "$1" is not set"
else
exit 1
fi
}
# echos a function if $DEBUG is set
function f_debug() {
if [ -n "$DEBUG" ] ; then
echo $1
fi
}
# enable / disable debug
function f_enableDebug() {
export DEBUG=1
}
function f_disableDebug() {
unset DEBUG
}
# sync the current location
function lsync() {
source ~/.location/.current 2>/dev/null
f_debug "Setting location: $LOCATION"
f_setLocation $LOCATION
}
# MASTER WRAPPER
function f_setLocation() {
LOC=~/.location/.$1
if [ -f $LOC ] ;then
f_debug "Using $LOC"
source "$LOC" 2>/dev/null
else
f_debug "Could not find '$LOC'"
f_debug "Using .location_default"
source ~/.location/.default 2>/dev/null
fi
}
function chrome() {
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome $* > /dev/null 2>&1 &
}