-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions
71 lines (60 loc) · 1.67 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
68
69
70
71
function md() {
mkdir -p '$@' && cd '$@'
}
function search() {
find . -name '$1'
}
replace() {
find . -name '$1' -type f -exec sed -i 's/$2/$3/g' {} \;
}
open-tunnel() {
ssh -g -R 2222:localhost:22 $1
}
enter-tunnel() {
ssh -t $1 'ssh -p 2222 $2@localhost'
}
tmux-new() {
name=${1-tmux}
dir=${2-~}
tmux new-session -d -c "$dir" -s "$name"
tmux new-window -t "$name:2" -c "$dir"
tmux new-window -t "$name:3" -c "$dir"
tmux select-window -t "$name:1"
tmux switch-client -t "$name"
}
reset-dns() {
sudo networksetup -listallnetworkservices | grep -v "An asterisk" | while read service
do
sudo networksetup -setdnsservers $service 1.1.1.1
sudo networksetup -setsearchdomains $service lan
done
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
}
reset-wifi() {
sudo networksetup -removepreferredwirelessnetwork en0 "$1"
sudo networksetup -setairportpower en0 off
sudo networksetup -setairportpower en0 on
sudo networksetup -setairportnetwork en0 "$1"
}
set-wifi-macaddress() {
random_address=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
address=${1-$random_address}
sudo ifconfig en0 ether $address
sudo networksetup -setairportpower en0 off
sudo networksetup -setairportpower en0 on
}
update-hosts() {
sudo 'cp' -f /etc/hosts /etc/hosts_bck
wget "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" -O- > /tmp/etc_hosts
cat ~/.hosts >> /tmp/etc_hosts
sudo 'mv' -f /tmp/etc_hosts /etc/hosts_blocking
}
enable-hosts-blocking() {
sudo 'cp' -f /etc/hosts_blocking /etc/hosts
sudo dscacheutil -flushcache
}
disable-hosts-blocking() {
sudo 'cp' -f ~/.hosts /etc/hosts
sudo dscacheutil -flushcache
}