summaryrefslogtreecommitdiff
path: root/archive/bin/apple-setup.sh
blob: 21f382f172945a536c73a4d71e93f1f4acf80946 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh

USB=/Volumes/SPWHITTON

key()
{
    local k="$1"
    osascript -e "tell application \"System Events\" to keystroke \"$k\""
}

code()
{
    local k="$1"
    osascript -e "tell application \"System Events\" to key code $k"
}

# activate my keyboard preferences

osascript -e 'tell application "System Preferences" to activate'
osascript -e 'tell application "System Preferences" to set current pane to pane "com.apple.preference.keyboard"'
osascript -e 'tell application "System Events" to key code 98 using {control down}' # ctrl-f7 to activate tabbing between controls
sleep 1
code 48
code 48
code 48
code 48
code 49
code 48
code 48
code 48
code 49
code 125
code 125
code 52
code 48
code 48
code 49
code 125
code 52
code 48
code 49
code 126
code 52
code 48
code 48
code 48
code 49
osascript -e 'tell application "System Events" to key code 98 using {control down}'
osascript -e 'tell application "System Events" to keystroke "q" using {command down}'

# setup

if ! [ -d "$HOME/src/dotfiles/.git" ]; then
    git clone https://git.spwhitton.name/dotfiles $HOME/src/dotfiles
    # this is currently out of action because GNU stow installs but
    # doesn't seem to actually do anything on Mac OS
    # $HOME/src/dotfiles/bin/bstraph
    cp $HOME/src/dotfiles/{.zshrc,.shenv} $HOME # instead
fi
pkill firefox
/Applications/Firefox.app/Contents/MacOS/firefox -private-window http://u.arizona.edu/~spwhitton/bookmarks.shtml >/dev/null 2>/dev/null &
mkdir -p $HOME/.ssh
cp $USB/lib/{id_putty,known_hosts,config} $HOME/.ssh
chmod 600 $HOME/.ssh/id_putty

# run the shell

cd $HOME
/bin/zsh

# cleanup

pkill firefox
pkill ssh # cached connection!
echo "Please wait, securely deleting files..."
rm -rfP $HOME/.ssh/{id_putty,config} $HOME/Downloads/* $HOME/.Trash/* $HOME/.zshist $HOME/.bash_history

# reset keyboard preferences

osascript -e 'tell application "System Events" to key code 98 using {control down}'
osascript -e 'tell application "System Preferences" to activate'
osascript -e 'tell application "System Preferences" to set current pane to pane "com.apple.preference.keyboard"'
sleep 1
code 48
code 48
code 48
code 48
code 49
code 48
code 48
code 48
code 49
code 48
code 48
code 48
code 48
code 49
code 48
code 48
code 49
osascript -e 'tell application "System Events" to key code 98 using {control down}'
osascript -e 'tell application "System Events" to keystroke "q" using {command down}'