-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctions.sh
72 lines (62 loc) · 1.27 KB
/
functions.sh
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
68
69
70
71
72
google() { open "https://www.google.com/search?q=$@" ;}
# Fuzzy finders
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
branch() {
git checkout ${1:-$(
git for-each-ref \
--sort=-committerdate \
--format='%(refname:short)' \
refs/heads/ \
| fzf
)}
}
code() {
if [ ! -z "$CODESPACES" ]; then
cd /workspaces/${1:-$(
find /workspaces -maxdepth 1 -type d | \
cut -f 3 -d "/" | \
fzf
)}
else
cd ~/Code/${1:-$(
find ~/Code -maxdepth 2 -type d | \
grep ".*/.*$" | \
cut -f 5-6 -d "/" | \
fzf
)}
fi
}
# Directory jumping
cddotfiles() { cd ~/.dotfiles ;}
cdroot() { cd `git rev-parse --git-dir`/.. ;}
# Show screen size
xy() {
echo "$(tput cols)x$(tput lines)"
}
publicip() {
curl https://api.ipify.org
}
# Returns nonzero if there's no internet connection
online() {
scutil -r 8.8.8.8 | grep "^Reachable" > /dev/null
}
# Returns nonzero if I'm not at home.
at_home() {
networksetup -getairportnetwork en0 | grep Campbell > /dev/null
}
hue_brightness() {
hour=$(date +"%H")
if [ "$hour" -ge 7 -a "$hour" -le 19 ]; then
echo "254"
else
echo "192"
fi
}
hue_temperature() {
hour=$(date +"%H")
if [ "$hour" -ge 7 -a "$hour" -le 19 ]; then
echo "4500k"
else
echo "2700k"
fi
}