This is https://github.com/Ben-Voris/Mac-notes.git.
A prettier version is at https://ben-voris.github.io/Mac-notes/.
How to use the function keys on your Mac either:
Much of this is from Mac keyboard shortcuts
Command
+ X
: Cut the selected item and copy it to the Clipboard.Command
+ C
: Copy the selected item to the Clipboard. This also works for files
in the Finder.Command
+ V
: Paste the contents of the Clipboard into the current document or
app. This also works for files in the Finder.Command
+ Z
: Undo the previous command. You can then press Shift
+ Command
+ Z
to Redo, reversing the undo command. In some apps, you
can undo and redo multiple commands.Command
+ A
: Select All items.Command
+ F
: Find items in a document or open a Find window.Command
+ G
: Find Again: Find the next occurrence of the item previously found.
To find the previous occurrence, press Shift-Command
+ G
.Command
+ H
: Hide the windows of the front app. To view the front app but hide
all other apps, press Option
+ Command
+ H
.Command
+ M
: Minimize the front window to the Dock. To minimize all windows of
the front app, press Option
+ Command
+ M
.Command
+ O
: Open the selected item, or open a dialog to select a file to open.Command
+ P
: Open a print dialog so that you can print the current document.Command
+ S
: Save the current document.Command
+ T
: Open a new tab.Command
+ W
: Close the front window. To close all windows of the app, press
Option
+ Command
+ W
.Option
+ Command
+ Esc
: Force quit an app.Command
+ Space bar
: Show or hide the Spotlight search field. To perform a
Spotlight search from a Finder window, press Command
+ Option
+ Space bar
. (If you
use multiple input sources to type in different languages, these shortcuts
change input sources instead of showing Spotlight.
(Learn how to change a conflicting keyboard shortcut.)Control
+ Command
+ Space bar
or Fn
+ E
: Show the Character Viewer,
from which you can choose emoji and other symbols.Control
+ Command
+ F
: Use or stop using the app in full screen, if supported by
the app.Space bar
: Use Quick Look to preview the selected item.Command
+ Tab
: Switch to the next most recently used app among your open apps.
Command
+ `
(Grave accent): Switch between the windows of the app you’re using.Shift
+ Command
+ 5
: In macOS Mojave or later, take a screenshot or make a screen
recording.Shift
+ Command
+ 3
: Captures the entire screen and saves it to the desktop.Shift
+ Command
+ 4
: Captures a selection and saves it to the desktop.Shift
+ Command
+ N
: Create a new empty folder in the Finder.Control
+ Command
+ N
: Create a new folder that contains the currently selected
items.Command
+ ,
(Comma): Open settings (preferences) for the front app.Delete
: Deletes the character to the left of the cursor, i.e., Linux backspace.Fn
+ Delete
: Delete the character to the right, i.e., Linux delete.Option
+ Delete
: delete the word to the left of the cursor.Fn
+ Option
+ Delete
: delete the word to the right of the cursor.These key chords behave different in different apps.
In VS Code, they move both the display and where text is inserted. In some
documents, they seem to move based on document structure. For example, in this
Markdown document, Control
+ down-arrow
can move to the last section and, in
that case, pressing these keys a second time move to the bottom of the document.
In Notes, they move what text is displayed but do not move where text is inserted.
Fn
+ right-arrow
: In VS Code, this moves the cursor to the end of line but in
the Notes app, this displays the end of line but does not change the text
insertion point.Fn
+ left-arrow
: Depends on the app, Moves the cursor to the beginning of the
line.Fn
+ down-arrow
: Moves to the bottom of the window or document or, in
VS Code and Safari, Page DownFn
+ up-arrow
: Moves to the top of the window or document or, in VS Code
and Safari, Page Up.Return
means SendShift
+ Return
Used in Signal and MessagesSettings
> Trackpad
Remember to use both hands. For example, for me, swiping from the left is easier with the left hand. When selecting a large amount of text, it is possible to start the “click drag” with one hand and extend it with the other.
Point & Click
Click
to Medium
or Firm
.Force Click and haptic feedback
.Look up & data detectors
to Force Click with One Finger
.Secondary click
(i.e., “right click”) to Click with Two Fingers
Tap to click
. If this is enabled, a light tap is registered as a
click.Force click is a longish hard press that, if haptic feedback is enabled, gives a distinct “bump” as feedback.
An example of a “data detector” is a dictionary lookup that can appear when a word is selected that is in the dictionary. See dictionary lookup.
Enable
Natural scrolling
/ Contents track finger movement
Zoom in or out
/ Pinch with two fingers
Smart Zoom
/ Double tab with two fingers
Rotate
/ Rotate with two fingers
Swipe between pages
to Scroll Left or Right with Two Fingers
Swipe between full-screen applications
to
Swipe Left or Right with Three fingers
Notification Center
/
Swipe left from the right edge with two fingers
Mission Control
to Swipe Up with Three Fingers
. This shows a set
of small views of the currently running applications. Clicking on one
brings that application to the foreground.App Exposé
to Swipe Down with Three Fingers
This exposes the files
opened by the current foreground application. Swipe up with three fingers
to hide this.Launchpad
to Pinch with thumb and three fingers
Show Desktop
to Spread with thumb and three fingers
Control
+ Click to get
suggestions.Dictionary lookup can be enabled by turning System Settings
> Trackpad
.
Sometimes this does not work, even for words that are in the dictionary. And then it starts working.
Unfortunately, the mouse command is not consistent. All start with clicking on a on a word to select it, then a “Force Click” but with a different number of fingers.
Mail
, Safari
and Visual Studio
- A three-finger “Force Click”Visual Studio
and Preview
- A one-finger “Force Click”Preview
- A two-finger “Force Click” followed by scrolling to Look Up
and then a single clickOption
+ Delete
When focus is in the message header view, deletes the
highlighted message without advancing to the next message. If this is what
you want as the default, uncheck Settings
> Viewing
>
Automatically view next message after discarding or archiving a message
.Command
+ Shift
+ N
: Refresh mailbox.Command
+ Shift
+ +
: When focus is on a message, increases the
displayed size of the message content (zoom in).Command
+ Shift
+ -
: When focus is on a message, decreases the
displayed size of the message content (zoom out).Control
+ Click on a message: Displays options for tapback, edit message,
delete, replyControl
+ Click on a Link: Opens in a new tabCommand
+ Z
: Undo close tab+
(new tab) shows recently closed tabs. Clicking on one
reopens it.Show the previous page
and Show the next page
).Option
+ Command
+ F
: Find and replace.Shift
+ Command
+ \
: Jump to the matching bracketControl
+ G
: Jump to line numberCommand
+ K
+ S
: Open Keyboard ShortcutsFn
+ F1
or Command
+ Shift
+ P
: Open CommandControl
+ P
: Previous line. Same as the up arrow key.Control
+ N
: Next line. Same as the down arrow key.VS Code steals the default minimize Command
+ M
. I found no shortcut that
uses only this, but some use it in conjunction with other keys, like Command
+
K
+ M
for “Change Language Mode” and Shift
+ Command
+ M
for “Toggle
Problems”.
At the VS Code command prompt, type shell
and select
Install 'code' command in PATH
, then follow its prompt. You can then enter
commands like these:
code ./
code file-name
Contrary to what it says, on MacOS, this command dos not update PATH but creates this:
/usr/local/bin/code: symbolic link to /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code
Or use the open(1)
command, as in this example:
open --new -a "Visual Studio Code" --args --new-window file-name
It is necessary to tell open(1)
to open a new window (--new
) and to tell
VS Code to create a new window with --new-window
.
Use Automator
to create a Quick Action
for Files and Folders.
Open a Folder in VS Code through Finder in MacOS
Automator
Quick Action
, Click on Choose
Workflow receives current
to Files or Folders
in Finder
Image
and Choose
. This opens a Finder-type windowApplication
Visual Studio Code
, click on Choose
Note that Image
is now
Custom
Open Finder items
in the LibraryOpen With
, then find Visual Studio Code
File
> Save
(or Command
+ S
) and enter something like “Open
with Visual Studio Code”.To use what you just created:
Control
+ Click on the itemQuick Actions
This depends upon displaying the photo in the Preview
app and so does not work
for a photo that is in a shared album.
Interact with text in a photo using Live Text in Preview on Mac
Double click on the picture to open the Preview app.
Control
+ Click on the photoEdit With
Preview
(NB: you’ll see a shortcut Command
+ Return
. It doesn’t
work.)Tools
> Text Selection
Command
+ C
Keyboard shortcuts and gestures in Photos on Mac
This only works for a local photo and does not work for a photo in a shared album.
i
in the tool bar. A window will
open. Click inside Title
or Caption
or Keywords
, and type. Close the
window.Some iOS apps, like Feedly, Netflix, Youtube, etc. are not available for Mac.
For these, visit the page, click on the Share
(up arrow) and click on Add to
Dock
. Links that are added to the dock also appear in the Apps folder.
https://code.visualstudio.com/download
Add these extensions
Bash IDE | mads-hartmann.bash-ide-vscode |
Bookmarks | alefragnani.Bookmarks |
C/C++ | ms-vscode.cpptools |
C/C++ Themes | ms-vscode.cpptools-themes |
markdownlint | DavidAnson.vscode-markdownlint |
Rewrap Revived | dnut.rewrap-revived |
Sort JSON objects | richie5um2.vscode-sort-json |
Sort lines | Tyriar.sort-lines |
Spell Right | ban.spellright |
Sign into GitHub.
macOS will display “Apple could not verify …. is free of malware …” and
will offer to “Move to Trash”. Click Done
and follow the steps in
Removing a file from quarantine.
Download at https://download.sqlitebrowser.org
See https://github.com/sqlitebrowser/sqlitebrowser/.
https://www.torproject.org/download/
https://signal.org/download/macos/
Existing chats from other devices are not synchronized.
https://www.mozilla.org/en-US/firefox/mac/
A photo cataloging tool I used on Linux
https://www.digikam.org/download/
Installing this requires removing the installer from quarantine.
A GPS format converter.
https://github.com/gpsbabel/gpsbabel
Installing this requires removing the installer from quarantine.
Download the tar from https://jdk.java.net/23/
Install in /usr/local with
sudo tar -xf ~/Downloads/toInstall/openjdk-23.0.2_macos-aarch64_bin.tar.gz -C /usr/local/bin/
Or put it in your home directory with
tar -xf ~/Downloads/toInstall/openjdk-23.0.2_macos-aarch64_bin.tar.gz -C ~/
Then add this to your .bashrc
or similar:
export JAVA_HOME=/usr/local/bin/jdk-23.0.2.jdk/Contents/Home/
PATH="${PATH}:${JAVA_HOME}/bin:"
osxphotos
Requires Macports
.
osxphotos
gives information about
files stored in the photo database.
sudo port install osxphotos
System Settings
> Touch ID & Password
set
Use Touch ID for autofilling passwords
on.System Settings
> Autofill from
> AutoFill & Password
, turn Passwords
off
and Strongbox
on, and list Strongbox
in Setup Code In
Login Items & Extensions
>
Open at Login
Apple wants me to use zsh because it hooks into Apple thingies.
To avoid the annoying warning about zsh when starting bash, put this into
~/.zshenv
:
# See https://support.apple.com/en-us/102360
export BASH_SILENCE_DEPRECATION_WARNING=1
Sometimes Control
+ C
stops working and you’ll hear a beep. When this
happens, try Command
+ .
When you exit the shell, Terminal
will stay running. To prevent this, in the
Terminal
settings Profiles
, change “When the shell exits” to “Close if shell
exited cleanly”.
Keyboard shortcuts in Terminal on Mac
Do not confuse Command
with Control
. For example, Command
+ D
splits the terminal window
into two panes but Control
+ D
is an end-of-file.
The keyboard shortcuts cannot be disabled. They can be assigned to a different chord.
(Shift
+ Command
+ D
undoes the split created by Command
+ D
.)
First, select a file or files in Finder, then drag
the files to a Terminal window using Command
+ Click, much like
moving files in Finder.
Try pointing SQL Lite browser at
database/Photos.sqlite
.
The picture files are in "${HOME}/Pictures/Photos Library.photoslibrary/"
The double quotes are necessary (that, or escape the space).
For one picture, with some edits, there are six files.
See exiftool
output for an example jpeg.
scopes/cloudsharing/data
contains at least some (all?) of the photos from
shared albums.
This command launches the Preview app from the zsh (not bash) command line:
open -a Preview -- "${HOME}/Pictures/Photos Library.photoslibrary/originals/0/0FB91698-EF23-48BF-96A9-F7902A77E118.jpeg
See osphotos
If you have the full path to the photo, the terminal open
command will open
the preview app.
To copy from iPhone to Mac or NAS
PhotoSync – transfer photos on App store
Visit photosync-app.com
for a complete feature list.
Photo Exifer claims to import XMP data to the Photos app. See How to import XMP sidecars to Photos on Mac?
Photo Exifer is compatible with extensible metadata files, supporting XMP files from Apple Photos and JSON files from Google Photos. It allows you to read photo metadata from XMP and JSON files and write it back to the corresponding photos
Photo Exifer likely cannot write files to a RAW file. It does not create an XMP file.
mlds(1)
mdls
lists the metadata attributes for the specified file
It will display GPS info, etc. from a photo that has data.
Note that GPS data added to a photo using the Photos app is not written to the file.
These use defaults(1)
to “access the Mac OS X user defaults system”.
When using the trackpad, and the default configuration, I find it too easy to accidentally rearrange the dock. Here’s a command to prevent that.
defaults write com.apple.Dock contents-immutable -bool true && killall Dock
When this contents-immutable
is set, apps cannot be drug into the dock.
defaults write com.apple.Dock contents-immutable -bool false && killall Dock
defaults
can also be used to control whether one can change the docks’s
position com.apple.Dock position-immutable
and size
com.apple.Dock size-immutable
.
defaults
to read a valuedefaults read com.apple.Dock contents-immutable
Homebrew and MacPorts are ways of getting open source tools running on a Mac. Both are actively maintained.
Here are Apple’s ports
MacPorts and their mpstats
tool
installed quickly but the first real package I installed,
shellcheck
,
took tens of minutes because it pulled so many dependencies - 465 packages per
port echo rdepof:shellcheck
- some of which did not have prebuilt binaries.
Thoughts on macOS Package Managers is in favor of MacPorts because it is more consistent with Linux and issues with how the project is run. Notes that Homebrew is sometimes updated more quickly. Though this is old, more recent pages link to it.
Responses to this
Reddit
lean towards Homebrew because it usually carries over with less between MacOS
releases, though some note that can cause more problems than it fixes because
Homebrew depends on the MacOS libraries. Also notes that its refusal to share
/usr/local
can cause problems.
system_profiler SPUSBDataType
Example output with Garmin e-collar attached:
USB:
USB 3.1 Bus:
Host Controller Driver: AppleT8132USBXHCI
Vendor-Specific Device:
Product ID: 0x0003
Vendor ID: 0x091e (Garmin International)
Version: 0.01
Speed: Up to 12 Mb/s
Location ID: 0x03100000 / 1
Current Available (mA): 500
Current Required (mA): 500
Extra Operating Current (mA): 0
USB 3.1 Bus:
Host Controller Driver: AppleT8132USBXHCI
USB 3.1 Bus:
Host Controller Driver: AppleT8132USBXHCI
ioreg -p IOUSB
lists information about the USB controllers but I can’t get it
to display the attached device, as shown above.
How to record the screen on your Mac
Shift
+
Command
+ 5
.Options
in the toolbar to
change the recording settings:
Show Mouse Clicks
.Record
.Record
button in the Screenshot toolbar.Stop
button in the menu bar, or press
Command
+ Control
+ esc
(Escape).Learn more about using the Screenshot app
File
> New Screen Recording
. Or press
Control
+ Command
+ N
.
Record
button to change the recording settings:
Show Mouse Clicks in Recording
.Start Recording
within
that area.Stop
button in the menu
bar, or press Command
+ Control
+ ecc
(Escape).Learn more about using QuickTime Player
Finder
> Applications
, click on the application, then press Command
+ Delete
.
If you try to open a file and get the message “Apple could not verify … is free of malware” and you’re sure the file is safe, you can mark it as safe.
For an install programs
Done
.System Settings
> Privacy & Security
Security
, you should see the package you tried to
install. Click on Open Anyway
and the click on it again. Then enter your
local password (not for the Apple account).Otherwise:
xattr -d com.apple.quarantine <file-name>
Or, enter this, with a trailing space.
xattr -d com.apple.quarantine
Then drag the file from Finder
into the Terminal window. THe Terminal will
fill in the file path. Then press return.
If you accidentally issue xattr -d
a second time for the same file, xattr
will print a message like this:
xattr: <file>: No such xattr: com.apple.quarantine
Finder
> Settings
> General
: Change the value of
New Finder windows show
.
To display the path as text, instead of a series of icons.
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true && killall Finder
Option
+ Left-click (two fingers on track pad)Option
, select Copy ... as Pathname
Command
+ Up-Arrow to go up a directory level I.e., cd ..
.Command
+ Down-Arrow to return to the previous directory. I.e., cd -
.Command
+ Shift
+ g
Opens a dialog that accepts a directory. This does
not accept ..
or ../
but does accept ~
.Command
+ Shift
+ h
. Jump to user’s home directory. I.e., cd ~
.Select a file by clicking on it. To select additional files, either Command
+
Click on each additional file or, to select a range of files, Shift
+ Click
on the last file in the range.
First select a file or files, then Command
+
C
, then select the target, and click either click on Edit
> Paste
or right
click on the source then click on Paste
. (Do not use Command
+ V
as that
will copy the files.)
This doesn’t work and I don’t know what I left out or mistyped.
First select a file or files. Next press Command
+ Click on one of the selected files and drag the files to the desired
directory, which can be in the same Finder windows, another, Finder window or
the desktop. Once you start dragging, you can release the Command
key.
To cancel the move, drop the selected file(s) back in their original location.
Right click (two fingers on the trackpad) on the source, click on Copy
.
Right click on the source, click on Paste
.
Control
+ Click on a fileOpen With
Other...
and find the
desired app.To make this change permanent, even if the desired app is listed, do not pick
it from the list. Instead, click on Other...
, find the desired app, check the
box Always Open With
, then click on Open
.
This changed the default app used to open this file and does not change the default app for the file type.
For more information, see the ResForge project, the Resource Fork wiki, and File system formats available in Disk Utility on Mac.
Control
+ Click on a fileGet info
Open with
Change All...
Continue
.See /etc/bashrc
which leads to /etc/bashrc_Apple_Terminal
.
Access to some directories where ls(1)
shows the user should have access give
“Operation not permitted”, even with root access.
ls -ld -@ ~/Library/Safari
drwxr-xr-x@ 44 bvoris staff 1408 Mar 9 16:38 /Users/bvoris/Library/Safari
com.apple.quarantine -1
: ls ~/Library/Safari
ls: Library/Safari: Operation not permitted
: sudo ls ~/Library/Safari
ls: Library/Safari: Operation not permitted
From ls(1)
If the file or directory has extended attributes, the permissions field printed by the -l option is followed by a ‘@’ character. Otherwise, if the file or directory has extended security information (such as an access control list), the permissions field printed by the -l option is followed by a ‘+’ character. If the -% option is given, a ‘%’ character follows the permissions field for dataless files and directories, possibly replacing the ‘@’ or ‘+’ character.
Permission is granted in System Settings
> Privacy & Security
.
Photos
Files and Folders
Full Disk Access
/etc/resolv.conf
, which is a symbolic link to /private/etc/resolv.conf
,
which is a symbolic link to ../var/run/resolv.conf
contains this:
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
# scutil --dns
#
# SEE ALSO
# dns-sd(1), scutil(8)
#
# This file is automatically generated.
The nameserver
values listed in resolv.conf
come from
System Settings
> Network
> Details
(of current connection) > DNS
MacOS does not use /etc/passwd
.
To edit a user from Settings
> Control
+ Click on the user name.
“Advanced Options…” should appear. Click on it.
From the command line, use dscacheutil
and dseditgroup
and maybe
chsh
and passwd
sudo chpass -s /opt/local/bin/bash bvoris
Without sudo
, this will fail with
"chpass: /opt/local/bin/bash: non-standard shell"
dscacheutil -q group -a name _developer
dscl . -read /Groups/_developer
dscacheutil -q user -a name bvoris
The output of this next command includes an encoded picture, so its very long.
dscl . -read /Users/bvoris
#!/bin/bash
# members -- list all members of a group
#
# SYNOPSIS
# members groupname
#
# http://superuser.com/questions/279891/list-all-members-of-a-group-mac-os-x
# by Arne
# Expected to work on Mac OS 10.5 and newer, tested on 10.6 and 10.7.
# It could be rewritten to work on 10.4 by using "dseditgroup -o checkmember"
# instead of "dsmemberutil checkmembership".
# By using dseditgroup, the script could also be extended to handle
# other Directory Service nodes than the default local node.
#
the_group="$1"
# Input check and usage
if [[ $# != 1 || $1 == -* || $1 =~ [[:space:]] ]]; then
echo "Usage: ${0##*/} groupname" >&2
echo "Lists all members of the group." >&2
exit 64
elif (dsmemberutil checkmembership -U root -G "$the_group" 2>&1 \
| grep "group .* cannot be found") >&2; then
exit 1
fi
# Check every user
exec dscl . -list /Users \
| while read each_username
do
printf "$each_username "
dsmemberutil checkmembership -U "$each_username" -G "$the_group"
done \
| grep "is a member" | cut -d " " -f 1
Apples supports both man
and info
but man -k
(search for a command) and
whatis
always outputs “nothing appropriate”.
Try man makewhatis
and man whatis
.
: echo $MANPATH
:/usr/share/man
sudo /usr/libexec/makewhatis
fails with "makewhatis: /usr/share/man/whatis.tmp: Read-only file system"
.
/opt/local/bin/whatis cp
whatis: nothing appropriate
/usr/bin/whatis cp
gives lots of ugly output (groff
errors?) but eventually shows cp(1)
sudo port install man-db
Outputs this:
found in man-db-2.13.0/config.log
---> Building man-db
---> Staging man-db into destroot
---> Installing man-db @2.13.0_0
---> Activating man-db @2.13.0_0
Error: Failed to activate man-db: The following ports have active files that conflict with man-db's:
mandoc @1.14.6_0
/opt/local/bin/apropos
/opt/local/bin/man
/opt/local/bin/whatis
(... 3 more not shown)
Image error: Conflicting file(s) present. Please deactivate the conflicting port(s) first, or use 'port -f activate man-db' to force the activation.
while executing
"throw registry::image-error $msg"
("foreach" body line 35)
invoked from within
"foreach file $imagefiles {
incr progress_step
_progress update $progress_step $progress_total_steps
se..."
invoked from within
"registry::write {
foreach file $imagefiles {
incr progress_step
_progress update $progress_step $progress_..."
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_textproc_man-db/man-db/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port man-db failed