-
Notifications
You must be signed in to change notification settings - Fork 0
/
.functions
67 lines (55 loc) · 1.29 KB
/
.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
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Commit everything
function commit() {
commitMessage="$1"
if [ "$commitMessage" = "" ]; then
commitMessage="wip"
fi
git add .
eval "git commit -a -m '${commitMessage}'"
}
function ip {
if [[ $# -eq 0 ]] ; then
echo 'Please provide the URL to look up.'
return
fi
echo `dig +short $1 | awk '{ print ; exit }'`
}
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh;
else
local arg=-sh;
fi
if [[ -n "$@" ]]; then
du $arg -- "$@";
else
du $arg .[^.]* ./*;
fi;
}
# Use Git’s colored diff when available
hash git &>/dev/null;
if [ $? -eq 0 ]; then
function diff() {
git diff --no-index --color-words "$@";
}
fi;
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_";
}
internet() {
disconnected=false
while ! ping 8.8.8.8 -c 1 &> /dev/null; do
echo '❌ No internet connection.'
disconnected=true
sleep 1;
done;
# Show notification only if it was ever disconnected, so you
# can leave the command running in the background.
if $disconnected; then
osascript -e 'display notification "Connection restored ✅" with title "Internet"'
fi
echo '✅ Connected to internet.'
}