Skip to main content

macos/README.md

1# macos
3These scripts are all for doing stuff on macOS.
4They rely on Mac-specific stuff and are unlikely to be useful on non-Mac systems.
6## The individual scripts
8<!-- [[[cog
10# This adds the root of the repo to the PATH, which has cog_helpers.py
11from os.path import abspath, dirname
12import sys; sys.path.append(abspath(dirname(dirname("."))))
14import cog_helpers
16folder_name = "macos"
18scripts = [
19 {
20 "name": "battery",
21 "description": "alias for <code>pmset -g batt</code>; reports the current battery level",
22 },
23 {
24 "name": "close_tabs",
25 "description": "close ephemeral tabs in Safari – basically, anything that can be easily recreated/reopened later."
26 },
27 {
28 "usage": "close_specific_tabs [example.org fragment.net]",
29 "description": "close tabs in Safari based on their URL – useful for closing tabs which I can see have high activity/CPU in Activity Monitor."
30 },
31 {
32 "name": "count_tabs",
33 "description": "count the number of tabs I have open in Safari."
34 },
35 {
36 "name": "ffile",
37 "description": "print the path to the frontmost selected item in Finder"
38 },
39 {
40 "name": "furl",
41 "description": "get the URL of the frontmost Safari window"
42 },
43 {
44 "name": "find_processes_using_secure_input",
45 "description": "lists any processes using Secure Input, which can block apps like TextExpander"
46 },
47 {
48 "usage": "get_all_live_text [directory]",
49 "description": "get OCR'd text for all the images in a directory using Live Text"
50 },
51 {
52 "name": "get_focus_mode",
53 "description": "prints the current Focus mode"
54 },
55 {
56 "name": "get_photo_sizes",
57 "description": "print the size of every item in my Photos Library."
58 },
59 {
60 "name": "list_safari_tabs",
61 "description": "print the URL of every tab I have open in Safari"
62 },
63 {
64 "name": "obnote",
65 "description": "print the path to the note I currently have open in [Obsidian](https://obsidian.md/), if any."
66 },
67 {
68 "usage": "set_accent_colour (red|orange|yellow|green|blue|purple|pink|graphite)",
69 "description": "set the accent colour, as configured in the Appearance settings",
70 },
71 {
72 "usage": "set_finder_comment PATH COMMENT",
73 "description": "Set the Finder comment of a file, which will be indexed by Spotlight for searching"
74 },
75 {
76 "usage": "set_iterm_tab_title.py TITLE",
77 "description": "Set the title of a tab in iTerm 2"
78 },
79 {
80 "usage": "sterilise [PATH]",
81 "description": "alias for <code>xattr -d com.apple.quarantine</code>"
82 },
83 {
84 "usage": "trash [PATH]",
85 "description": "move a file to the Trash"
86 },
87 {
88 "name": "unlock_keychain",
89 "description": """
90 alias for <code>security unlock-keychain ~/Library/Keychains/login.keychain</code>; unlocks the login keychain
91 <p>
92 The login keychain normally gets unlocked by the OS when you log into your account; this is for when I'm accessing a Mac over SSH.
93 </p>
94 """
95 }
98cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
100]]]-->
101<dl>
102 <dt>
103 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/battery">
104 <code>battery</code>
105 </a>
106 </dt>
107 <dd>
108 alias for <code>pmset -g batt</code>; reports the current battery level
109 </dd>
111 <dt>
112 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/close_tabs">
113 <code>close_tabs</code>
114 </a>
115 </dt>
116 <dd>
117 close ephemeral tabs in Safari – basically, anything that can be easily recreated/reopened later.
118 </dd>
120 <dt>
121 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/close_specific_tabs">
122 <code>close_specific_tabs [example.org fragment.net]</code>
123 </a>
124 </dt>
125 <dd>
126 close tabs in Safari based on their URL – useful for closing tabs which I can see have high activity/CPU in Activity Monitor.
127 </dd>
129 <dt>
130 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/count_tabs">
131 <code>count_tabs</code>
132 </a>
133 </dt>
134 <dd>
135 count the number of tabs I have open in Safari.
136 </dd>
138 <dt>
139 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/ffile">
140 <code>ffile</code>
141 </a>
142 </dt>
143 <dd>
144 print the path to the frontmost selected item in Finder
145 </dd>
147 <dt>
148 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/furl">
149 <code>furl</code>
150 </a>
151 </dt>
152 <dd>
153 get the URL of the frontmost Safari window
154 </dd>
156 <dt>
157 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/find_processes_using_secure_input">
158 <code>find_processes_using_secure_input</code>
159 </a>
160 </dt>
161 <dd>
162 lists any processes using Secure Input, which can block apps like TextExpander
163 </dd>
165 <dt>
166 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/get_all_live_text">
167 <code>get_all_live_text [directory]</code>
168 </a>
169 </dt>
170 <dd>
171 get OCR'd text for all the images in a directory using Live Text
172 </dd>
174 <dt>
175 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/get_focus_mode">
176 <code>get_focus_mode</code>
177 </a>
178 </dt>
179 <dd>
180 prints the current Focus mode
181 </dd>
183 <dt>
184 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/get_photo_sizes">
185 <code>get_photo_sizes</code>
186 </a>
187 </dt>
188 <dd>
189 print the size of every item in my Photos Library.
190 </dd>
192 <dt>
193 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/list_safari_tabs">
194 <code>list_safari_tabs</code>
195 </a>
196 </dt>
197 <dd>
198 print the URL of every tab I have open in Safari
199 </dd>
201 <dt>
202 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/obnote">
203 <code>obnote</code>
204 </a>
205 </dt>
206 <dd>
207 print the path to the note I currently have open in [Obsidian](https://obsidian.md/), if any.
208 </dd>
210 <dt>
211 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/set_accent_colour">
212 <code>set_accent_colour (red|orange|yellow|green|blue|purple|pink|graphite)</code>
213 </a>
214 </dt>
215 <dd>
216 set the accent colour, as configured in the Appearance settings
217 </dd>
219 <dt>
220 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/set_finder_comment">
221 <code>set_finder_comment PATH COMMENT</code>
222 </a>
223 </dt>
224 <dd>
225 Set the Finder comment of a file, which will be indexed by Spotlight for searching
226 </dd>
228 <dt>
229 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/set_iterm_tab_title.py">
230 <code>set_iterm_tab_title.py TITLE</code>
231 </a>
232 </dt>
233 <dd>
234 Set the title of a tab in iTerm 2
235 </dd>
237 <dt>
238 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/sterilise">
239 <code>sterilise [PATH]</code>
240 </a>
241 </dt>
242 <dd>
243 alias for <code>xattr -d com.apple.quarantine</code>
244 </dd>
246 <dt>
247 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/trash">
248 <code>trash [PATH]</code>
249 </a>
250 </dt>
251 <dd>
252 move a file to the Trash
253 </dd>
255 <dt>
256 <a href="https://github.com/alexwlchan/scripts/blob/main/macos/unlock_keychain">
257 <code>unlock_keychain</code>
258 </a>
259 </dt>
260 <dd>
261 alias for <code>security unlock-keychain ~/Library/Keychains/login.keychain</code>; unlocks the login keychain
262 <p>
263 The login keychain normally gets unlocked by the OS when you log into your account; this is for when I'm accessing a Mac over SSH.
264 </p>
265 </dd>
266</dl>
267<!-- [[[end]]] (sum: uJMF1iuiOs) -->