Mac: Difference between revisions

From 太極
Jump to navigation Jump to search
(468 intermediate revisions by the same user not shown)
Line 28: Line 28:


== BSD and Linux ==
== BSD and Linux ==
[https://www.howtogeek.com/190773/htg-explains-whats-the-difference-between-linux-and-bsd/ What’s the Difference Between Linux and BSD?]
* [https://www.howtogeek.com/190773/htg-explains-whats-the-difference-between-linux-and-bsd/ What’s the Difference Between Linux and BSD?]
* [https://www.makeuseof.com/best-bsd-based-operating-systems/ The 7 Best BSD-Based Operating Systems of All Time]


== Darwin, MacOS, OpenSource? ==
== Darwin, MacOS, OpenSource? ==
Line 55: Line 56:


But I found the problem should be resolved in macOS. That is, running 'sudo chmod 644' on the file from an Mac computer.
But I found the problem should be resolved in macOS. That is, running 'sudo chmod 644' on the file from an Mac computer.
=== How to partition ===
* [https://osxdaily.com/2020/06/29/how-create-new-partition-mac/ How to Create a New Partition in macOS]
* [https://www.makeuseof.com/how-to-create-delete-partition-mac/ How to Create and Delete Partitions on Your Mac] 2022
=== Disk space ===
Three ways to find out
# About this mac (eg 338GB available out of 499.96GB)
# Finder -> Macintosh HD -> Get Info (eg Available 338GB, used 159GB)
# '''df -hl''' command (the sum of the following example is 153GB) ["-l" show local file systems only]
#* used 10G on / -- [https://www.idownloadblog.com/2019/10/24/macos-catalina-hidden-volume/ Disk Utility], new in macOS Catalina 10.15
#* used 138G on /System/Volumes/Data -- [https://www.idownloadblog.com/2019/10/24/macos-catalina-hidden-volume/ Disk Utility], new in macOS Catalina 10.15
#* used 4G on /private/var/vm -- [https://discussions.apple.com/thread/7402978 virtual memory page/swap files]
#* used 502M on /Volumes/Recovery


== Beta version of macOS ==
== Beta version of macOS ==
[http://www.pcadvisor.co.uk/how-to/apple/how-get-new-version-of-macos-1013-3618301/ How to get the new version of macOS 10.13]
[http://www.pcadvisor.co.uk/how-to/apple/how-get-new-version-of-macos-1013-3618301/ How to get the new version of macOS 10.13]


== Preferences - Energy Saver ==
== Download macOS installers ==
* [https://discussions.apple.com/thread/251260849 download Catalina from App store]. It's about 4.5GB for [https://support.apple.com/kb/DL2052?viewlocale=en_US&locale=en_US macOS Catalina 10.15.7 Combo Update]
[https://osxdaily.com/2021/02/03/download-full-macos-installers-easy-mds/ How to Download Full MacOS Installers the Easy Way with MDS]
 
The download speed is good when I tried to download Big Sur 11.4. The file <Install_macOS_11.4-20F71.dmg> took 12.45GB.
 
[https://www.top-password.com/blog/convert-disk-image-between-dmg-and-iso-on-mac-os-x/ How to Convert Disk Image Between .DMG and .ISO Format on Mac OS X].
<pre>
hdiutil makehybrid -iso -joliet -o ~/Desktop/filename.iso ~/Desktop/filename.dmg
</pre>
 
== Preferences ==
 
=== Set all app windows to close when quitting apps ===
https://support.apple.com/guide/mac-help/quit-apps-mchl834d18c2/mac. I need this for the Preview app. But it does not work. The command line way 'defaults write com.apple.Preview ApplePersistenceIgnoreState -bool no' does not help either.
 
=== Single click to reveal desktop/hide all apps ===
[https://www.imore.com/mac/macos/macos-sonoma-click-to-reveal-desktop-turn-off How to turn off macOS Sonoma 'click to reveal desktop': switch off the most annoying change in Mac update history]
 
=== Stage manager ===
[https://support.apple.com/en-us/102355 Use Stage Manager to organize apps and windows on Mac]
 
=== Privacy: camera, microphone, share desktop in Webex ===
Camera location: Roughly 1/2 inch [https://discussions.apple.com/thread/251026849 to the right of the camera]. You cannot see it because it is covered with a tinted and transparent plate.  If you want to experiment and confirm then operate your computer in a bright area and note the screen brightness.
 
[https://support.apple.com/guide/mac-help/use-the-built-in-camera-mchlp2980/mac To test the built-in camera on Mac] we can use Photo Booth, FaceTime, ...
 
[https://discussions.apple.com/thread/250745054 Catalina / WebEx Cannot share Desktop or Apps] or [https://help.webex.com/en-us/73zvl3/Support-for-Cisco-Webex-Meetings-for-macOS-Catalina Support for Cisco Webex Meetings for macOS Catalina]. Check your Systems Preferences > Security & Privacy > Privacy settings. Click the lock to make changes - and enter your password. Check the box next to Cisco WebEx for all of the following:
* Camera
* Microphone
* <strike>Input Monitoring</strike>
* <strike>Full Disk Access</strike>
* Screen Recording
 
[https://help.webex.com/en-us/2hsk9i/Screen-Sharing-in-Cisco-Webex-Meetings-Virtual-Desktop-App Screen Sharing in Cisco Webex Meetings Virtual Desktop App]
 
[https://help.webex.com/en-us/5ddww5/Share-Content-in-Cisco-Webex-Meetings-and-Cisco-Webex-Events Share Content in Cisco Webex Meetings and Cisco Webex Events]
 
[https://help.webex.com/en-us/WBX64076/I-m-Hearing-an-Echo-of-My-Voice-in-the-Audio-Conference I'm Hearing an Echo of My Voice in the Audio Conference]
 
=== Energy Saver ===
* https://support.apple.com/en-us/HT201714
* https://support.apple.com/en-us/HT201714
* https://support.apple.com/en-us/HT202824
* https://support.apple.com/en-us/HT202824
Line 70: Line 125:
* [https://www.makeuseof.com/tag/11-mac-dashboard-widgets-youll-actually-use/ 9 Mac Dashboard Widgets You’ll Actually Use]
* [https://www.makeuseof.com/tag/11-mac-dashboard-widgets-youll-actually-use/ 9 Mac Dashboard Widgets You’ll Actually Use]
* [https://www.wikihow.com/Create-a-Sticky-Note-on-a-Mac%27s-Dashboard How to Create a Sticky Note on a Mac's Dashboard]
* [https://www.wikihow.com/Create-a-Sticky-Note-on-a-Mac%27s-Dashboard How to Create a Sticky Note on a Mac's Dashboard]
=== Finder window relocating to different Space Desktop ===
Right click on the Finder icon in the dock. Select "Options" then under "Assign to" select "This Desktop". See [https://www.reddit.com/r/MacOS/comments/ydclh4/finder_window_relocating_to_different_space/ this].
=== How to prevent Mac from changing the order of Desktops/Spaces ===
[https://apple.stackexchange.com/a/214349 How to prevent Mac from changing the order of Desktops/Spaces]
=== Universal Control, Sidecar ===
[https://www.howtogeek.com/792817/how-to-switch-from-universal-control-to-sidecar-on-a-mac-and-ipad/ How to Switch From Universal Control to Sidecar on a Mac and iPad]
== Second screen: Deskreen (cross platforms) ==
* [https://www.linuxuprising.com/2021/01/deskreen-makes-any-device-with-web.html Deskreen Makes Any Device With A Web Browser A Second Screen For Your Computer], [https://smile.amazon.com/Headless-Display-Emulator-Headless-1920x1080-Generation/dp/B06XT1Z9TF amazon]
* [https://www.reviewgeek.com/68635/the-free-deskreen-app-turns-your-old-tablet-into-a-wireless-monitor/ The Free Deskreen App Turns Your Old Tablet Into a Wireless Monitor]
* [https://youtu.be/6flkkBBglQ0 Deskreen - An Open Source, Self Hosted way to use a mobile device as a second monitor]. (video)


== Split screen ==
== Split screen ==
[https://www.makeuseof.com/features-to-easily-work-with-multiple-apps-mac/ 4 Features That Make It Easy to Work With Multiple Apps on a Mac]
https://support.apple.com/en-us/HT204948
https://support.apple.com/en-us/HT204948
# Hold down the full-screen button  in the upper-left corner of a window.  
# Hold down the full-screen button  in the upper-left corner of a window.  
Line 83: Line 154:


https://www.cnet.com/news/macbook-pro-blank-screen-on-wake-from-sleep-2-fixes/
https://www.cnet.com/news/macbook-pro-blank-screen-on-wake-from-sleep-2-fixes/
== Sleep wake failure ==
Catalina 10.15.3. Screen is black.


== Booting problem ==
== Booting problem ==
[https://www.makeuseof.com/tag/repair-mac-disk-safe-mode-fsck/ How to Repair Your Mac’s Disk Using Safe Mode, fsck, and More]
[https://www.makeuseof.com/tag/repair-mac-disk-safe-mode-fsck/ How to Repair Your Mac’s Disk Using Safe Mode, fsck, and More]


= OS X File System =
== Shut down randomly ==
* https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
[https://www.makeuseof.com/tag/mac-shutting-randomly-heres-can/ Your Mac Keeps Shutting Down Randomly? Here's What You Can Do]
* [http://osxdaily.com/2007/03/30/mac-os-x-directory-structure-explained/ Mac OS X Directory Structure explained]
* [http://apple.stackexchange.com/questions/79514/directory-structure-between-mac-osx-and-linux Directory structure between mac osx and linux]


== Home directory ==
== Boot keys and backup ==
/Users/USERNAME
* While restarting, hold down the ⌥ Option key; see [https://www.wikihow.com/Boot-a-Mac-from-USB-Drive How to boot a Mac from USB drive]
* [https://www.makeuseof.com/tag/mac-boot-from-usb-drive/ How to Make Your Mac Boot From a USB Drive]
* Command (⌘)-R to start up from macOS Recovery; see
** [https://support.apple.com/mac-backup Back up your Mac]
** [https://support.apple.com/en-us/HT201250 Back up your Mac with Time Machine]
** [https://www.makeuseof.com/how-to-back-up-time-machine-to-internal-drive-mac/ How to Back Up Your Mac Without an External Drive Using Time Machine]
** [https://support.apple.com/en-us/HT203981 Restore your Mac from a backup]
* [https://www.howtogeek.com/280089/how-to-create-a-bootable-backup-of-your-entire-mac-on-an-external-drive/ How to Create a Bootable Backup of Your Entire Mac on an External Drive]
* [https://www.imore.com/how-restore-your-mac-backup How to restore your Mac from a backup] using Time Machine or other software
* [https://www.howtogeek.com/399058/how-to-make-a-bootable-clone-of-your-macs-hard-drive/ How to Make a Bootable Clone of Your Mac’s Hard Drive]
* [https://www.cloudwards.net/how-to-backup-a-mac-to-an-external-hard-drive/ How to Backup a Mac to an External Hard Drive in 2020]
* [https://www.lifewire.com/use-recovery-hd-volume-to-reinstall-os-x-2259971 Use the Recovery HD Volume to Reinstall or Troubleshoot OS X]
 
== WindowServer process takes a lot of memory ==
When no my own applications are running, macOS already took 6GB RAM 😕
 
MacOS 10.15.3, WindowServer uses 780MB.
 
[https://www.howtogeek.com/312755/what-is-the-process-windowserver-and-why-is-it-running-on-my-mac/ What Is the Process WindowServer, and Why Is It Running on My Mac?]
 
[https://www.makeuseof.com/lower-windowserver-cpu-usage/ How to Reduce WindowServer's CPU Usage on Mac]
 
== docker for mac memory usage in com.docker.hyperkit ==
[https://stackoverflow.com/questions/58308169/docker-for-mac-memory-usage-in-com-docker-hyperkit docker for mac memory usage in com.docker.hyperkit]. the '''Real Memory''' usage is much lower than what you see in the "Memory" column in Activity Monitor.
 
== Emoji ==
* Click Flag on the toolbar -> Show emoji and symbols
* Control + command + space bar
 
== Automator ==
* [https://support.apple.com/guide/automator/welcome/mac Automator User Guide]
* [https://github.com/juruen/rmapi/blob/master/docs/tutorial-print-macosx.md How to directly print to your ReMarkable on Mac]
 
== Reset password ==
[https://osxdaily.com/2021/05/11/how-reset-macos-password-terminal/ How to Reset MacOS Password with Terminal]
 
== Relocated Items folder on your Mac after upgrading macOS ==
[https://support.apple.com/guide/mac-help/a-relocated-items-folder-mac-upgrading-macos-mchl8ae423a3/mac If you see a Relocated Items folder on your Mac after upgrading macOS]
 
'''/Users/Shared/Relocated Items/'''
 
= OS X File System =
* https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
* [http://osxdaily.com/2007/03/30/mac-os-x-directory-structure-explained/ Mac OS X Directory Structure explained]
* [http://apple.stackexchange.com/questions/79514/directory-structure-between-mac-osx-and-linux Directory structure between mac osx and linux]
 
== Home directory ==
/Users/USERNAME


The following is the default directories under $HOME.
The following is the default directories under $HOME.
Line 131: Line 250:


== Library folder & show hidden files/folders ==
== Library folder & show hidden files/folders ==
[https://nektony.com/blog/how-to-get-to-library-on-mac What is the Library folder on Mac?]
[http://www.macworld.co.uk/how-to/mac-software/how-show-hidden-files-library-folder-mac-3520878/ How to show hidden files and folders including ~/Library on a Mac]
[http://www.macworld.co.uk/how-to/mac-software/how-show-hidden-files-library-folder-mac-3520878/ How to show hidden files and folders including ~/Library on a Mac]


In MacOS Sierra, use CMD-Shift-. (dot).
In MacOS Sierra & Majove, use Shift + CMD + . (dot) to toggle.


Or follow [http://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/ Quickly Show/Hide Hidden Files on macOS Sierra, OS X El Capitan & Yosemite]
Or follow [http://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/ Quickly Show/Hide Hidden Files on macOS Sierra, OS X El Capitan & Yosemite]
Line 139: Line 260:
== 6 macOS Folders You Can Safely Delete to Save Space ==
== 6 macOS Folders You Can Safely Delete to Save Space ==
https://www.makeuseof.com/tag/macos-folders-delete-save-space/
https://www.makeuseof.com/tag/macos-folders-delete-save-space/
== 5 macOS Folders You Should Never Touch ==
[https://www.makeuseof.com/tag/mac-folders-never-touch/ 5 macOS Folders You Should Never Touch (And Why)]
== Tune Up Your Mac for Best Performance ==
[https://www.makeuseof.com/tag/quick-ways-to-tune-up-your-mac/ 10 Easy Ways to Tune Up Your Mac for Best Performance]
# Clear Some Free Space
# Check Activity Monitor
# Reduce Your Login Items
# Run A Scan For Malware
# Empty The Caches
# Run First Aid On Your Disk
# Disable System Animations
# Speed Up Your Browser
# Reindex Spotlight
# Update Your Apps
== Temp Folder ==
[http://osxdaily.com/2018/08/17/where-temp-folder-mac-access/ Where’s the Temp Folder on Mac OS? How to Find & Open the Mac Temporary Directory]
* echo $TMPDIR (/var/folders/XX/RANDOMCHARACTERS/T). Note: R's tempdir() will create a subfolder in OS's $TMPDIR.
* /tmp (which links to /private/tmp)
* ~/Library/Caches/TemporaryItems/ (not found on Mojave)


== /Volumes and Machintosh HD directory ==
== /Volumes and Machintosh HD directory ==
Line 153: Line 297:


== Format SD card as FAT ==
== Format SD card as FAT ==
Use [https://www.sdcard.org/downloads/formatter_4/ SD Memory Card Formatter] (Windows and mac only). See https://www.raspberrypi.org/documentation/installation/noobs.md.
Use [https://www.sdcard.org/downloads/formatter_4/ SD Memory Card Formatter] (Windows and mac only). See [https://www.raspberrypi.org/documentation/installation/noobs.md NOOBS].
 
[https://www.makeuseof.com/how-to-format-sd-card-mac/ How to Format an SD Card on Your Mac]
 
== rsync ==
The built-in rsync utility is too old (it does not support multiple files by using curly braces from remote server). Use ''brew install rsync'' to get a new one.
 
== Mac File System ==
[https://www.makeuseof.com/tag/mac-file-system-external-drive/ Which Mac File System Is Best for an External Drive?]
 
== Ext4: macFUSE ==
* https://github.com/osxfuse/osxfuse/wiki
* [https://www.maketecheasier.com/mount-access-ext4-partition-mac/ How to Mount and Access Ext4 Partition in Mac]
* [https://www.cyberciti.biz/faq/mac-os-x-read-ext3-ext4-external-usb-hard-disk-partition/ Mac OS X: Read Linux ext3 / ext4 External USB Hard Disk Partition]
* [https://osxdaily.com/2014/03/20/mount-ext-linux-file-system-mac/ How to Mount EXT4 Linux File Systems on a Mac with OS X Fuse]


== ExFat: Best drive/partition format to share data between Mac, Linux and OS X ==
== ExFat: Best drive/partition format to share data between Mac, Linux and OS X ==
Line 216: Line 374:
rsync -rltDv  --info=progress2 SRC DEST
rsync -rltDv  --info=progress2 SRC DEST
</syntaxhighlight>
</syntaxhighlight>
== APFS Volume ==
=== Add a volume ===
[https://www.makeuseof.com/how-to-add-volume-apfs-drive-mac/ What Is a Volume and How Do You Add One to the Drive in a Mac?]
=== Delete an APFS volume ===
[http://osxdaily.com/2019/08/22/how-delete-apfs-volume-mac/ How to Delete an APFS Volume from Mac]
=== Install MacOS Catalina Beta on APFS Volume to Dual Boot with Mojave ===
[http://osxdaily.com/2019/07/25/install-macos-catalina-apfs-volume-dual-boot-mojave/ How to Install MacOS Catalina Beta on APFS Volume to Dual Boot with Mojave]


== What is the “wheel” user in OS X? ==
== What is the “wheel” user in OS X? ==
Line 226: Line 394:
== How to Auto-Hide the Dock With No Delay ==
== How to Auto-Hide the Dock With No Delay ==
http://www.makeuseof.com/tag/auto-hide-dock-no-delay-mac/
http://www.makeuseof.com/tag/auto-hide-dock-no-delay-mac/
== Customize the Time and Date in the Mac Menu Bar ==
[https://www.howtogeek.com/700425/how-to-customize-the-time-and-date-in-mac-menu-bar/ How to Customize the Time and Date in the Mac Menu Bar]


== Hide username from menu bar ==
== Hide username from menu bar ==
https://apple.stackexchange.com/questions/57712/hide-username-from-menu-bar/57715. The other options are to show full name or icon only.
https://apple.stackexchange.com/questions/57712/hide-username-from-menu-bar/57715. The other options are to show full name or icon only.


== Move icons in the menubar ==
== Menu bar color in macOS 14 ==
[https://discussions.apple.com/thread/255158474 MacOS Sonoma Menu bar color]. Settings - Wallpaper - Colors.
 
== Move icons in the menu bar ==
Hold the CMD key and then click and drag the icon.
Hold the CMD key and then click and drag the icon.
== What Does a Green or Orange Dot in the Menu Bar Mean ==
[https://www.macrumors.com/how-to/menu-bar-dot-explanation/ macOS Monterey: What Does a Green or Orange Dot in the Menu Bar Mean?] Green color means an app is using the '''camera''', and orange color means the '''mic''' is used.


== Move icons in the Dock ==
== Move icons in the Dock ==
[https://discussions.apple.com/thread/3817000 drag and drop QUICKLY]. Another trick is to drag the icon out of the Dock and put it back somewhere in the Dock.
[https://discussions.apple.com/thread/3817000 drag and drop QUICKLY]. Another trick is to drag the icon out of the Dock and put it back somewhere in the Dock.
== Extract icons from Mac apps ==
[https://www.howtogeek.com/687389/how-to-extract-a-high-quality-icon-from-a-mac-app/ How to Extract a High Quality Icon From a Mac App]
== Move a window when the titlebar is not available ==
https://apple.stackexchange.com/a/231924 If you move the mouse to the right/left edge until you see the horizontal resize icon, then dragging vertically will allow you to move the window instead of resizing. Same goes for the bottom edge resize cursor + horizontal drag (Tested. It works.)
[https://apple.stackexchange.com/questions/71112/how-do-i-move-a-window-whose-title-bar-is-off-screen How do I move a window whose title bar is off-screen?]
In the case of P4merge's Preference, we just need to maximize the window to see the Cancel & OK buttons.


== Don't show recent applications in Dock in Mojave ==
== Don't show recent applications in Dock in Mojave ==
[https://www.tekrevue.com/tip/recent-applications-extra-icons-mojave-dock/ macOS Mojave: Turn Off Recent Applications to Remove Extra Dock Icons]
[https://www.tekrevue.com/tip/recent-applications-extra-icons-mojave-dock/ macOS Mojave: Turn Off Recent Applications to Remove Extra Dock Icons]
== Minimize windows into application icon ==
[https://www.techjunkie.com/mac-minimize-windows-dock/ macOS: Tips on Minimizing Windows into the Dock]
== Connecting to WiFi but no internet ==
* [https://appletoolbox.com/solved-macbook-connects-to-wi-fi-but-has-no-internet-connection/ Solved: MacBook connects to Wi-Fi but has no Internet connection*]. It gives many practical suggestions. Run Wireless Diagnostics on your MacBook: Hold option and click the Wi-Fi icon in your menu bar.
* [https://www.igeeksblog.com/macbook-connects-to-wifi-but-no-internet/ MacBook connects to Wi-Fi but has no Internet? 12 Fixes]
* [https://www.freecodecamp.org/news/how-to-flush-dns-on-mac-macos-clear-dns-cache/ How to Flush DNS on Mac – MacOS Clear DNS Cache]
My case:
* Forget and reconnect my wifi does not help.
* ping google.com not working but ping 1.1.1.1 works. Change DNS by Preferences - Network - Advanced - DNS by adding 1.1.1.1. Now Chrome works but Outlook or Webex is still not working?? Reboot. Everything is fine.


== How can I list my open network ports with netstat? ==
== How can I list my open network ports with netstat? ==
http://apple.stackexchange.com/questions/117644/how-can-i-list-my-open-network-ports-with-netstat
http://apple.stackexchange.com/questions/117644/how-can-i-list-my-open-network-ports-with-netstat
The 1st column shows the command/program name.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
sudo lsof -i -P | grep -i "listen"
sudo lsof -i -P | grep -i "listen"
nmap localhost
sudo lsof -P -i TCP -s TCP:LISTEN | grep XXXXX
</syntaxhighlight>
</syntaxhighlight>


Line 256: Line 460:
* [https://discussions.apple.com/thread/1812321?start=0&tstart=0 The Option "Allow User to Administer this Computer" option is Dimmed]
* [https://discussions.apple.com/thread/1812321?start=0&tstart=0 The Option "Allow User to Administer this Computer" option is Dimmed]
* [https://www.howtogeek.com/howto/35132/how-to-enable-the-root-user-in-mac-os-x/ How to Enable the Root User in macOS]
* [https://www.howtogeek.com/howto/35132/how-to-enable-the-root-user-in-mac-os-x/ How to Enable the Root User in macOS]
== SMB network file sharing ==
* [https://www.geekbitzone.com/posts/2023/macos/macos-network-shares/macos-mount-network-share-without-finder-window/ How to mount an SMB network share on macOS Ventura]
* [https://osxdaily.com/2023/02/13/mount-smb-share-command-line-mac/ How to Mount SMB Share from Command Line on Mac]
== .DS_Store file ==
[https://apple.stackexchange.com/a/69473 Consequences of deleting .DS_Store]. ''In most cases nothing will happen if you delete them, or at worst custom Finder view settings (icon size, position, background color, etc) will be lost.''


== @ sign in file attributes ==
== @ sign in file attributes ==
Line 292: Line 503:
== Uninstall a program ==
== Uninstall a program ==
[https://www.makeuseof.com/tag/how-to-uninstall-programs-on-mac/ How to Uninstall Programs on Mac]
[https://www.makeuseof.com/tag/how-to-uninstall-programs-on-mac/ How to Uninstall Programs on Mac]
== Case sensitive ==
In R, it seems to be case insensitive. load("file.Rdata") or load("file.RData") or load("file.rdata") works fine.
* [https://discussions.apple.com/thread/1082510 Mac OS not case sensitive?] For example, "cd" command is not case sensitive. But "ls" is case sensitive; e.g. "ls *.RData" is different from "ls *.Rdata".
* [https://www.quora.com/Why-does-OS-X-choose-to-have-a-case-insensitive-file-system-instead-of-a-case-sensitive-one Why does OS X choose to have a case-insensitive file system instead of a case-sensitive one?]


= Create a Bootable macOS Installer =
= Create a Bootable macOS Installer =
Line 305: Line 522:


Reboot, holding down the OPTION key and selecting the “Install OS X Sierra” drive upon boot..
Reboot, holding down the OPTION key and selecting the “Install OS X Sierra” drive upon boot..
== 免 USB 開機碟,重灌最原始乾淨的 Mac 系統 ==
https://www.kocpc.com.tw/archives/308906. 唯一缺點是必須處於有網路的環境下.


= How to Run macOS Mojave in Parallels For Free =
= How to Run macOS Mojave in Parallels For Free =
Line 327: Line 547:
== Where is the terminal ==
== Where is the terminal ==
Macintosh HD/Applications/Utilities/Terminal.
Macintosh HD/Applications/Utilities/Terminal.
== Message of the Day ==
[https://osxdaily.com/2007/01/30/change-the-mac-os-x-terminals-message-of-the-day/ Change the Terminal Message of the Day in Mac OS X]. In my case, I just did mv /etc/motd /etc/motd.bak and I will not receive the annoying message.


== Mouse pointer ==
== Mouse pointer ==
Line 339: Line 562:
* http://osxdaily.com/2012/03/27/making-sense-of-mac-keyboard-symbols/
* http://osxdaily.com/2012/03/27/making-sense-of-mac-keyboard-symbols/
* http://tedwise.com/2009/04/28/what-do-those-weird-mac-symbols-mean/
* http://tedwise.com/2009/04/28/what-do-those-weird-mac-symbols-mean/
=== Alt key ===
[https://www.makeuseof.com/alt-key-on-mac What Is the Alt Key on Mac? A Complete Guide]


== Keyboard shortcuts ==
== Keyboard shortcuts ==
[https://www.makeuseof.com/tag/mac-terminal-commands-cheat-sheet/ The Mac Terminal Commands Cheat Sheet]
[https://www.makeuseof.com/tag/mac-terminal-commands-cheat-sheet/ The Mac Terminal Commands Cheat Sheet]


* Ctrl + a OR Cmd + left arrow = going to the beginning of the line
* going to the beginning of the line
* Ctrl + e OR Cmd + right arrow = going to the end of the line
** Cmd + left arrow
* Fn + Down arrow = page down
** fn + left arrow
* Fn + Up arrow = page up
** Ctrl + a (may conflict with the Prefix key I use for '''tmux''')
* going to the end of the line
** Cmd + right arrow
** fn + right arrow
** Ctrl + e (may conflict with the Prefix key I use for '''tmux''')
* fn + Down arrow = page down
* fn + Up arrow = page up
 
== fn/global key ==
* [https://lifehacker.com/this-key-on-your-mac-is-full-of-hidden-shortcuts-1850941307 This Key on Your Mac Is Full of Hidden Shortcuts]
* [https://support.apple.com/guide/mac-help/use-keyboard-function-keys-mchlp2596/mac Use keyboard function keys on Mac]
* [https://osxdaily.com/2023/12/26/how-to-reverse-function-keys-macos-system-settings/ How to Reverse Function Keys (F1, F2, etc) on MacOS Sonoma]
 
== Shell ==
=== Check the current shell and the default shell ===
<syntaxhighlight lang='bash'>
echo $0      # current shell


== Rename terminal tabs ==
echo $SHELL  # default shell
Click the “Shell” menu and select “Edit Title” to bring up the Terminal Inspector window
</syntaxhighlight>
On my 10.14.X, it returns /bin/sh. On 10.15.X, the default will be zsh; see [https://www.theverge.com/2019/6/4/18651872/apple-macos-catalina-zsh-bash-shell-replacement-features Apple replaces bash with zsh as the default shell in macOS Catalina].


== Terminal replacement ==
=== Change the default shell ===
* [https://www.iterm2.com/ iTerm2]. GPL2 license. Source code is in [https://github.com/gnachman/iTerm2 github].
http://osxdaily.com/2012/03/21/change-shell-mac-os-x/. Open 'Terminal' and click CMD + ",". Click the tab "Shell". On Startup, check "Run command" and type, for example, /bin/bash. Uncheck "Run inside shell". Quit terminal and open it again. It will go straight to the bash shell.
** (Update 5/14/2018) Copy from RStudio to iTerm2 R console may mess up. Don't find a solution yet.
** [https://apple.stackexchange.com/questions/76665/iterm2-save-window-tabs-on-exit Save window/tabs on exit?]. Works.
** The HOME/END keys work when I work in a virtual machine. To change font size, go to Preferences -> Profile -> Text -> Font or just use the keyboard shortcut Command + +/-.  
** Copy won't include the background color.
** We can change the cursor color from grey to anything (Preferences -> Profile -> Colors -> Cursor Colors).
** It can display image on its terminal using their own utility [https://iterm2.com/documentation-images.html imgcat]. After downloading it, chmod +x and then move it to /usr/local/bin directory.
** [https://www.bleepingcomputer.com/news/security/iterm2-leaks-everything-you-hover-in-your-terminal-via-dns-requests/ iTerm2 Leaks Everything You Hover in Your Terminal via DNS Requests] (9/20/2017)
* [https://www.macterm.net/ MacTerm]


== exit does not close a terminal/tab ==
Note that after the change, iTerm app will also have the new default shell after it has restarted.
You can change the setting by Preferences -> Profiles -> Shell. See https://superuser.com/questions/158375/how-do-i-close-the-terminal-in-osx-from-the-command-line.


== Mac Terminal’s Hidden Task Manager to See Background Processes ==
[https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/ How to Change the Default Shell to Bash on macOS Catalina]
https://www.howtogeek.com/309273/how-to-use-the-mac-terminals-hidden-task-manager-to-see-background-processes/


== terminal fun ==
=== Change default shell to bash on Macos Catalina ===
* [http://www.howtogeek.com/291940/the-best-just-for-fun-tricks-hidden-in-macos-terminal/ The Best “Just For Fun” Tricks Hidden in macOS’ Terminal]:
* [https://www.cyberciti.biz/faq/change-default-shell-to-bash-on-macos-catalina/ Change default shell to bash on Macos Catalina]
** Make Your Mac Say Anything Out Loud,
* [https://www.dyclassroom.com/howto-mac/how-to-change-default-shell-to-bash-on-macos-catalina How to change default shell to bash on macOS Catalina]
** Play Simple Games Like Tetris, Pong, and Snake,
* [https://support.apple.com/en-us/HT208050 Use zsh as the default shell on your Mac]
** caffeinate will prevent your Mac from falling asleep.
 
=== Oh My Zsh ===
[https://osxdaily.com/2021/11/28/how-uninstall-oh-my-zsh/ How to Uninstall Oh My Zsh on Mac]


== Recording the terminal ==
=== Changing Your Shell Temporarily ===
[https://asciinema.org/ asciinema]
[https://www.peachpit.com/articles/article.aspx?p=659655&seqNum=4 Changing Your Shell Temporarily]


= Keyboard shortcuts =
=== Bash vs Zsh ===
[http://www.lifehack.org/561663/wen-shan-how-not-using-keyboard-shortcut-make-you-lose-64-hours-every-year How Not Using Keyboard Shortcuts Makes You Lose 64 Hours Every Year]
* [https://medium.com/macoclock/shell-bash-zsh-macos-catalina-145f378a8381 Bash? Zsh? Which Shell to use in macOS Catalina]. It's the license consideration.
* [https://sunlightmedia.org/bash-vs-zsh/ Bash vs Zsh: A comparison of two command line shells] (2019 Update)


== Keyboard mappings using a PC keyboard on a Macintosh ==
== Rename terminal tabs ==
Mac keyboard: Ctrl -> Option/Alt -> Cmd.  Windows keyboard: Ctrl -> Windows -> Alt.
Click the “Shell” menu and select “Edit Title” to bring up the Terminal Inspector window


[[File:Mac-keyboard.jpg|200px]]  [[File:Windows-keyboard.jpg|250px]]
== Terminal replacement: iTerm2 ==
[https://www.iterm2.com/ iTerm2]. GPL2 license. Source code is in [https://github.com/gnachman/iTerm2 github].


* https://support.microsoft.com/en-us/help/970299/keyboard-mappings-using-a-pc-keyboard-on-a-macintosh
* (Update 5/14/2018) Copy from RStudio to iTerm2 R console may mess up. Don't find a solution yet.
* https://9to5mac.com/2016/03/17/how-to-remap-windows-keyboard-buttons-match-mac-layout/.
* [https://apple.stackexchange.com/questions/76665/iterm2-save-window-tabs-on-exit Save window/tabs on exit?]. Works.
** Apple internal keyboard -> USB keyboard
* The HOME/END keys work when I work in a virtual machine. To change font size, go to Preferences -> Profile -> Text -> Font or just use the keyboard shortcut Command + +/-.
** 'Option' -> 'Command'
* Copy won't include the background color.
** 'Command' -> 'Option'.
* We can change the cursor color from grey to anything (Preferences -> Profile -> Colors -> Cursor Colors).
* It can display image on its terminal using their own utility [https://iterm2.com/documentation-images.html imgcat]. After downloading it, chmod +x and then move it to /usr/local/bin directory.
* [https://www.bleepingcomputer.com/news/security/iterm2-leaks-everything-you-hover-in-your-terminal-via-dns-requests/ iTerm2 Leaks Everything You Hover in Your Terminal via DNS Requests] (9/20/2017)


== Lock screen ==
[https://lucasfcosta.com/2019/02/10/terminal-guide-2019.html How I'm still not using GUIs in 2019: A guide to the terminal] by Lucas F. Costa
Shift + control + power


== Cut and paste files ==
=== Keyboard shortcuts ===
http://osxdaily.com/2011/07/29/cut-and-paste-mac-os-x-lion/
* CMD + [ or ]: [https://stackoverflow.com/a/42383290 switch panes]


# Cmd + C
=== Difference between Login Shell and Non-Login Shell? ===
# Cmd + Opt + V
https://unix.stackexchange.com/a/46856


== Minimize all windows ==
=== Shell integration ===
* Method 1: Cmd + F3 (min apps go to the RHS)
* [https://iterm2.com/documentation-shell-integration.html Shell Integration]
* Method 2: Opt + Cmd + H + M
* [https://www.alexkras.com/remove-shell-integration-from-iterm2/ How to Remove Shell Integration From iterm2]


== Finder ==
From my testing, right click menu's "Download with scp" has been greyed out for some unknown reason.
Command + [: move back to the previous folder


See [http://www.dummies.com/computers/macs/mac-operating-systems/mac-os-x-finder-keyboard-shortcuts-3/ more].
But it can remember directories from open tabs when I quit and restart 'iTerm2'.


== Navigation in a browser or document ==
=== Change the title to the current directory ===
* Command + up = go to the top of the document
[https://apple.stackexchange.com/a/90737 For iTerm2, how do I make the working directory appear in the window title?]. The first example below will show the current directory on the title and the 2nd example will show the full path.
* Command + down = go to the end of the document
<syntaxhighlight lang='bash'>
* Command + f = search
echo -n -e "\033]0;${PWD##*/}\007"
* Fn + Down arrow = page down (or Spacebar in a web browser)
* Fn + Up arrow = page up (or Shift + Spacebar in a web browser)
* Fn + Left arrow = Home
* Fn + Right arrow = End
* Ctrl + TAB = switch tabs in browser


== Text navigation and selection ==
echo -ne "\033]0;$PWD\007"
[http://osxdaily.com/2012/02/23/keyboard-shortcuts-to-navigate-select-text-mac-os-x/ 12 Keyboard Shortcuts for Navigating & Selecting Text in Mac OS X]
</syntaxhighlight>
This will work one time. If we switch to another directory, we need to run the command again. Besides, it keeps showing the characters "-ne" after each command.


* Select text to beginning of a line – Shift+Command+Left Arrow
The follow method can change the title dynamically based on the current directory. The problem is if the prompt already contains the current directory why do we worry about the window's title.
* Select text to end of a line – Shift+Command+Right Arrow
<syntaxhighlight lang='bash'>
* Select text to beginning of current word – Shift+Option+Right Arrow
export PROMPT_COMMAND='echo "\033]0;${PWD##*/}\007"'
* Select text to end of current word – Shift+Option+Right Arrow
</syntaxhighlight>
* Select text to beginning of all text – Shift+Command+Up Arrow
* Select text to end of all text – Shift+Command+Down Arrow


== Switch input sources ==
=== PS1 ===
Go to System Preferences -> Keyboard -> Shortcuts -> '''Input Sources'''. Check 'Select the previous input source ^Space'. Use '''Ctrl + Space''' to switch.
If I give '''PS1="\[\w$ "'''
 
it will change my prompt from
== Compare to Windows/Linux ==
<pre>
* Use Command + q to close an application instead of "Alt+F4" on Windows/Linux.
NCI-12345678-ML:bdge USERNAME$
* System Activity tool:
</pre>
** Windows: Task Manager
to
** Linux: System Monitor
<pre>
** Mac: Activity Monitor
~/github/bdge$
</pre>
where the new one is probably better. We can replace '''\w''' with '''\W''' to get the directory basename instead of the full path.
 
The default '''PS1='\h:\W \u\$ '''' is defined in '''/etc/bashrc'''.
 
My El Capitan, I need to create a new file '''~/.profile''' (not in ~/.bash_profile) and put the command there.
<pre>
export PS1="\w (\!)\$ "
</pre>
 
The following choice will not show the hostname nor the current directory name. However the current iTerm2 (version 3.3.0) can show the current directory in the status bar. Preferences > Profiles > Session > Configure status bar (at the bottom of the GUI).
<syntaxhighlight lang="bash" inline>export PS1='$ '</syntaxhighlight>


== [https://superuser.com/questions/299241/in-mac-os-what-is-the-keyboard-shortcut-to-switch-between-windows-of-the-same-a Switch between windows of the same application] ==
See
Cmd + ` (backtick)
* [https://opensource.com/article/17/7/bash-prompt-tips-and-tricks Bash prompt tips and tricks]
* https://www.askdavetaylor.com/how_to_set_linux_mac_terminal_shell_ps1_prompt/
* [https://superuser.com/questions/147043/where-to-find-the-bashrc-file-on-mac-os-x-snow-leopard-and-lion Where to find the .bashrc file on Mac OS X]


= Hardware =
=== Color ===
# [https://support.apple.com/kb/SP719?locale=en_US  MacBook Pro (Retina, 15-inch, Mid 2015) - Technical Specifications] 2015 Macbook Pro model A1398, 15.4 inch.
By default "ls" 1) does not distinguish the colors for files and folders, 2) "ls -G" will shows a very dark blue color for folders. The remedy is [https://apple.stackexchange.com/a/397306 Changing color of folders, files, execs on iTerm2]
# MacBook Pro 15 inch, 2018 [https://support.apple.com/kb/SP776?viewlocale=en_US&locale=en_US Technical Spec]. 2.6GHz 6 cores i7.  
* add '''alias ls="ls -G" ''' to '''.zshrc'''
* modify the iTerm2 settings - Profiles - Color. I change the "Normal" blue color in ANSI Colors to "0095ff".


== 9 Essential Details You Must Know About Your Mac ==
=== Meta key and nano ===
https://www.makeuseof.com/tag/essential-mac-details/
https://stackoverflow.com/a/197092 Go to Preferences -> Profiles -> Keys and choose Left option Key acts as: +Esc. This allows me to use 'Option + n' to toggle line numbering.


== Display resolution ==
=== Infinite scroll back ===
2880x1800 on my 15-Inch Retina Display MacBook Pro. According to the [https://en.wikipedia.org/wiki/Retina_Display Retina Display] page on Wikipedia, its [https://en.wikipedia.org/wiki/Pixel_density PPI (pixels per inch)] is 220. To achieve the same PPI on 21.5 inch display, it has to be 4K and the display has to be 5K if it is 27 inch display.
Preferences -> Profiles -> Terminal -> check the option of "Unlimited scroll back"


Unfortunately Virtualbox (5.1.14) can only give 1440x900 (tested on Ubuntu & Windows). See a workout http://tusharm.com/articles/win7-on-retina-display-with-virtual-box/.
=== iTerm2 + tmux ===
Remember to change the preference in order to use mouse/touchpad for copy/paste. See [[Linux#tmux.2A|Linux > tmux]].


== External monitor ==
=== iTerm2 + .bashrc + .profile ===
On Dell U2718Q 27-inch 4K monitor, we can get a larger font size for every app by changing the scaling through System Preferences > Display > Resolution > Scaled. The choices are
[https://superuser.com/a/320067 .bashrc not sourced in iTerm + Mac OS X]. Create/edit the file ".profile" and put "source ~/.bashrc". Quit and open iTerm2.  
* 1920 x 1080
* 2560 x 1440 (more comfortable)
* 3008 x 1692
* 3360 x 1890
* 3840 x 2160


On the original macbook pro, the choices are
The same trick can be used for ".zshrc" file. By default there is no ".bashrc" nor ".zshrc" file.
* 1024 x 640
* 1280 x 800
* 1440 x 900 (more comfortable)
* 1680 x 1050
* 1920 x 1200


== Touchpad ==
This is useful if I want to have [https://www.tecmint.com/view-colored-man-pages-in-linux/ colored man page].
Need to press a little bit (instead of touch) for the left-click effect. If we want to use 'tap' for the click (like other OS), go to the System Preferences to change it.


The right click is called '''secondary click''' in OS X. We can enable it by going to System Preferences/Touchpad/Secondary click. Then tapping with two fingers would work.  See [http://osxdaily.com/2012/01/28/change-or-disable-the-secondary-click-in-mac-os-x/ Change or Disable the Secondary Click in Mac OS X].
=== Customize the zsh Prompt in the macOS Terminal ===
* [https://www.makeuseof.com/customize-zsh-prompt-macos-terminal/ How to Customize the zsh Prompt in the macOS Terminal]. However, it (''PROMPT'' method) will change the color of all texts not just the prompt.
* [https://stackoverflow.com/a/68797795 Ventura] with explanation (''PS1'' works fine).


Other handy gestures:
My '''.zshrc'''
* Scroll: two fingers move up/down. The direction is like moving a paper; i.e. scrolling up will gradually show the next part of the content.
<pre>
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'
alias ls="ls -G"
alias grep="grep --color"
alias sshnokey='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
alias scp="scp -p"
alias rsync='rsync --exclude=".*"  --exclude="~*"'
# PROMPT='%F{cyan}%n%f:~$ '  # username
# PROMPT='%F{cyan}%d$ '      # current full directory
# PROMPT='%F{cyan}%1~$ '      # current directory (not full)
# main problem with PROMPT is it will affect the color of ALL text
# PS1="%B%F{034}%~$%f%b "      # green prompt
PS1="%B%F{yellow}%~$%f%b "      # or red, magenta
PATH=$PATH:~/Library/Python/3.9/bin  # mainly for 'jupyter-lab'
</pre>


* Zoom in/out: pinch with two fingers.
== exit does not close a terminal/tab ==
You can change the setting by Preferences -> Profiles -> Shell. See https://superuser.com/questions/158375/how-do-i-close-the-terminal-in-osx-from-the-command-line.


* Smart zoom: double-tap with two fingers.
== Mac Terminal’s Hidden Task Manager to See Background Processes ==
https://www.howtogeek.com/309273/how-to-use-the-mac-terminals-hidden-task-manager-to-see-background-processes/


* [https://youtu.be/jf2JsstwAA0 Drag and drop] method 1: Use the normal three finger drag, leave two fingers on the trackpad while doing a flicking motion with the third finger (eg thumb). The more momentum you add to your motion, the further it drags.
== terminal fun ==
* [http://apple.stackexchange.com/questions/42429/how-to-properly-use-drag-and-drop-with-macbook-pro-on-os-x-10-7 Drag and drop] method 2:
* [http://www.howtogeek.com/291940/the-best-just-for-fun-tricks-hidden-in-macos-terminal/ The Best “Just For Fun” Tricks Hidden in macOS’ Terminal]:  
*# highlight the app first
** Make Your Mac Say Anything Out Loud,
*# '''lightly''' click the app (you should only feel one click. Do not use too much force; if you do, you will hear two click sound and it will pop up a window to show the file information) with your thumb and then use your index to move the app to “Applications” directory.
** Play Simple Games Like Tetris, Pong, and Snake,
** caffeinate will prevent your Mac from falling asleep.


* Show desktop: Spread with thumb and three fingers
== Recording the terminal ==
* Mission control: Swipe up with three fingers
[https://asciinema.org/ asciinema]
* Swipe between full-screen apps: swipe left or right with three fingers
* Dictionary/Thesaurus: Tap with three fingers


== Touchbar ==
== paste text from Clipboard to terminal is not complete ==
[http://osxdaily.com/2017/02/22/screen-lock-macbook-pro-touch-bar/ How to Use Screen Lock on MacBook Pro with Touch Bar]. So I add 'Show Desktop' and 'Lock screen' to the control strip. The control strip becomes 'Show Desktop', 'Lock Screen', 'Volume', 'Mute'.
I have not found a solution yet:(


== CPU information ==
The clipboard service is called '''pboard'''. Search in Activity Monitor.  
<pre>
sysctl -n machdep.cpu.brand_string
</pre>
My macbook Pro 2015 shows i7-4980HQ (see [https://browser.geekbench.com/processor-benchmarks GeekBench 4 score]) CPU @ 2.80GHz. Quad cores. Eight threads. Base Frequency 2.8GHz. Max Turbo Frequency 4.0GHz. Bus Speed: 5 GT/s DMI2.


== CPU temperature and alias ==
The text in the clipboard can be found by using Finder -> Edit -> Show Clipboard.
* https://apple.stackexchange.com/questions/54329/can-i-get-the-cpu-temperature-and-fan-speed-from-the-command-line-in-os-x. The ''istats'' works for me. 49.63°C on 2016 macbook pro, 41°C (52°C when connected to a 27-inch external monitor) on 2018 Macbook pro 2.6Ghz on idle.
<syntaxhighlight lang='bash'>
$ gem install iStats
$ istats


# We can make an alias by inserting a line in ~/.bash_profile
[https://setapp.com/how-to/how-to-view-clipboard-history-on-mac How to access clipboard (copy-paste) history on a Mac].
$ echo "alias temperature='istats'" >> ~/.bash_profile
$ source ~/.bash_profile
</syntaxhighlight>
* http://osxdaily.com/2016/03/13/monitor-system-stats-cpu-temp-fan-speed-in-mac-notification-center/
* https://beebom.com/how-check-cpu-temperature-mac/


== Fan and CPU temperature ==
[https://osxdaily.com/2018/02/02/fix-copy-paste-not-working-mac/ Copy Paste Not Working on Mac? Here’s How to Fix a Stuck Clipboard]. Type the following command exactly: '''killall pboard''' and press Return. This will terminate and relaunch the pboard process, which is the clipboard daemon for Mac OS.
* [https://www.crystalidea.com/macs-fan-control Macs Fan Control]
* [https://discussions.apple.com/thread/8536070 Fan problem on macbook pro]


When it asks for the admin password for its help tool, no need to enter it (choose 'Cancel') if we don't need to change fan control. See [https://www.crystalidea.com/macs-fan-control/faq FAQ].
iTerm2 > [https://iterm2.com/3.1/documentation-preferences.html Preferences > General > Selection > Applications in terminal may access clipboard]?


After launching it, it will show an icon on the menubar. It can be configured to show the CPU temperature ('''CPU Proximity''' result is close to '''istats''' reported) and fan speed.
== Executable file/command ==
* [https://www.skptricks.com/2019/08/create-executable-command-file-in-mac-os.html Create an executable command file in MAC OS]
* [https://stackoverflow.com/a/52651033 Equivalent of .bat in mac os]
* [https://apple.stackexchange.com/a/25261 What is the difference between .command, .tool, and .sh file extensions?]
** .sh file is opened by Xcode by default
** .command and .tool files are owned by Terminal by default , so if you double-click on one of them, it will open and execute in Terminal


== RAM ==
= Keyboard shortcuts =
[https://www.howtogeek.com/348562/can-you-upgrade-the-ram-in-your-mac/ Can you upgrade the ram in your Mac]
* [http://www.lifehack.org/561663/wen-shan-how-not-using-keyboard-shortcut-make-you-lose-64-hours-every-year How Not Using Keyboard Shortcuts Makes You Lose 64 Hours Every Year]
* [https://www.makeuseof.com/tag/useful-mac-osx-shortcuts-pdf/ The Most Useful Mac Keyboard Shortcuts to Know]


== Power Adapter ==
== Keyboard mappings using a PC keyboard on a Macintosh ==
* 85W MagSafe 2 Power Adapter for MacBook Pro with Retina Display (MD506LL/A) $75
Mac keyboard: Ctrl -> Option/Alt -> Cmd.   Windows keyboard: Ctrl -> Windows -> Alt.
* 87W USB-C Power Adapter. Model  A1719. Output: 20.2v +4.3A, 9V+3A, 5.2V + 2.4A.
** [https://www.apple.com/shop/questions/product/MNF82LL/A/87w-usb-c-power-adapter What chargers can i use with macbook pro 2017]? ''Assuming that the 2017 is the same as the 2016, you can actually (slowly) charge your MacBook Pro 15" with any decent apple-coded 5V, 2.4A 12W charger (like an iPad charger) via a USB-A to USB-C cable.... The MBP 15" also works with a 15W (5V @ 3A) USB Type-C chargers, and many higher-powered USB Type-C chargers with USB-PD support. ''
** [https://community.cypress.com/docs/DOC-10692 Difference between USB Type-C and USB-PD (Power Delivery)]
** [http://blog.ravpower.com/2018/02/all-about-usb-power-delivery/ All about USB power delivery]


== Keyboard battery level ==
[[File:Mac-keyboard.jpg|200px]]  [[File:Windows-keyboard.jpg|250px]]
macOS 10.11.6 shows the battery level is 18%.


macOS 10.12.6 corrected the calibration problem. Now it is showing 58%.
* https://support.microsoft.com/en-us/help/970299/keyboard-mappings-using-a-pc-keyboard-on-a-macintosh
* https://9to5mac.com/2016/03/17/how-to-remap-windows-keyboard-buttons-match-mac-layout/.
** Apple internal keyboard -> USB keyboard
** 'Option' -> 'Command'
** 'Command' -> 'Option'.


== Battery ==
== Lock screen ==
=== Plug or unplug ===
Shift + control + power
[https://apple.stackexchange.com/questions/12271/should-i-disconnect-my-macbook-pros-power-cord-when-the-battery-is-fully-charge Should I disconnect my MacBook Pro's power cord when the battery is fully charged?]. Answer: No.


=== Battery diagnostic ===
== Cut and paste files ==
About this Mac -> Overview -> System report -> Power.
http://osxdaily.com/2011/07/29/cut-and-paste-mac-os-x-lion/


[https://support.apple.com/en-us/HT201585 Cycle count limits] for my macbook pro 15inch Mid 2015 (shown from About This Mac) is 1000.
# Cmd + C
# Cmd + Opt + V


* The current cycle count currently is  175 cycle count (10/20/2017). Full charge capacity (mAh) is 8421.
== External keyboard ==
* The current cycle count currently is 199 (Feb 7, 2017 -> Nov 29, 2017). Full charge capacity is 8076.
* The current cycle count is 263 (Mar 2, 2018). Full charge capacity is 8096.
* The current cycle count is 430 (Oct 10, 2018). Full charge capacity is 7554.
* The current cycle count is 437 (Oct 19, 2018). Full charge capacity is 7073 (80%).


The [https://chargeberry.com/ Chargeberry] app shows the factory capacity is 8755 mAh.


== Ambient light sensor ==
[https://medium.com/@elhayefrat/how-to-fix-the-home-and-end-buttons-for-an-external-keyboard-in-mac-4da773a0d3a2 How to Fix the Home and End Buttons for an External Keyboard in Mac]
http://osxdaily.com/2010/05/22/where-is-the-ambient-light-sensor-on-a-macbook-pro/


== Too hot: remove the cover, cleaning ==
== Minimize all windows ==
[https://www.howtogeek.com/358960/how-to-clean-dust-out-of-your-macbook/ How to Clean Dust Out of Your MacBook]
* Method 1: Cmd + F3 (min apps go to the RHS)
* Method 2: Opt + Cmd + H + M


== Complaints ==
== Finder ==
Macbook Pro 2015
Command + [: move back to the previous folder
* Even the lid is closed, the fan is turning loud (6000 RPM for both fans, something is running?) parentalcontrolsd uses 248% cpu and the CPU temperature 50+. Router showed the machine's wifi is still on. The battery is drained out fast when I open the lid: <span style="color: red">Hazard!!</span>
* After I open the lid, the screen can not be unlocked. I only see the mouse cursor.
* Wifi cannot automatically connect


== [https://www.apple.com/imac-pro/specs/ iMac Pro] ==
See [http://www.dummies.com/computers/macs/mac-operating-systems/mac-os-x-finder-keyboard-shortcuts-3/ dummies.com] or [https://www.webnots.com/finder-keyboard-shortcuts-for-mac/ www.webnots.com].
The new (2017) iMac Pro can be equipped with a 128 GB of memory and 4 TB SSD drive.


= Finder - file manager =
== Navigation in a browser or document ==
* https://en.wikipedia.org/wiki/Finder_(software)
* Command + up = go to the top of the document
 
* Command + down = go to the end of the document
== Change font size ==
* Command + f = search
[http://osxdaily.com/2016/02/25/change-text-font-size-finder-mac-os-x/ View -> Show View Options -> Text Size]
* Fn + Down arrow = page down (or Spacebar in a web browser)
* Fn + Up arrow = page up (or Shift + Spacebar in a web browser)
* Fn + Left arrow = Home
* Fn + Right arrow = End
* Ctrl + TAB = switch tabs in browser


== [http://osxdaily.com/2015/11/05/copy-file-path-name-text-mac-os-x-finder/ Copy file full path] ==
== Text navigation and selection ==
This is important since RStudio cannot drag and drop a file to insert the file path.
[http://osxdaily.com/2012/02/23/keyboard-shortcuts-to-navigate-select-text-mac-os-x/ 12 Keyboard Shortcuts for Navigating & Selecting Text in Mac OS X]


# Navigate to the file or folder you wish to copy the path for
* Select text to beginning of a line – Shift+Command+Left Arrow
# Right-click (or Control+Click, or a Two-Finger click on trackpads) on the file or folder in the Mac Finder
* Select text to end of a line – Shift+Command+Right Arrow
# While in the right-click menu, hold down the OPTION key to reveal the “Copy (item name) as Pathname” option, it replaces the standard Copy option
* Select text to beginning of current word – Shift+Option+Right Arrow
# Once selected, the file or folders path is now in the clipboard, ready to be pasted anywhere
* Select text to end of current word – Shift+Option+Right Arrow
* Select text to beginning of all text – Shift+Command+Up Arrow
* Select text to end of all text – Shift+Command+Down Arrow


Cf. On Ubuntu, it is much simple. Just click Ctrl+C.
== Switch input sources ==
Go to System Preferences -> Keyboard -> Shortcuts -> '''Input Sources'''. Check 'Select the previous input source ^Space'. Use '''Ctrl + Space''' to switch.


== Enter key does not open the file ==
== Compare to Windows/Linux ==
Use '''Command+Down''' instead of Enter key to open a file or go into a directory.
* Use Command + q to close an application instead of "Alt+F4" on Windows/Linux.
* System Activity tool:
** Windows: Task Manager
** Linux: System Monitor
** Mac: Activity Monitor


'''Enter''' key is only used to rename a file. See https://discussions.apple.com/thread/3140356?start=0&tstart=0.
== [https://superuser.com/questions/299241/in-mac-os-what-is-the-keyboard-shortcut-to-switch-between-windows-of-the-same-a Switch between windows of the same application] ==
Cmd + ` (backtick)


Use Command+Down will immediately uncompress a tar.gz file.
== Switch desktops ==
^ (control) + left/right arrow keys


== Go to a folder ==
== Switch two screens/monitors ==
Use Cmd+Shift+o to go to a specific location by entering its full path. Unfortunately this option is not available in other applications in general.
[https://apple.stackexchange.com/questions/268697/how-to-quickly-move-mouse-cursor-between-monitors How to quickly move mouse cursor between monitors?]


== Permanently mapping a network drive ==
= Hardware =
[http://osxdaily.com/2010/09/20/map-a-network-drive-on-a-mac/ Map a network drive to Mac OS X that re-mounts after system reboot]
* [https://support.apple.com/kb/SP719?locale=en_US  MacBook Pro (Retina, 15-inch, Mid 2015) - Technical Specifications] 2015 Macbook Pro model A1398, 15.4 inch.
* MacBook Pro 15 inch, 2018 [https://support.apple.com/kb/SP776?viewlocale=en_US&locale=en_US Technical Spec]. 2.6GHz 6 cores i7.
: <syntaxhighlight lang='bash'>
$ sysctl -n machdep.cpu.brand_string
Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
</syntaxhighlight>
* [https://support.apple.com/kb/SP854 2021 Macbook Pro 14 inch]. 8 core CPU, 200GB/s memory, 14.2 inch, 3024-by-1964, 500 nits.


=== Users & Groups ===
== 9 Essential Details You Must Know About Your Mac ==
In System Preferences -> Users & Groups. Click '''Login Items''' tab. You will see all item (e.g. NCIMacDriveScript) that will open automatically when I log in. The item location can be found by right clicking the item.
https://www.makeuseof.com/tag/essential-mac-details/


== Tag ==
== Where to Buy Refurbished MacBooks ==
[https://www.howtogeek.com/402989/how-to-tag-files-on-a-mac-iphone-or-ipad/ How To Tag Files on a Mac, iPhone, or iPad]
[https://www.makeuseof.com/tag/top-places-buy-refurbished-mac-laptops-mac/ Where to Buy Refurbished MacBooks: The 4 Best Sites]


== [http://mac.eltima.com/file-manager.html Commander One] ==
== Display resolution ==
Free dual pane file manager for Mac.
2880x1800 (2880/1800=1.6) on my 15-Inch Retina Display MacBook Pro. According to the [https://en.wikipedia.org/wiki/Retina_Display Retina Display] page on Wikipedia, its [https://en.wikipedia.org/wiki/Pixel_density PPI (pixels per inch)] is 220.
* To achieve the same PPI on 21.5 inch display, it has to be 4K and the display has to be 5K if it is 27 inch display.
* Comparison: [https://nanoreview.net/en/laptop/dell-latitude-5520?m=d.2 Dell Latitude 5520] 15.6 inches, 1080p, 141 ppi.
* iPad 5th, 9.7inch, 264 ppi (2048 x 1536; 1.33 ratio)
* [https://99designs.com/blog/tips/ppi-vs-dpi-whats-the-difference/ PPI vs. DPI: what’s the difference?]
* [https://www.lifewire.com/best-monitors-for-macbook-pro-4169493 Best Monitors for MacBook Pros]
* [https://forums.macrumors.com/threads/guide-fixing-external-monitor-scaling-and-fuzziness-issues-with-mbp-and-osx.2179968/ Fixing External Monitor Scaling macbook pro]


* [http://www.eltima.com/wiki/user-guides/commander.html User Guide]
I scale the resolution to 1440x900 (1440/900=1.6; 16:10) to get large font size. Other resolutions have the same ratio include 1280*800, 1680*1050, 1920*1200, and 2560*1600.
* The bookmark is called '[http://www.eltima.com/wiki/user-guides/commander/favorites.html Favorites]' in Commander One. Click the 'star' icon and a Windows' style of a right click menu will pop up. You can select 'Add to Favorites' to add the current directory to the favorites. This bookmarked location will be shown when you click the 'star' icon next time.
* The icon (multiple horizontal lines) next to the 'star' shows the recent locations. This is useful too!
* By default, Commander One will send anonymous usage statistics to Eltima. Go to Preferences -> General to uncheck this option.


== Find files ==
Unfortunately Virtualbox (5.1.14) can only give 1440x900 (tested on Ubuntu & Windows). See a workout http://tusharm.com/articles/win7-on-retina-display-with-virtual-box/.
[https://www.makeuseof.com/tag/spotlight-alternatives-mac-search/ The 5 Best Spotlight Alternatives for Searching Mac Files and More]


= Screenshots =
== Mini-LED ==
* Shift +Cmd + 4:  select a rectangle
* [https://www.digitaltrends.com/computing/best-mini-led-laptops/ The best mini-LED laptops you can buy in 2022]
* http://www.howtogeek.com/278615/the-best-screenshot-apps-for-macos/
* [https://screenrant.com/apple-macbook-pro-2021-mini-led-not-oled-why/ 2021 MacBook Pro: Why Apple Chose Mini-LED Instead Of OLED]
* [https://www.makeuseof.com/tag/change-mac-screenshot-save-location/ How to Change Where Mac Screenshots Are Saved]


== Terminal ==
== Lid Closed in Clamshell Mode ==
Use the '''[https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/screencapture.1.html screencapture]''' command.
[https://www.makeuseof.com/use-macbook-with-lid-closed/ How to Use Your MacBook With the Lid Closed in Clamshell Mode]
<syntaxhighlight lang='bash'>
screencapture test.jpg


screencapture -c    # send to the clipboard
== Second Monitor ==
[https://www.addictivetips.com/mac-os/set-the-primary-display-on-macos/ How to set the primary display on macOS].
* You will notice that one of the displays has a white bar at the top. This white bar indicates which display is the '''primary display''' on macOS.
* The '''Dock''' will jump to the display that you’ve just set as the primary display
* When you select a display in the Arrangement tab, a '''red border''' appears around the screen of the one you’ve selected. This is how you identify which display is which.


screencapture -T 10 timedshot.jpg # timer
=== External monitor ===
On Dell U2718Q 27-inch 4K monitor, we can get a larger font size for every app by changing the scaling through System Preferences > Display > Resolution > Scaled. The choices are
* 1920 x 1080
* 2560 x 1440 (more comfortable)
* 3008 x 1692
* 3360 x 1890
* 3840 x 2160


screencapture -w test.jpg
On the original macbook pro, the choices are
# OR
* 1024 x 640
screencapture -W
* 1280 x 800
* 1440 x 900 (more comfortable)
* 1680 x 1050
* 1920 x 1200


screencapture -h    # help
Another Dell 27 inch monitor. [https://www.dell.com/support/home/en-us/product-support/product/u2723qe-monitor/docs Dell U2723QE] 4k Monitor. It provides a PD USB-C port. [https://dl.dell.com/content/manual12109242-dell-u2723qe-monitor-user-s-guide.pdf?language=en-us Manual] .
</syntaxhighlight>
To view an image file, use the '''[https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/open.1.html open]''' command. See also [http://brettterpstra.com/2014/08/06/shell-tricks-the-os-x-open-command/ Shell tricks: the OS X open command].
<syntaxhighlight lang='bash'>
open test.jpg
</syntaxhighlight>


To view the metadata of an image file, use the '''mdls''' command such as ''mdls XXX.png''. See [https://www.macissues.com/2014/05/12/how-to-look-up-file-metadata-in-os-x/ How to look up file metadata in OS X]
[https://forums.hardwarezone.com.sg/threads/dell-monitors-s-vs-p-vs-u-series.5935144/ Dell Monitors - S vs P vs U series]. S is the entry level (mostly tn panel), P is the professional series (for people who do series work on Photoshop type of work). U is ultra, the highest range.


== Grab ==
=== Home HP 22cwa 1080p monitor ===
Grab is a utility. Finder -> Go -> Applications -> Utilities -> Grab.
Click on "Display Settings" at the bottom on the Display window.  


[https://appletoolbox.com/2013/01/how-to-use-mac-os-x-grab-utility-to-take-screenshots/ How To Use macOS & Mac OS X Grab Utility To Take Screenshots]
On the macbook pro (15inch 2018, 2880 x 1800, the ratio is '''16:10''', not 16:9. That's why the screen is taller), I choose it as 'Main display'. Resolution: Scaled. 1440 x 900 (fill the whole screen).


Take a Timed Screenshot With the '''Grab''' (built-in) Application. Open Grab, select Capture -> Selection/Window/Screen/Timed screen.
On the 1080p monitor, I choose as 'Extended display'. Resolution: Scaled. 1600 x 900 (fill the whole screen).


== [https://app.prntscr.com/en/index.html Lightshot] ==
=== Mirroring display/screen ===
Lightshot works like [[Linux#Shutter|Shutter]] in Ubuntu - easy to use and can sit on the taskbar.
* [https://support.apple.com/en-us/HT210380 Use your iPad as a second display for your Mac with Sidecar]
* [https://www.linuxuprising.com/2021/05/turn-your-tablet-or-phone-into-graphic.html Turn Your Tablet Or Phone Into A Graphic Tablet / Touch Screen For Your Desktop With Weylus]


Note: to view an image resolution in '''Finder''', right click an image and select '''Get Info''' -> More Info.
=== Duet ===
[https://apps.apple.com/us/app/duet-display/id935754064 Duet Display App]


Its icon is a feather.
== Touchpad ==
Need to press a little bit (instead of touch) for the left-click effect. If we want to use 'tap' for the click (like other OS), go to the System Preferences to change it.


Feather has an advantage that the screenshot does not need to be saved. It can be copied to a clipboard and then discarded.
The right click is called '''secondary click''' in OS X. We can enable it by going to System Preferences/Touchpad/Secondary click. Then tapping with two fingers would work.  See [http://osxdaily.com/2012/01/28/change-or-disable-the-secondary-click-in-mac-os-x/ Change or Disable the Secondary Click in Mac OS X].


= Screen cast/recorder =
Other handy gestures:
[https://www.screenrecordersoftwares.com/top-best-screen-recorder-for-mac/ Top Best Screen Recorder For Mac]
* Scroll: two fingers move up/down. The direction is like moving a paper; i.e. scrolling up will gradually show the next part of the content.


== Quicktime player ==
* Zoom in/out: pinch with two fingers.
We can record the screen (full screen or a selected region). The recorded file will be in a .mov format.


== recordit ==
* Smart zoom: double-tap with two fingers.
* http://recordit.co/. Free GIF screen recorder for Mac and Windows
* [https://www.mysocialagency.com/jump-bandwagon-make-twitter-gif/ How to Make Your Own GIFs to Use on Twitter]


== Screen cast o magic ==
* [https://youtu.be/jf2JsstwAA0 Drag and drop] method 1: Use the normal three finger drag, leave two fingers on the trackpad while doing a flicking motion with the third finger (eg thumb). The more momentum you add to your motion, the further it drags.
http://screencast-o-matic.com/
* [http://apple.stackexchange.com/questions/42429/how-to-properly-use-drag-and-drop-with-macbook-pro-on-os-x-10-7 Drag and drop] method 2:
*# highlight the app first
*# '''lightly''' click the app (you should only feel one click. Do not use too much force; if you do, you will hear two click sound and it will pop up a window to show the file information) with your thumb and then use your index to move the app to “Applications” directory.


= Application =
* Show desktop: Spread with thumb and three fingers
== How to Install Applications  ==
* Mission control: Swipe up with three fingers
* http://www.howtogeek.com/177619/how-to-install-applications-on-a-mac-everything-you-need-to-know/
* Swipe between full-screen apps: swipe left or right with three fingers
* [http://commandlinemac.blogspot.com/2008/12/installing-dmg-application-from-command.html Installing a .dmg and .pkg application from the command line]
* Dictionary/Thesaurus: Tap with three fingers


== Keyboard shortcut to launch an application ==
== Mouse ==
* F4 key - LaunchPad
[https://www.amazon.com/Logitech-Pebble-Wireless-Mouse-Bluetooth/dp/B07X4D3BR6 Logitech Pebble Wireless Mouse] M350. Silent. 18-months battery life.
* Command + Space - Spotlight search


== Messages when you launch an application ==
=== Scrolling direction for mouse ===
* Google Chrome
* [https://techwiser.com/set-different-scroll-direction-for-mouse-and-trackpad-on-macos How To Set Different Scroll Direction For Mouse And Trackpad on macOS?].
 
* [https://github.com/Caldis/Mos Mos] works fine on macOS 14.2 Sonoma. After installing the software (move it to the Application), open its Settings -> Privacy and Security -> Accessibility and Allow '''Mos''' to control my computer. Without the software, a PC mouse and trackpad have different scrolling directions. The default options are good and there is no need to change anything.
[[File:ChromeMac.png|250px]]
** Check the option "Launch on Login" option under the general setting.


* iTerm
== Touchbar/touch bar ==
* [http://osxdaily.com/2017/02/22/screen-lock-macbook-pro-touch-bar/ How to Use Screen Lock on MacBook Pro with Touch Bar]. So I add 'Show Desktop' and 'Lock screen' to the control strip. The control strip becomes 'Show Desktop', 'Lock Screen', 'Volume', 'Mute'.
* [https://www.tenorshare.com/os-x/fix-macbook-touch-bar-not-working.html Top 4 Methods to Fix MacBook Touch Bar Not Working]. Method 3: Refresh Touch Bar from Activity Monitor on MacBook Pro works for me.


[[File:Iterm open.png|250px]]
== GPU benchmark ==
[https://novabench.com Novabench] can benchmark CPU and GPU. The test is quick too. Note watching 4k Youtube videos does not trigger AMD gpu. It only uses a little of Intel Iris Pro gpu.


* SeqTools
* (Novabench ver 4.0.2) The '''AMD Radeon R9 M370X''' 2GB (not Intel Iris Pro Graphics) from 2015 macbook pro (2.8Ghz i7, 16GB DDR3) shows usage during the test (Activity monitor -> Window -> GPU History). The overall score is 1620. CPU score=913, RAM score=269, GPU score=323 (Metal 3D: 31 FPS, OpenCL: 842 GFLOPS), Disk score=115 (write speed: 405 MB/s, read speed: 1059 MB/s).


[[File:Seqtoos open1.png|250px]] [[File:Seqtoos open2.png|250px]] [[File:Seqtoos open3.png|250px]]
== CPU information ==
 
== Install pkg file from command line ==
http://apple.stackexchange.com/questions/15658/how-can-i-open-a-pkg-file-manually
<pre>
<pre>
sudo installer -pkg ~/Downloads/packagename.pkg -target ~/Applications/
sysctl -n machdep.cpu.brand_string
# OR
installer -pkg ~/Downloads/packagename.pkg -target ~/Applications/
</pre>
</pre>
My macbook Pro 2015 shows i7-4980HQ (see [https://browser.geekbench.com/processor-benchmarks GeekBench 4 score]) CPU @ 2.80GHz. Quad cores. Eight threads. Base Frequency 2.8GHz. Max Turbo Frequency 4.0GHz. Bus Speed: 5 GT/s DMI2.


== Close an application ==
== CPU temperature and alias ==
Clicking the red button does close/quit an application/a program. You need to use Command-Q.
* https://apple.stackexchange.com/questions/54329/can-i-get-the-cpu-temperature-and-fan-speed-from-the-command-line-in-os-x. The ''istats'' works for me. 49.63°C on 2016 macbook pro, 41°C (52°C when connected to a 27-inch external monitor) on 2018 Macbook pro 2.6Ghz on idle.
<syntaxhighlight lang='bash'>
$ gem install iStats
$ istats


[https://discussions.apple.com/thread/3826532?tstart=0 Another answer]: The red close button just closes the window. It is up to the application whether it quits or not - typically if the application uses documents or it has other windows that can be opened it will not quit.  Applications with a single window (System Preferences, for example), will usually quit when the window is closed, since there isn't anything else it does.
# We can make an alias by inserting a line in ~/.bash_profile
 
$ echo "alias temperature='istats'" >> ~/.bash_profile
== Delete/remove an application ==
$ source ~/.bash_profile
[https://freemacsoft.net/appcleaner/ AppCleaner]
</syntaxhighlight>
* http://osxdaily.com/2016/03/13/monitor-system-stats-cpu-temp-fan-speed-in-mac-notification-center/
* https://beebom.com/how-check-cpu-temperature-mac/
 
== Fan and CPU temperature ==
* [https://www.crystalidea.com/macs-fan-control Macs Fan Control]
* [http://osxdaily.com/2019/07/03/adjust-mac-fan-speed-macs-fan-control/ How to Adjust Mac Fan Speed Manually with Macs Fan Control]
* [https://discussions.apple.com/thread/8536070 Fan problem on macbook pro]


= Package formats =
When it asks for the admin password for its help tool, no need to enter it (choose 'Cancel') if we don't need to change fan control. See [https://www.crystalidea.com/macs-fan-control/faq FAQ].
== app ''directory'' ==
Example: App Store.app, Atom editor, [https://www.sourcetreeapp.com/ SourceTree]


http://apple.stackexchange.com/questions/112197/what-does-a-app-file-actually-do
After launching it, it will show an icon on the menubar. It can be configured to show the CPU temperature ('''CPU Proximity''' result is close to '''istats''' reported) and fan speed.


'''apps''' are "Package Bundles" is Apple jargon. These are actually Unix directories, in a special format. The actual Unix Executable File is in a subdirectory named MacOS, which you can see using the "Show Package Contents" menu in Finder.
== High CPU usage ==
[https://www.minitool.com/news/xagt-exe-high-cpu-usage.html How to Fix Xagt.exe High CPU Usage?] FireEye [https://www.fireeye.com/products/endpoint-security.html EndPoint Agent Security] software.


To deliver the program in an app format, we can zip the app folder. If we use Safari browser, it will automatically decompress the zip file so the app program will appear in the Downloads directory.
== RAM ==
[https://www.howtogeek.com/348562/can-you-upgrade-the-ram-in-your-mac/ Can you upgrade the ram in your Mac]


For example, in SourceTree, the download file is called 'SourceTree_X.Y.zip'. When we click the zip file, it will be automatically extracted. And when I click SourceTree.app, it will have a dialog to help user to move the program to the application folder.
== Power Adapter ==
* 85W MagSafe 2 Power Adapter for MacBook Pro with Retina Display (MD506LL/A) $75
* 87W USB-C Power Adapter. Model  A1719. Output: 20.2v +4.3A, 9V+3A, 5.2V + 2.4A.
** [https://www.apple.com/shop/questions/product/MNF82LL/A/87w-usb-c-power-adapter What chargers can i use with macbook pro 2017]? ''Assuming that the 2017 is the same as the 2016, you can actually (slowly) charge your MacBook Pro 15" with any decent apple-coded 5V, 2.4A 12W charger (like an iPad charger) via a USB-A to USB-C cable.... The MBP 15" also works with a 15W (5V @ 3A) USB Type-C chargers, and many higher-powered USB Type-C chargers with USB-PD support. ''
** [https://community.cypress.com/docs/DOC-10692 Difference between USB Type-C and USB-PD (Power Delivery)]
** [http://blog.ravpower.com/2018/02/all-about-usb-power-delivery/ All about USB power delivery]


[[File:Sourcetree.png|250px]]
== USB-C and Thunderbolt ==
* [https://www.macworld.com/article/3586187/how-to-tell-if-your-usb-c-cable-is-usb-only-or-supports-thunderbolt-3.html How to tell if your USB-C cable is USB only or supports Thunderbolt 3]
* [https://www.howtogeek.com/449991/thunderbolt-3-vs.-usb-c-whats-the-difference Thunderbolt 3 vs. USB-C: What’s the Difference?]


== [https://en.wikipedia.org/wiki/Installer_(macOS)#Installer_package pkg file] ==
== Keyboard ==
Example: [https://cran.rstudio.com/bin/macosx/ R-cran]
=== Terrible keyboard ===
[https://appleinsider.com/inside/macbook-pro/tips/how-to-file-a-claim-in-the-macbook-butterfly-keyboard-lawsuit How to file a claim in the MacBook butterfly keyboard lawsuit]


* [https://www.crystalidea.com/blog/extract-pkg-files-mac-and-windows Extract PKG files on Mac and Windows]
Latest Macbook pro's keyboard layout is terrible. Keys are too crowded and the arrow keys are way too tiny and unusable. The touchbar version of macbook is even worse. 👎
* [http://osxdaily.com/2016/08/31/open-kg-files-mac-what-installs-where-suspicious-package/ How to Open .pkg Files to View What Will Install on Mac with Suspicious Package]


PKG files are Mac OS X installation (setup) packages that contain installer scripts ('Scripts' file) and compressed installation files ('Payload' file) that are used to install Mac software applications onto a user's hard drive.
Some alternatives:
* [https://www.makeuseof.com/tag/apples-official-keyboard-best-choice-mac/ The 7 Best Alternatives to Apple’s Official Magic Keyboard]
* [https://www.amazon.com/Logitech-Advanced-Wireless-Illuminated-Keyboard/dp/B07S92QBCJ/ Logitech MX Keys Advanced Wireless Illuminated Keyboard]


On the case of R-x.y.z.pkg, it contains R framework, '''R.app''' GUI, Tcl/Tk X11 and TexInfo.
=== Adding a Period after the Double Space ===
* [https://www.frontendreference.com/disable-adding-period-with-double-space-ventura.html Disable Adding a Period after the Double Space on MacOS Ventura]
* [https://osxdaily.com/2023/04/04/how-to-disable-period-typing-after-double-space-on-macos-ventura/ How to Disable Period Typing After Double Space on MacOS Ventura]


To install a pkg file from terminal, see [http://apple.stackexchange.com/questions/72226/installing-pkg-with-terminal this] post
=== Magic Keyboard Home and End keys acts as Page Up and Page down ===
<syntaxhighlight lang='bash'>
[https://apple.stackexchange.com/a/440785. Home doesn't move to the beginning of the line in macOS; that's a Windows thing.
sudo installer -pkg R-3.3.3.pkg -target /
On Mac Home is 'scroll to the top', End is 'scroll to the bottom', the cursor doesn't move.
</syntaxhighlight>
 
Cmd/left or right arrow moves to the beginning & end of line.


=== pkgutil ===
=== Remap Keys Using a Third-Party Keyboard ===
* [http://infoheap.com/mac-pkgutil-tutorial/ mac pkgutil – quick start guide]
[https://www.makeuseof.com/tag/use-customize-third-party-keyboard-mac/ How to Use & Customize a Third-Party Keyboard on Your Mac]
* pkgutil is used to keep previous version of R


== [https://en.wikipedia.org/wiki/Apple_Disk_Image dmg (disk image) file] ==
=== Keyboard battery level ===
Example: Google chrome, JDK, FastQC, Sketchup, Commander One.
macOS 10.11.6 shows the battery level is 18%.


A DMG file is a disk image, which is sort of like an archive file. When you download one, you can double-click it to “mount” it (under '''Devices''' in the '''Finder'''), allowing you to extract the application from inside it.
macOS 10.12.6 corrected the calibration problem. Now it is showing 58%.


After the app is dragged to your Applications folder, you can run it normally — from the Finder, Launchpad, Spotlight, dock, or anything else.
=== Bluetooth keyboard (AA battery version) battery life ===
I got a little over 3 months of battery life.


We can mount or eject a dmg file by
=== Bluetooth connection ===
<syntaxhighlight lang='bash'>
It will ask to enter a few keys shown on the screen before connection.  
# mount
hdiutil mount fastqc_v0.11.5.dmg
# copy its content
mkdir -p ~/FastQC
cp -r /Volumes/FastQC/FastQC.app/Contents/MacOS/* ~/FastQC/
# eject
hdiutil eject /Volumes/FastQC/
</syntaxhighlight>


To create a dmg file (see [http://stackoverflow.com/questions/96882/how-do-i-create-a-nice-looking-dmg-for-mac-os-x-using-command-line-tools command line] or [http://apple.stackexchange.com/questions/48414/how-do-i-create-a-dmg-file-from-a-directory here] and [http://www.technorms.com/30882/create-dmg-files-in-mac-os-x GUI])
It is interesting the keyboard will show as "Full Name [E]'s Keyboard" on the macOS's menu bar.
<syntaxhighlight lang='bash'>
hdiutil create -volname WhatYouWantTheDiskToBeNamed \
    -srcfolder /path/to/the/folder/you/want/to/create \
    -ov -format UDZO name.dmg
</syntaxhighlight>


To convert a dmg file to iso
== Battery ==
<syntaxhighlight lang='bash'>
[https://www.howtogeek.com/764654/how-to-keep-your-macbook-battery-healthy-and-extend-its-life/ How to Keep Your MacBook Battery Healthy and Extend Its Life]
hdiutil convert imagefile.dmg -format UDTO -o imagefile.iso
mv imagefile.iso.cdr imagefile.iso
</syntaxhighlight>


To install a dmg file from terminal, see [http://stackoverflow.com/questions/22934083/install-dmg-package-on-mac-os-from-terminal this] or [http://apple.stackexchange.com/questions/73926/is-there-a-command-to-install-a-dmg this]
=== Charging on hold/Optimized Battery Charging ===
<syntaxhighlight lang='bash'>
[https://support.apple.com/en-us/HT212049 If battery charging is paused or on hold on your Mac]
MOUNTDIR=$(echo `hdiutil mount jdk-8u121-macosx-x64.dmg | tail -1 \
| awk '{$1=$2=""; print $0}'` | xargs -0 echo) \
&& sudo installer -pkg "${MOUNTDIR}/"*.pkg -target / \
&& sudo hdiutil detach "${MOUNTDIR}"
</syntaxhighlight>


Explanation: The first command (hdiutil mount jdk-8u121-macosx-x64.dmg) will output
=== Plug or unplug ===
<pre>
[https://apple.stackexchange.com/questions/12271/should-i-disconnect-my-macbook-pros-power-cord-when-the-battery-is-fully-charge Should I disconnect my MacBook Pro's power cord when the battery is fully charged?]. Answer: No.
expected  CRC32 $628D96B6
/dev/disk2          GUID_partition_scheme         
/dev/disk2s1        Apple_HFS                      /Volumes/JDK 8 Update 121
</pre>
We like to grab the string "/Volumes/JDK 8 Update 121". This can be achieved by getting the last line of the output and replace the first and 2nd fields with empties and then output the whole line.


= Package manage software =
=== Battery diagnostic ===
http://apple.stackexchange.com/questions/32724/what-are-pros-and-cons-for-macports-fink-and-homebrew & http://apple.stackexchange.com/questions/64690/macports-vs-fink-vs-homebrew
About this Mac -> Overview -> System report -> Power.  


== [https://www.macports.org/ MacPorts]==
[https://support.apple.com/en-us/HT201585 Cycle count limits] for my macbook pro 15inch Mid 2015 (shown from About This Mac) is 1000.
Different versions of Mac OS X has a different macport binary (in .pkg format).


[http://www.makeuseof.com/tag/macports-open-source-software-mac/ MacPorts Brings the Best Open Source Software to Your Mac]
* The current cycle count currently is  175 cycle count (10/20/2017). Full charge capacity (mAh) is 8421.
* The current cycle count currently is 199 (Feb 7, 2017 -> Nov 29, 2017). Full charge capacity is 8076.
* The current cycle count is 263 (Mar 2, 2018). Full charge capacity is 8096.
* The current cycle count is 430 (Oct 10, 2018). Full charge capacity is 7554.
* The current cycle count is 437 (Oct 19, 2018). Full charge capacity is 7073 (80%).


== [http://brew.sh/ Homebrew] ==
The [https://chargeberry.com/ Chargeberry] app shows the factory capacity is 8755 mAh.
<syntaxhighlight lang='bash'>
# Install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# It will ask around 11 times on your administrator password for a variety of questions.


# install some package
== Ambient light sensor ==
brew install wget
http://osxdaily.com/2010/05/22/where-is-the-ambient-light-sensor-on-a-macbook-pro/
brew install htop
brew install ruby # install a newer version of ruby & gem; overwrite the pre-installed one
brew install cvs
which htop        # /usr/local/bin/htop
# Update brew
brew update  # Not add sudo
# Uninstall homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
</syntaxhighlight>


'''brew tap''' command
== SSD ==
* https://stackoverflow.com/questions/34408147/what-does-brew-tap-mean
[https://www.macworld.com/article/3609512/how-to-m1-intel-mac-ssd-health-terminal-smartmontools.html How to check your Intel and M1 Mac’s SSD health using Terminal] and '''smartmontools'''.
* Used by [https://github.com/cjbassi/gotop gotop]


[https://stackoverflow.com/questions/7323261/uninstall-remove-a-homebrew-package-including-all-its-dependencies How to uninstall / remove a Homebrew package including all its dependencies]
== Too hot: remove the cover, cleaning ==
[https://www.howtogeek.com/358960/how-to-clean-dust-out-of-your-macbook/ How to Clean Dust Out of Your MacBook]


'''[https://caskroom.github.io/ Homebrew Cast]''' extends Homebrew and brings its elegance, simplicity, and speed to macOS applications and large binaries alike. [https://apple.stackexchange.com/questions/125468/what-is-the-difference-between-brew-and-brew-cask What is the difference between `brew` and `brew cask`?].
== Complaints ==
 
Macbook Pro 2015 & 2018
== [http://www.finkproject.org/ Fink] ==
* Even the lid is closed, the fan is turning loud (6000 RPM for both fans, something is running?) parentalcontrolsd uses 248% cpu and the CPU temperature 50+. Router showed the machine's wifi is still on. The battery is drained out fast when I open the lid: <span style="color: red">Hazard!!</span>
No binary installer for recent versions of OS X (good to me). You will need to install the proper Command Line Tools for Xcode for your system.  
* After I open the lid, the screen can not be unlocked. I only see the mouse cursor.
* Wifi cannot automatically connect
* Freeze (no response after clicking a program) after sleeping.
* Restart does not work. Force to push the power button to shutdown the machine.


== [http://rudix.org/ Rudix] ==
== Mac mini ==
<syntaxhighlight lang='bash'>
[https://www.makeuseof.com/reasons-mac-mini-is-the-best-entry-level-mac/ 5 Reasons the M2 Mac mini Is the Best Entry-Level Mac You Can Buy]
# install
curl -s https://raw.githubusercontent.com/rudix-mac/rpm/2016.12.13/rudix.py | sudo python - install rudix
# install some package
sudo rudix install wget
sudo rudix install python-pip
# remove a package
sudo rudix remove python-pip
# uninstall
sudo rudix -R
</syntaxhighlight>


= Extract files (Unzip) =
== [https://www.apple.com/imac-pro/specs/ iMac Pro] ==
[https://theunarchiver.com/ Unarchiver]. Mentioned by [https://www.raspberrypi.org/downloads/raspbian/ Raspbian].
The new (2017) iMac Pro can be equipped with a 128 GB of memory and 4 TB SSD drive.


= Image editor =
= Finder - file manager =
https://www.howtogeek.com/304677/the-best-free-photo-editors-for-macos/
* https://en.wikipedia.org/wiki/Finder_(software)


Note when I use the 'Preview' program, it will automatically save the changes without any warnings when I exit the program.
== Quick Look, Preview ==
* Highlight any file and press the space bar to view image previews, see text inside certain files.
* [https://support.apple.com/guide/mac-help/use-the-preview-pane-in-the-finder-on-mac-mchl1e4644c2/mac Use the Preview pane in the Finder on Mac]. '''View -> Show Preview''' Options.
* [https://mashtips.com/guide-quick-look-on-macos/ A Complete Guide for Using Quick Look on MacOS]
* [https://www.apple.com/macos/ventura/features/ New features available with macOS Ventura]
* [https://www.zdnet.com/article/how-to-use-the-new-quick-look-feature-in-macos-ventura-spotlight/ How to use the new Quick Look feature in MacOS Ventura Spotlight]


== Paintbrush ==
== Freeze/frozen==
https://paintbrush.sourceforge.io/
It happened when I try to use AirDrop. [https://appletoolbox.com/how-to-quickly-restart-or-relaunch-finder-in-macos/ How to Quickly Restart or Relaunch Finder in macOS].


Works fine. It does prompt to save for any changes when I quit the program.
'''killall Finder''' from Terminal


= Text editor =
== Add to Sidebar / bookmark ==
http://beebom.com/best-text-editors-for-mac/
File -> 'Add to Sidebar'


For printing to pdf files with line numbers, I am using GEdit in Ubuntu VM. Some promising editors like BBEdit cannot even let me open rmd files.
== Remember all my tabs and reopen them after restarting ==
* Finder always remember unless you '''kill''' the process. This will prevent its remembering currently-open windows. https://apple.stackexchange.com/a/418583
* Right click the Finder icon can show all the open tab locations at the top
* [https://nektony.com/how-to/force-quit-finder Force Quit Finder on Mac]


== Change the default text editor ==
== Permanently delete files ==
Just right (or control) click a file of the type you want to change and:
* Note that CMD + delete will move files to the Trash
"Get Info" -> "Open with:" -> (Select your program) -> "Change All".
** Shift + CMD + delete will empty the Trash. See [https://support.apple.com/en-us/HT201236 Mac keyboard shortcuts] from apple.com.
* Option + CMD + delete OR File + Option -> Delete will permanently delete files
* To see files in the Trash, click Finder -> Go -> Go to Folder -> enter "~/.Trash/" (no double quotes) and press ENTER.
 
== Change font size ==
[http://osxdaily.com/2016/02/25/change-text-font-size-finder-mac-os-x/ View -> Show View Options -> Text Size]
 
== Folder Date Modified ==
When I open an Excel file or a Word file, even I don't modify anything the '''Date Modified''' of this folder containing the file will be changed. Very annoying!  I think a more reasonable way is to change its setting. View -> Show View Options. Unselect "Date Modified" and check '''Date Added'''.  


The above method can be used to change the default player too (iTune -> VLC).
* It seems different folder can have their own setting.
* https://discussions.apple.com/thread/4183923
* http://osxdaily.com/2017/04/20/sort-files-by-date-mac/


If you use the '''open''' command in a terminal to open a text file, the default program will be used.
== Show the full file path ==
[https://www.stugon.com/show-current-path-mac-os-x-finder/ How to Show Current Path in Mac OS X Finder]. View -> Show Path Bar.


== [https://atom.io/ Atom] editor from Github ==
== [http://osxdaily.com/2015/11/05/copy-file-path-name-text-mac-os-x-finder/ Copy file full path] ==
Complains: too frequent updates. It makes multiple instances on the right click menu in '''Finder''' on '''macOS''' (seems it is only a problem on Mac). See a report [https://github.com/atom/atom/issues/11047 here]. A solution is
[https://www.makeuseof.com/macos-how-to-view-file-paths/ How to View File Paths in macOS]
<pre>
rm -rf ~/Library/Caches/com.github.atom.ShipIt
killall Finder
</pre>
and then launch Finder manually.


[http://flight-manual.atom.io/ Atom Flight Manual]
This is important since RStudio cannot drag and drop a file to insert the file path.


* The atom application requires no installation. So once it is downloaded (we actually download a zip file. After download has finished Safari browser will automatically decompress the zip file), we can drag it to the Application folder.
# Navigate to the file or folder you wish to copy the path for
* [https://stackoverflow.com/questions/22390709/how-to-open-atom-editor-from-command-line-in-os-x Open atom from a terminal].
# Right-click (or Control+Click, or a Two-Finger tap/click on the trackpad) on the file or folder in the Mac Finder
Method 1 (GUI). Atom -> Install Shell Commands. Two symbolic links ('''atom''' and '''apm''') will be created in /usr/local/bin to point to the currently opened Atom application.
# While in the right-click menu, hold down the OPTION/Alt key to reveal the “Copy (item name) as Pathname” option, it replaces the standard Copy option
# Once selected, the file or folders path is now in the clipboard, ready to be pasted anywhere


Method 2 (Manual):
Cf. On Ubuntu, it is much simple. Just click Ctrl+C.
<syntaxhighlight lang='bash'>
ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom
</syntaxhighlight>
* When you open the Atom the first time, it will split the screen into two '''panes''': [http://flight-manual.atom.io/getting-started/sections/atom-basics/ on the LHS it has a 'Welcome' and on the RHS it has a 'Welcome Guide']. You can choose to close any one of them by View -> Panes -> Close Pane. You may reopen the Welcome Guide by Help -> Welcome Guide. 
* You can hide the directory on the left hand side by View -> Toggle Tree View.
* Command Palette: Press Cmd+Shift+P.
** You can search by any keyword to find the keyboard shortcut.
** You can use it to [http://flight-manual.atom.io/getting-started/sections/installing-atom/ install the terminal commands '''atom''' and '''apm'''] if they were not installed during installing Atom.
* Settings: Atom -> Preferences.
* Open a file: Cmd+o. Save a file: Cmd+s.
* If a file is modified and not saved yet, the changes are saved to a cache. Even we close Atom, the changes are there. The original file is still intact.
* Open a directory as a project. Open a folder will add a tree view to the editor where you can browse all the files. You can toggle the tree view on the side of the window by Cmd+\.
* Jump to a specific line: Ctrl+g.
* Find and replace: Cmd+f. To search the whole project, Cmd+Shift+f.
* Folding: Alt+Cmd+[ and Alt+Cmd+]
* '''Panes''' splitting: Cmd+K Up/Down/Left/Right
* Preview a markdown file (toggle): Ctrl+Shift+M
* [https://discuss.atom.io/t/syntax-highlighting-for-r-language/12508/4 R syntax highlight]
<syntaxhighlight lang='bash'>
$ apm install language-r
Installing language-r to /Users/USERNAME/.atom/packages ✓
# Re-start Atom to enable it
</syntaxhighlight>


Printing. No way!
== Enter key does not open the file ==
Use '''Command+Down''' instead of Enter key to open a file or go into a directory.


== [http://macdown.uranusjr.com/ Macdown]- markdown editor ==
'''Enter''' key is only used to rename a file. See https://discussions.apple.com/thread/3140356?start=0&tstart=0.
If I use macDown to open a text file, macDown will still assume the file is a markdown file and give a preview on the right panel.


== Sublime ==
Use Command+Down will immediately uncompress a tar.gz file.
http://www.sublimetext.com/


[https://stackoverflow.com/questions/9961350/in-sublime-text-2-how-do-i-open-new-files-in-a-new-tab How do I open new files in a new tab?]
== Go to the previous/next folder ==
* Cmd + [
* Cmd + ]


== [http://macromates.com/download TextMate] ==
== Go to a folder ==
http://lifehacker.com/5817833/the-best-programming-text-editor-for-mac
Use Cmd+Shift+o to go to a specific location by entering its full path. Unfortunately this option is not available in other applications in general.


For some reason when I open an old file, TextMate does not open it on a new tab; it opened the file in a new window??
== Permanently mapping a network drive ==
* [https://www.makeuseof.com/how-to-set-up-access-network-drive-mac/ How to Set Up and Access a Network Drive on a Mac]
* [http://osxdaily.com/2010/09/20/map-a-network-drive-on-a-mac/ Map a network drive to Mac OS X that re-mounts after system reboot]


== BBEdit ==
=== Users & Groups ===
[http://ccc.technews.tw/2019/04/08/bbedit-return-mac-app-store/ 5 年過去了,知名文字檔編輯軟體 BBEdit 回歸 Mac App Store]
In System Preferences -> Users & Groups. Click '''Login Items''' tab. You will see all item (e.g. NCIMacDriveScript) that will open automatically when I log in. The item location can be found by right clicking the item.


== gedit ==
== Tag ==
http://macappstore.org/gedit/ Does not work. I got the same error.
[https://www.howtogeek.com/402989/how-to-tag-files-on-a-mac-iphone-or-ipad/ How To Tag Files on a Mac, iPhone, or iPad]


= Jekyll =
== Alternative: [http://mac.eltima.com/file-manager.html Commander One]  ==
http://idratherbewriting.com/documentation-theme-jekyll/mydoc_install_jekyll_on_mac.html
(Free & commercial) dual pane file manager for Mac.


= Text to speech =
* [http://www.eltima.com/wiki/user-guides/commander.html User Guide]
* In Chrome/Safari select a paragraph and right click -> Speech -> Start speaking.
* The bookmark is called '[http://www.eltima.com/wiki/user-guides/commander/favorites.html Favorites]' in Commander One. Click the 'star' icon and a Windows' style of a right click menu will pop up. You can select 'Add to Favorites' to add the current directory to the favorites. This bookmarked location will be shown when you click the 'star' icon next time.
* [https://nosrac.github.io/Dictater/ Dictater]
* The icon (multiple horizontal lines) next to the 'star' shows the recent locations. This is useful too!
* [http://osxdaily.com/2010/03/28/how-to-make-your-mac-talk-text-to-speech/ How to Make a Mac Talk: Text to Speech]
* By default, Commander One will send anonymous usage statistics to Eltima. Go to Preferences -> General to uncheck this option.
* This Finder replacement solution also provides its users with the various ways of search.
* Cloud Storage Compatibility


= Dictionary =
== Alternative: Nimble Commander ==
[https://www.makeuseof.com/tag/easily-expanding-apple-dictionary-mac-only/ Expand Your Mac’s Dictionary App by Adding Additional Languages]
* http://magnumbytes.com/ (Free and paid). Dual-pane file manager with classic design.
* [https://github.com/mikekazakov/nimble-commander Source code]
* File search, ...


I add 'Simplified Chinese - English' dictionary and move it to the top. With the change, when I right click a word and choose 'Look Up' in a browser, the 'Simplified Chinese -English' will be shown up on top.
== Right click open with ==
[https://osxdaily.com/2013/01/22/fix-open-with-menu-mac-os-x/ Remove Duplicates from the “Open With” Right-Click Menu in Mac OS X]
<pre>
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\   
LaunchServices.framework/Versions/A/Support/\
lsregister -kill -r -domain local -domain user


= Videos =
killall Finder
[https://www.tekrevue.com/tip/trim-videos-quick-look-mojave/ How to Trim Videos with Quick Look in macOS Mojave]
</pre>


= Java =
== Find files ==
[https://solarianprogrammer.com/2018/09/28/installing-openjdk-macos/ Installing OpenJDK 11 on macOS Mojave]  
[https://www.makeuseof.com/tag/spotlight-alternatives-mac-search/ The 5 Best Spotlight Alternatives for Searching Mac Files and More]


= Printer =
== FTP clients ==
To print a test page: Mac -> System Preferences > Printers and Scanners. Double click a printer, go to the menu on top and select Print -> Print Test Page.
[https://www.muo.com/tag/8-free-ftp-clients-for-mac/ The 5 Best FTP Clients for Mac]


When installing an office printer (\\nciprint\5W012CAN5560, Canon iR-ADV C5550/5560 UFR II), mac asks for the driver (1. Generic PostScript Printer 2. Generic PCL Printer 3. Select Software). If I choose Generic PostScript Printer, the test page shows the driver name "Generic.ppd" and version 1.0. When I download the driver from [https://www.usa.canon.com/internet/portal/us/home/support/details/copiers-mfps-fax-machines/multifunction-copiers/imagerunner-advance-c5560i Canon] website and add the printer using the new driver, the test print page shows driver name CNPZUIRAC5550ZU.ppd.
== Cloud file manager ==
[https://cyberduck.io/ Cyberduck]. Cyberduck is a libre server and cloud storage browser for Mac and Windows with support for FTP, SFTP, WebDAV, Amazon S3, OpenStack Swift, Backblaze B2, Microsoft Azure & OneDrive, Google Drive and Dropbox.


= PDF =
== Open rar files ==
== Print to PDF from the print dialog ==
[https://apps.apple.com/us/app/the-unarchiver/id425424353?mt=12 The Unarchive‪r‬] from Mac App Store.
In the Print dialog, look for the “PDF” button in the lower left corner, click on that pull-down menu, and select “Save as PDF”. Click “Save” in the save dialogue box, and save the file to whatever location you want.


== Command line to print a file to pdf ==
= Screenshots =
* https://apple.stackexchange.com/questions/273758/is-there-a-simple-way-to-convert-a-unicode-text-file-to-pdf-on-the-command-line
* Shift + Cmd + 5 = screenshot app in Ventura (macOS 13).
<pre>
* Shift +Cmd + 4:  select a rectangle
# Suppose we have an R file. We like to print it to PDF with line numbers.
* First hit Cmd + Shift + 4. Then hit Space. Capture the current window.
$ cat -n tmp.R > tmp.txt
* http://www.howtogeek.com/278615/the-best-screenshot-apps-for-macos/
$ cupsfilter tmp.txt > tmp.pdf
* [https://www.makeuseof.com/tag/change-mac-screenshot-save-location/ How to Change Where Mac Screenshots Are Saved]
* [https://www.makeuseof.com/tag/how-to-take-a-screenshot-on-a-mac/ How to Take a Screenshot on Your Mac (Using Several Methods)].
** To Change the Default Screenshot Format.
** To Change Where Screenshots Get Saved. On macOS Mojave and, you can change the default destination folder directly from the Screenshot app.
** To Change the Default File Name for Screenshots.
* [https://osxdaily.com/2013/03/19/turn-off-the-screen-shot-empty-trash-sound-effects-in-mac-os-x How to Turn Off Screen Shot & Empty Trash Sound Effects in Mac OS X]. Preferences -> Sound -> uncheck '''Play user interface sound effects'''.


# OK. But how to control the font size? How to deal with indentation for line wrapping. Landscape orientation.
== Terminal ==
</pre>
Use the '''[https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/screencapture.1.html screencapture]''' command.
* [http://www.eprg.org/pdfcorner/text2pdf/ text2pdf]
<syntaxhighlight lang='bash'>
* Use pandoc to convert it to docx (so we can control font size) and convert it again to PDF.
screencapture test.jpg


== Convert a pptx to pdf ==
screencapture -c    # send to the clipboard
The 'Zoom' function is kind of slow to response with Office 2016. There is no this problem with converted PDF file.


* Use 'Save As...'
screencapture -T 10 timedshot.jpg # timer
* Don't use print to PDF. The quality will reduced.


== Delete/add/reorder page pages using Preview ==
screencapture -w test.jpg
http://osxdaily.com/2010/01/20/delete-pages-in-a-pdf-document/
# OR
screencapture -W


There is no need to save the document. It will be saved automatically.
screencapture -h    # help
</syntaxhighlight>
To view an image file, use the '''[https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/open.1.html open]''' command. See also [http://brettterpstra.com/2014/08/06/shell-tricks-the-os-x-open-command/ Shell tricks: the OS X open command].
<syntaxhighlight lang='bash'>
open test.jpg
</syntaxhighlight>


For some reason, after I join pdf files and export the merged pdf, the exported file contains only 1 page.
To view the metadata of an image file, use the '''mdls''' command such as ''mdls XXX.png''. See [https://www.macissues.com/2014/05/12/how-to-look-up-file-metadata-in-os-x/ How to look up file metadata in OS X]


A more reliable way is to use a built-in [https://apple.stackexchange.com/questions/230437/how-can-i-combine-multiple-pdfs-using-the-command-line command line program 'join.py'] (works on OS X El Capitan)
== Grab ==
<syntaxhighlight lang='bash'>
Grab is a utility. Finder -> Go -> Applications -> Utilities -> Grab.
# Use Cmd + c to copy PDF files relative paths from /home/$USER/Downloads directory


cd /User/$USER/Downloads/
[https://appletoolbox.com/2013/01/how-to-use-mac-os-x-grab-utility-to-take-screenshots/ How To Use macOS & Mac OS X Grab Utility To Take Screenshots]
"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" \
  -o FILE.pdf \
  file1.pdf file2.pdf /PATH/TO/A/WHOLE/DIR/*.pdf
</syntaxhighlight>


== Print multiple pages per sheet ==
Take a Timed Screenshot With the '''Grab''' (built-in) Application. Open Grab, select Capture -> Selection/Window/Screen/Timed screen.
"Preview" does not have this option. Use [https://www.wikihow.com/Print-Multiple-Pages-Per-Sheet-in-Adobe-Reader Adobe Reader].
== Merge/combine several PDF files ==
[https://www.tekrevue.com/tip/combine-pdfs-mac-quick-actions/ How to Use Mojave’s Quick Actions to Quickly Combine PDFs on the Mac]


== Crop pdf files ==
== [https://app.prntscr.com/en/index.html Lightshot] ==
Preview. See a demonstration on [https://youtu.be/mneEdGBEs5o youtube]. This is very good and the crop experience is similar to [https://sourceforge.net/projects/briss/ briss].
Lightshot works like [[Linux#Shutter|Shutter]] in Ubuntu - easy to use and can sit on the taskbar.


# View → Thumbnails
Note: to view an image resolution in '''Finder''', right click an image and select '''Get Info''' -> More Info.
# Select all pages by Cmd+a. Use Cmd+click to unselect any pages.
# Click the '''Show Markup Toolbar''' button from the RHS of the toolbar and click the '''Rectangular Selection''' button or directly click on Tools → Rectangular Selection
# Use mouse to select an area on the first page (or on a specific page). A rectangular area will show up on ALL pages.
# Adjust the width/height as you want from the 1st page (or from the specific page).
# Close the document and the changes will be automatically saved.


== Edit by Preview ==
Its icon is a feather.
* [https://www.imore.com/how-use-preview-mac How to use Preview on Mac] highlight/underline/strike through (a highlighter icon), crop, add signature. To remove highlights, right click a highlight and select the red backslash icon (the last one) to do it.
* [https://support.apple.com/en-us/HT201740 Use the Preview app to view and edit images and PDFs]


== Search woe in Preview ==
Feather has an advantage that the screenshot does not need to be saved. It can be copied to a clipboard and then discarded.
If a word is split, it can not find it. For example, "ade-quacy" cannot be found.


== Preview Keyboard shortcuts  ==
= Screen cast/recorder =
* Hide sidebar: CMD + Option +1
* [https://www.howtogeek.com/724687/how-to-screen-record-on-mac/ How to Screen Record on Mac]
* Show sidebar: CMD + Option +2
* [https://www.screenrecordersoftwares.com/top-best-screen-recorder-for-mac/ Top Best Screen Recorder For Mac]
* Show Table of Contents: CMD + Option +3
* [https://www.makeuseof.com/best-free-screen-recorder The Best Free Screen Recorders to Save Your Online Meetings]


== Kill Preview ==
== MacOS Big Sur, Catalina, & Mojave ==
Using the command line: '''killall Preview'''
[https://osxdaily.com/2020/08/06/how-make-screen-recordings-macos/ How to Make Screen Recordings in MacOS Big Sur, Catalina, & Mojave]. Hint: Shift + CMD + 5. Note audio is not recorded. Note that I did not see the control panel anymore. But luckily I can use the touch bar to stop recording (or Command-Control-Esc). [https://fossbytes.com/how-to-record-screen-on-mac How To Record Screen On Mac With Audio & Without Audio?]


== Icon/symbol next to opened documents under 'Window' menu ==
[https://blogs.systweak.com/how-to-record-screen-on-mac-with-sound How to Record Screen on Mac with Sound] using a commercial software like [https://www.globaldelight.com/capto/ Capto] or [https://www.araelium.com/screenflick-mac-screen-recorder Screenflick].
https://developer.apple.com/design/human-interface-guidelines/macos/menus/menu-anatomy/


* Checkmark: the active document
== iPad/iphone ==
* Diamond: document that is currently minimized in the Dock.
[https://www.vidmore.com/record-video/screen-record-with-sound-ios/ How to Record iOS Screen with Sound in Simple Clicks]. The only problem is the file size could be very large.


= Disk =
== Quicktime/QT player ==
== Trash can ==
* We can record the screen (full screen or a selected region). The recorded file will be in a .mov format and saved in the Desktop (no setting to change the default directory).
See its icon in the Dock.
* [https://support.apple.com/en-us/HT208721 How to record the screen on your Mac]
** <s>Method 1: Shift + Cmd + 5</s>
** Method 2: Quicktime. File - New Screen Recording. Choose 'Entire screen' or 'Selected portion'. Then click the 'Recording' button to start recording. When finished, click the white circle on the top taskbar to stop recording. By default, the movie files (*.mov) are saved in my home directory.
 
== Screenshot utility ==
* [https://www.appgeeker.com/record/quicktime-record-screen-and-audio.html How to use QuickTime to record screen and audio: Ultimate Guide]
** Tip1: Click '''Options''', and then choose [your Mac name] Microphone if you want to record your voice to add narration to the video. The default is None.
** Tip2: To stop recording the screen, press the '''CMD + Control + Esc''' keys. OR CMD + Shift + 5 to bring up the toolbar and press the STOP button.
** Note: File size could be very large. For example, 19 seconds video & 2270x1548 will be 85 MB.
 
* [https://www.appgeeker.com/record/record-screen-with-audio-mac.html How to record screen with audio on Mac - computer audio included]
** Soundflower has no support for apple silicon
** [https://github.com/ExistentialAudio/BlackHole BlackHole] supports intel & apple silicon. [https://appletoolbox.com/record-screen-internal-audio-mac/ How to Record Screen With Internal Audio on Mac]. Read the 2nd comment.
 
== recordit ==
* http://recordit.co/. Free GIF screen recorder for Mac and Windows
* [https://www.mysocialagency.com/jump-bandwagon-make-twitter-gif/ How to Make Your Own GIFs to Use on Twitter]
 
== Screen cast o magic ==
http://screencast-o-matic.com/
 
== LICEcap ==
[https://www.cockos.com/licecap/ LICEcap]. See [https://slowkow.com/notes/harmony-animation/ Harmony] animation.


[http://www.dummies.com/computers/macs/mac-operating-systems/using-the-trash-folder-in-mac-os-x-lion/ Using the trash folder]
= Application =
== How to Install Applications  ==
* http://www.howtogeek.com/177619/how-to-install-applications-on-a-mac-everything-you-need-to-know/
* [http://commandlinemac.blogspot.com/2008/12/installing-dmg-application-from-command.html Installing a .dmg and .pkg application from the command line]


== Alternative to WinDirStat ==
== Trouble shooting ==
https://alternativeto.net/software/windirstat/?license=free&platform=mac
=== XXX can't be opened because Apple cannot check it for malicious software ===
https://youtu.be/6knyHlUe1cM?t=1205. Open Preferences - Security & Privacy - General. Click 'Open Anyway'. 


* ncdu
=== The binaries are not signed ===
Consider the [https://github.com/nkanaev/yarr yarr](Yet Another RSS Reader) application, to bypass these measures, you can run the command:
<pre>
<pre>
brew install ncdu
xattr -d com.apple.quarantine /Applications/yarr.app
</pre>
</pre>
* [http://www.derlien.com/ Disk Inventory X]. It shows the sizes of files and folders in a special graphical way called "treemaps". The filename is ''DIX1.0Universal.dmg''. It froze my Mac:(
* [https://github.com/shundhammer/qdirstat QDirStat] based on Qt. No binary for macOS
* [https://daisydiskapp.com/ DaisyDisk] $10.


= Google Chrome browser =
=== Damaged App Cannot be Opened on MacOS Error ===
* https://en.wikipedia.org/wiki/Google_Chrome and [https://chromereleases.googleblog.com/search/label/Stable%20updates Chrome stable updates]
[https://appuals.com/damaged-app-cannot-be-opened-on-macos-error/ FIX: Damaged App Cannot be Opened on MacOS Error]
* [https://www.whatismybrowser.com/guides/the-latest-version/chrome What's the latest version of Chrome?]


= Safari =
=== Gatekeeper ===
[https://www.howtogeek.com/368817/how-to-view-websites-on-mac-that-require-internet-explorer-or-a-pc/ How to View Websites on Mac that Require Internet Explorer/Edge (or a PC)]
[https://www.istartips.com/disable-gatekeeper.html How to Disable Gatekeeper to Allow App Installation from Anywhere in macOS]


= Developer =
== Keyboard shortcut to launch an application ==
Macs (unlike Linux) don’t come with a package manager, but there are a couple of popular package managers you can install. See [http://www.scipy.org/install.html SciPy].
* F4 key - LaunchPad
* Command + Space - Spotlight search


== Install [https://developer.apple.com/xcode/ Xcode] ==
== Messages when you launch an application ==
http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/
* Google Chrome


Note:
[[File:ChromeMac.png|250px]]
* Download directly from https://developer.apple.com/download/more/ (log in required)
* It seems there is no way to run this automatically without the alert box. Users need to [https://www.maketecheasier.com/install-command-line-tools-without-xcode/ agree the license].
<syntaxhighlight lang='bash'>
xcode-select --install
</syntaxhighlight>
The installed tools (like ar, gcc, g++, git, libtool, make, nm, otool, svn, et al) are located in '''/Library/Developer/CommandLineTools/usr/bin/''' directory. If the command is run again, you will get a message
<pre>
xcode-select: error: command line tools are already installed, use "Software update" to install updates
</pre>


To check the Xcode version (if you have installed a ''full'' Xcode)
* iTerm
<syntaxhighlight lang='bash'>
$ xcodebuild -version  # if you have the full Xcode installed
Xcode 8.2.1
Build version 8C1002  # if you only have the command line tool installed
$ xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer
directory '/Library/Developer/CommandLineTools' is a command line tool instance
</syntaxhighlight>


To check whether Xcode has been installed
[[File:Iterm open.png|250px]]
<syntaxhighlight lang='bash'>
$ xcode-select -p
/Library/Developer/CommandLineTools            # if you have installed the command line tool only
# or
/Applications/Xcode.app/Contents/Developer  # if you have the full Xcode package installed
# or
xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one
(or see `man xcode-select`)
</syntaxhighlight>


To accept the XCode license through command line, follow the post [https://klue.github.io/blog/2017/04/macos_kernel_debugging_vbox/ Debugging macOS Kernel using VirtualBox]:
* SeqTools
<syntaxhighlight lang='bash'>
$ sudo xcodebuild -license accept # it seems not working. A dialog is still popped up.
</syntaxhighlight>


The '''df''' command shows installing the command line developer tools takes about 600MB space.
[[File:Seqtoos open1.png|250px]] [[File:Seqtoos open2.png|250px]] [[File:Seqtoos open3.png|250px]]


== Uninstall Xcode ==
== Install pkg file from command line ==
http://osxdaily.com/2012/02/20/uninstall-xcode/
http://apple.stackexchange.com/questions/15658/how-can-i-open-a-pkg-file-manually
<pre>
sudo installer -pkg ~/Downloads/packagename.pkg -target ~/Applications/
# OR
installer -pkg ~/Downloads/packagename.pkg -target ~/Applications/
</pre>


== Header file location ==
== Close an application ==
* /usr/include (does not exist on my 10.12 Sierra)
Clicking the red button does close/quit an application/a program. You need to use Command-Q.
* /usr/local/include (some are over there; e.g. from "sudo make install" command)
 
* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/ (if you have installed a full Xcode)
[https://discussions.apple.com/thread/3826532?tstart=0 Another answer]: The red close button just closes the window.  It is up to the application whether it quits or not - typically if the application uses documents or it has other windows that can be opened it will not quit. Applications with a single window (System Preferences, for example), will usually quit when the window is closed, since there isn't anything else it does.
 
== Delete/remove an application ==
[https://freemacsoft.net/appcleaner/ AppCleaner]


I get the following error
== How to Add, Remove, and Delay Startup Apps on a Mac ==
<pre>
[https://www.makeuseof.com/tag/add-remove-delay-startup-items-mac/ How to Add, Remove, and Delay Startup Apps on a Mac]
In file included from init.c:1:
/Library/Frameworks/R.framework/Resources/include/R.h:55:11: fatal error: 'stdlib.h' file not found
# include <stdlib.h> /* Not used by R itself, but widely assumed in packages */
          ^~~~~~~~~~
1 error generated.
make: *** [init.o] Error 1
ERROR: compilation failed for package ‘later’
</pre>
when I install some package. The stdlib.h file is missing from /usr/local/include. However, a simple C code compiles fine.
<syntaxhighlight lang='c'>
#include <stdio.h>
#include <stdlib.h>


int main ()
== RSS Reader ==
{
  char str[10] = "3.14";
  printf("The value is %f\n",atof(str));
  return 0;
}
</syntaxhighlight>


See this post [https://stat.ethz.ch/pipermail/r-sig-mac/2018-December/012880.html (R-SIG-Mac) 'math.h' file not found]
[https://osxdaily.com/2022/01/03/free-rss-reader-iphone-ipad-mac-netnewswire/ Need an RSS Reader for iPhone, iPad, or Mac? Get NetNewsWire]
<syntaxhighlight lang='bash'>
 
sudo installer -pkg \
= Package formats =
  /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg \
== app ''directory''/Application  ==
  -target /
In '''Finder''', the attribute of the file is an ''Application''.  
</syntaxhighlight>
However, I don't have "Packages" directory.


See [https://stackoverflow.com/questions/28362994/where-is-my-stdio-h-in-mac Where is my “stdio.h” in Mac?] & [https://superuser.com/questions/995360/missing-usr-include-in-os-x-el-capitan/1009364 Simply installing Xcode will not install all of the command line developer tools]. Try
Example: App Store.app, Atom editor, [https://www.sourcetreeapp.com/ SourceTree]
* Run "sudo ln -sf /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /usr/include". Get a message '' "Operation not permitted". '' See this post [https://apple.stackexchange.com/q/196224 Unix “ln -s” command not permitted in OSX El Capitan Beta3]
* Run "xcode-select --install". Get a message '' "Can't install the software because it is not currently available from the Software Update server." ''


Search within [https://www.google.com/search?source=hp&ei=dfR_XKCwGYmw5wK5xbeoAQ&q=site%3Ahttps%3A%2F%2Fstat.ethz.ch%2Fpipermail%2Fr-sig-mac%2F+stdlib.h&btnK=Google+Search&oq=site%3Ahttps%3A%2F%2Fstat.ethz.ch%2Fpipermail%2Fr-sig-mac%2F+stdlib.h&gs_l=psy-ab.3...1864.7270..7601...0.0..0.52.648.15......0....1j2..gws-wiz.....0..0i131j0j0i131i10.khUOoin_wpw R-SIG-Mac Archives].
http://apple.stackexchange.com/questions/112197/what-does-a-app-file-actually-do


=== System Integrity Protection/SIP  ===
'''apps''' are "Package Bundles" is Apple jargon. These are actually Unix directories, in a special format. The actual Unix Executable File is in a subdirectory named MacOS, which you can see using the '''Show Package Contents''' menu in Finder.
* [https://support.apple.com/en-us/HT204899 About System Integrity Protection on your Mac]
* [https://www.ihash.eu/2015/11/how-to-disableenable-sip-on-mac-os-x-el-capitan/ How To Disable/Enable SIP on Mac OS X 10.11 El Capitan]
* [https://stackoverflow.com/questions/53104473/macos-clang-via-homebrew-broken-under-mojave-wchar-h wchar.h not found]. I got the same error when I try to compile buggy.cpp file by following [https://www.bioconductor.org/developers/how-to/c-debugging/ Debugging C/C++ code] on Bioconductor.


== Lib location ==
To deliver the program in an app format, we can zip the app folder. If we use Safari browser, it will automatically decompress the zip file so the app program will appear in the Downloads directory.
* /usr/lib
* /usr/local/lib
* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib/ (if you have installed a full Xcode)


== ldd on Mac ==
For example, in SourceTree, the download file is called 'SourceTree_X.Y.zip'. When we click the zip file, it will be automatically extracted. And when I click SourceTree.app, it will have a dialog to help user to move the program to the application folder.
<pre>
otool -L  <exec>
</pre>


== openssl ==
[[File:Sourcetree.png|250px]]
'''Method 1''': brew
* https://solitum.net/openssl-os-x-el-capitan-and-brew/
<syntaxhighlight lang='bash'>
brew doctor
brew update
brew upgrade
brew install openssl  # the opposite operation is 'uninstall'
cd /usr/local/include
ln -s ../opt/openssl/include/openssl .
</syntaxhighlight>


'''Method 2''': compile yourself
== [https://en.wikipedia.org/wiki/Installer_(macOS)#Installer_package pkg file] ==
* http://apple.stackexchange.com/questions/221587/how-to-make-a-clean-install-of-openssl-on-el-capitan
Example: [https://cran.rstudio.com/bin/macosx/ R-cran]
* http://mac-dev-env.patrickbougie.com/openssl/


== Python packages ==
* [https://www.crystalidea.com/blog/extract-pkg-files-mac-and-windows Extract PKG files on Mac and Windows]
http://www.scipy.org/install.html
* [http://osxdaily.com/2016/08/31/open-kg-files-mac-what-installs-where-suspicious-package/ How to Open .pkg Files to View What Will Install on Mac with Suspicious Package]


= Install macOS on a PC =
PKG files are Mac OS X installation (setup) packages that contain installer scripts ('Scripts' file) and compressed installation files ('Payload' file) that are used to install Mac software applications onto a user's hard drive.
http://www.makeuseof.com/tag/how-to-install-mac-os-x-on-a-pc-without-using-a-mac/ (7/17/2017)


= VirtualBox =
On the case of R-x.y.z.pkg, it contains R framework, '''R.app''' GUI, Tcl/Tk X11 and TexInfo.
== Touchpad ==
The direction of scrolling up and down in guest machine is opposite to the host machine.


== Keyboard shortcuts (macOS + Windows keyboard)==
To install a pkg file from terminal, see [http://apple.stackexchange.com/questions/72226/installing-pkg-with-terminal this] post
Since there is no Command key on Windows keyboards, we need to modify preferences.  
<syntaxhighlight lang='bash'>
sudo installer -pkg R-3.3.3.pkg -target /
</syntaxhighlight>


[https://www.howtogeek.com/219156/how-to-remap-your-windows-cutcopypaste-to-os-x-like-controls-and-vice-versa/ Copy and paste]: go to preferences -> keyboard -> Modifier keys. Change 'Option' key to 'Command' key and 'Command' key to 'Option' key. Since the 'Option' key is 'Alt' on Windows keyboards, the layout will be very similar to using Mac keyboards. This is consistent with [https://www.amazon.com/gp/product/B01LZAK8MM/ref=ox_sc_act_title_1 Logitech K780] multi-device keyboard where 'Alt' key shares with the 'Command' key.
=== pkgutil ===
* [http://infoheap.com/mac-pkgutil-tutorial/ mac pkgutil – quick start guide]
* pkgutil is used to keep previous version of R


Do not use Ctrl to replace Command; you will not able to use the Ctrl key in '''nano''' and you are missing Ctrl + a to move mouse to HOME in Terminals. NOTE: [[#Terminal_replacement|iTerm2]] is a good replacement for macOS's built-in '''Terminal''' program; HOME/END works.
== [https://en.wikipedia.org/wiki/Apple_Disk_Image dmg (disk image) file] ==
Example: Google chrome, JDK, FastQC, Sketchup, Commander One.


== Keyboard shortcuts (Windows OS + mac keyboard) ==
A DMG file is a disk image, which is sort of like an archive file. When you download one, you can double-click it to “mount” it (under '''Devices''' in the '''Finder'''), allowing you to extract the application from inside it.
* Left CMD is used by VirtualBox to switch to full screen (at least on VirtualBox)
* Right CMD = Windows key
* fn + delete = DEL/Backspace key


== Guest additions ==
After the app is dragged to your Applications folder, you can run it normally — from the Finder, Launchpad, Spotlight, dock, or anything else.
VirtualBox doesn't have guest additions for OSX. http://askubuntu.com/questions/372982/virtualbox-4-3-guest-additions-on-osx-guest


In order to share files between the host and guest machine, we need to 1. add 'host-only' network adapter to the guest machine and 2. enable 'Remote Login' by going to the System Preferences -> Sharing.
We can mount or eject a dmg file by  
 
For example, from the host machine, I can use the following on the host machine to access the guest machine
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
$ ssh brb@brbs-MacBook-Pro.local
# mount
hdiutil mount fastqc_v0.11.5.dmg
# copy its content
mkdir -p ~/FastQC
cp -r /Volumes/FastQC/FastQC.app/Contents/MacOS/* ~/FastQC/
# eject
hdiutil eject /Volumes/FastQC/
</syntaxhighlight>
</syntaxhighlight>


However, it is unsuccessfully to do access the host machine from the guest machine??
To create a dmg file (see [http://stackoverflow.com/questions/96882/how-do-i-create-a-nice-looking-dmg-for-mac-os-x-using-command-line-tools command line] or [http://apple.stackexchange.com/questions/48414/how-do-i-create-a-dmg-file-from-a-directory here] and [http://www.technorms.com/30882/create-dmg-files-in-mac-os-x GUI])
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
$ ssh USERNAME@192.168.56.1
hdiutil create -volname WhatYouWantTheDiskToBeNamed \
    -srcfolder /path/to/the/folder/you/want/to/create \
    -ov -format UDZO name.dmg
</syntaxhighlight>
</syntaxhighlight>


== Smart card reader ==
To convert a dmg file to iso
If USB is enabled in the guest machine, the Smart Card reader will not be available on the host machine. That is, we cannot use the smart card in Mac. So it is necessary to uncheck the USB from the USB setting in the guest machine.
<syntaxhighlight lang='bash'>
hdiutil convert imagefile.dmg -format UDTO -o imagefile.iso
mv imagefile.iso.cdr imagefile.iso
</syntaxhighlight>


== Screen resolution ==
To install a dmg file from terminal, see [http://stackoverflow.com/questions/22934083/install-dmg-package-on-mac-os-from-terminal this] or [http://apple.stackexchange.com/questions/73926/is-there-a-command-to-install-a-dmg this]
https://forums.virtualbox.org/viewtopic.php?f=22&t=54030 works.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
$ VBoxManage setextradata "vm_name" VBoxInternal2/EfiGopMode 4
MOUNTDIR=$(echo `hdiutil mount jdk-8u121-macosx-x64.dmg | tail -1 \
| awk '{$1=$2=""; print $0}'` | xargs -0 echo) \
&& sudo installer -pkg "${MOUNTDIR}/"*.pkg -target / \
&& sudo hdiutil detach "${MOUNTDIR}"
</syntaxhighlight>
</syntaxhighlight>
The number '3' corresponds to a resolution of 1280x1024 (5:4) and '4' corresponds to 1440x900 (8:5). On lenovo laptop (1600 x 900, 16:9), the height will fill the screen but there are little black spaces on both sides. See [https://en.wikipedia.org/wiki/Graphics_display_resolution#Overview_by_vertical_resolution_and_aspect_ratio Display resolution and aspect ratio].


Note that I need to enable Full Screen for the guest machine b/c the desktop is too large.
Explanation: The first command (hdiutil mount jdk-8u121-macosx-x64.dmg) will output
<pre>
expected  CRC32 $628D96B6
/dev/disk2          GUID_partition_scheme         
/dev/disk2s1        Apple_HFS                      /Volumes/JDK 8 Update 121
</pre>
We like to grab the string "/Volumes/JDK 8 Update 121". This can be achieved by getting the last line of the output and replace the first and 2nd fields with empties and then output the whole line.


== El Capitan (10.11) ==
= Package manage software =
* http://www.wikigain.com/install-mac-os-x-el-capitan-virtualbox/
http://apple.stackexchange.com/questions/32724/what-are-pros-and-cons-for-macports-fink-and-homebrew & http://apple.stackexchange.com/questions/64690/macports-vs-fink-vs-homebrew
* http://www.wikigain.com/complete-guide-fix-virtualbox-errors-installing-mac-os-x/
 
== [https://www.macports.org/ MacPorts]==
Different versions of Mac OS X has a different macport binary (in .pkg format).
 
[http://www.makeuseof.com/tag/macports-open-source-software-mac/ MacPorts Brings the Best Open Source Software to Your Mac]
 
== Homebrew ==
* http://brew.sh/, [https://docs.brew.sh/ Documentation]
* [https://formulae.brew.sh/formula/ List of packages/formulae], [https://formulae.brew.sh/analytics/install-on-request/30d/#header Sorting] by request events
* [https://opensource.com/article/20/6/homebrew-mac Introduction to Homebrew: the painless way to install anything on a Mac]
 
Homebrew installs packages to their own directory and then symlinks their files into '''/usr/local'''.
[https://ivelasq.rbind.io/blog/macos-rig/index.html Setting up macOS as an R data science rig in 2023]
<syntaxhighlight lang='bash'>
# Install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# It will ask around 3 times on your administrator password for a variety of questions.


It works on my VirtualBox 5.1.14 and Macbook Pro 2015.
Warning: /opt/homebrew/bin is not in your PATH.
  Instructions on how to configure your shell for Homebrew
  can be found in the 'Next steps' section below.
==> Installation successful!


Note: if I skip the following commands, the macOS booting will keep re-run again and again.
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
<pre>
Read the analytics documentation (and how to opt-out) here:
VBoxManage modifyvm macElcapitan --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
  https://docs.brew.sh/Analytics
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
No analytics data has been sent yet (nor will any be during this install run).
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1 
</pre>


Con: The image downloaded there is already a virtual machine image format.
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations


If I try to use the iso file downloaded from internet, I saw an error "Missing Bluetooth Controller Transport" (https://gist.github.com/frdmn/de12c894a385bc8e6bff).
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/USER/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh
</syntaxhighlight>
 
<syntaxhighlight lang='bash'>
# Search a package
brew search gedit
 
# install some package
brew install wget
brew install htop
brew install ruby # install a newer version of ruby & gem; overwrite the pre-installed one
brew install cvs
brew install gedit # The print to file function works great. need to launch from terminal
                  # https://formulae.brew.sh/formula/gedit
which htop        # /usr/local/bin/htop
 
# Update brew
brew update  # Not add sudo
# Uninstall homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
</syntaxhighlight>
 
[https://github.com/Homebrew/homebrew-cask brew cask]. While Homebrew primarily deals with '''command line''' software, Homebrew Cask is used for installing '''desktop applications'''. It provides a friendly command-line interface (CLI) workflow for the administration of macOS applications distributed as binaries.
 
Applications installed via Homebrew Cask are typically placed in the /Applications directory and can be launched like any other Mac application. You can also open the application in Terminal: '''open -a Firefox''' where "-a" means to open an application.  


== [https://en.wikipedia.org/wiki/MacOS_Sierra Sierra (10.12)] ==
# [https://www.howtoisolve.com/enable-picture-in-picture-for-youtube-in-macos-sierra/ Enable Picture-in-picture]. It works on Safari and Chrome browsers. Right click on a video and then immediately right click again. It will show an option "picture in picture" in the right-click menu. This is cool but it seems there is no way to control the video except play/pause.
#* Another choice is '''[https://github.com/kamranahmedse/pennywise Pennywise]''' which keep all the keyboard shortcuts the original website provided. By default it has a NAVBAR (Left, Right and URL) at the top. We can toggle it by using Cmd/Ctrl + Shift + L.
#* Another choice is Google chrome browser. See [https://www.addictivetips.com/web/chrome-picture-in-picture-mode/ How to use Chrome picture in picture mode].
# The official image (e.g. '''Install macOS Sierra.app''') we downloaded from ''Apple Store'' is saved under '''/Applications''' folder.
# We can follow the instruction https://github.com/geerlingguy/macos-virtualbox-vm to convert the app folder into an iso file. The ''prepare-iso.sh'' script seems to always put the iso file onto the Desktop folder; i.e. output folder and name is not taken.
# When we want to create a virtual machine in VirtualBox
#* video memory change from 16GB to 128MB
#* increase memory to 4096MB
#* turn off audio
<pre>
<pre>
VBoxManage modifyvm "{vmname}" --cpuidset 00000001 000306a9 00020800 80000201 178bfbff
brew search calibre
</pre>
brew search kindlegen
Another [https://techsviewer.com/install-macos-sierra-virtualbox-windows/ instruction] is to run ('''this seems to be necessary even we uses 'import Appliance' method''')
brew search vlc
<pre>
brew info calibre
VBoxManage modifyvm "Sierra10.14" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
brew install --cask calibre
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
brew uninstall --cask calibre
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
 
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
# https://www.code2bits.com/how-to-update-homebrew-cask-formula-on-macos/
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
brew update            # Fetch latest version of homebrew and formula.
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
brew list              # List all the installed formulae.
brew outdated          # Show formulae with an updated version available.
brew upgrade            # Upgrade all outdated and unpinned brews.
brew upgrade [formula]  # Upgrade only the specified brews (but do so even if they are pinned)
brew pin    [formulae]  # Pin the specified formulae (Prevents from being upgraded - 'brew upgrade').
brew info  [formulae]  # Display information about formula.
brew cleanup            # For all installed or specific formulae, remove any older versions from the cellar.
</pre>
</pre>


After booting, select the preferred language and (before click the 'Continue' button) go to Utilities > Disk Utility. Select the VirtualBox disk (VBOX HARDDISK Media)and choose Erase to format it as a Mac OS Extended (Journaled) drive. Installing macOS took about 15 minutes on my Dell T3600 Desktop running Ubuntu/Mint.
'''brew tap''' command.  


After a successful login, the 'df -h' command shows macOS uses 8.6 GB space.
* https://stackoverflow.com/questions/34408147/what-does-brew-tap-mean
* Used by [https://github.com/cjbassi/gotop gotop]


Unfortunately, the Mac guest machine cannot install guest additions.
[https://stackoverflow.com/questions/7323261/uninstall-remove-a-homebrew-package-including-all-its-dependencies How to uninstall / remove a Homebrew package including all its dependencies]


I get a 'Guru meditation' error when I test the iso on an old non-mac machine (intel core 2 duo CPU).
'''[https://caskroom.github.io/ Homebrew Cast]''' extends Homebrew and brings its elegance, simplicity, and speed to macOS applications and large binaries alike. [https://apple.stackexchange.com/questions/125468/what-is-the-difference-between-brew-and-brew-cask What is the difference between `brew` and `brew cask`?].


Note there is an error ('''IOConsoleUsers: gIOScreenLockState 3, hs 0, bs 0, now 0, sm 0x0''') to install Sierra '''10.12.4''' as a guest machine. See https://benlimmer.com/2017/04/23/macos-sierra-virtualbox-10-12-4/.
== [http://www.finkproject.org/ Fink] ==
No binary installer for recent versions of OS X (good to me). You will need to install the proper Command Line Tools for Xcode for your system.  


== High Sierra (10.13) ==
== [http://rudix.org/ Rudix] ==
[https://www.tekrevue.com/tip/download-high-sierra-mojave/ How to Download macOS High Sierra From macOS Mojave]
<syntaxhighlight lang='bash'>
# install
curl -s https://raw.githubusercontent.com/rudix-mac/rpm/2016.12.13/rudix.py | sudo python - install rudix
# install some package
sudo rudix install wget
sudo rudix install python-pip
# remove a package
sudo rudix remove python-pip
# uninstall
sudo rudix -R
</syntaxhighlight>


== Mojave (10.14) ==
= Extract files (Unzip) =
* [https://www.wikigain.com/install-macos-mojave-on-virtualbox-windows/ How to install macos mojave on virtualbox windows]
[https://theunarchiver.com/ Unarchiver]. Mentioned by [https://www.raspberrypi.org/downloads/raspbian/ Raspbian].
* [https://techsviewer.com/install-macos-10-14-mojave-virtualbox-windows/ How to Install macOS Mojave Final on VirtualBox on Windows PC]
 
* [https://thetechbloggerguy.blogspot.com/2018/12/macos-mojave-virtualbox-win10.html?m=1 How to Install macOS Mojave in VirtualBox on Windows 10]
== Remove __MACOSX directory and .DS_Store files in zip files ==
<syntaxhighlight lang='bash'>
zip -d data.zip "__MACOSX/*"
zip -d data.zip "*/.DS_Store"
</syntaxhighlight>


On VB 5.2.x.
= Preview/edit photos =
<pre>
* [https://www.howtogeek.com/preview-mac-features-to-discover/ 12 Things You Didn’t Know You Could Do in the Preview App on a Mac]
# cd "C:\Program Files\Oracle\VirtualBox\"
* Preview program can show Exif. Press Cmd +i to show 'Inspector'.  
VBoxManage modifyvm "macMojave" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
* [https://forums.macrumors.com/threads/photos-preview-and-browsing-without-importing.1615557/ Photos preview and browsing without importing]. Two options: Preview and Image Capture (preinstalled).
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
* [https://www.howtogeek.com/290451/how-to-remove-an-images-background-using-preview-on-macos/ How to Remove an Image’s Background Using Preview on macOS]
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
</pre>


Change Settings. Select USB and check 3.0 USB. This is to enable [https://techsviewer.com/how-to-install-virtualbox-extension-pack-and-enable-usb-3-0/ mouse and keyboard] support in the virtual machine.
To remove exif information, use [https://imageoptim.com/mac ImageOptim] program (open source). See an introduction [https://www.howtogeek.com/203592/what-is-exif-data-and-how-to-remove-it/ here].


After the first reboot, I need to remove the iso file. But it dropped to Shell after I boot up. It's more complicated. See the 3rd link above.
[https://sno.phy.queensu.ca/~phil/exiftool/ Exiftool] is a command line tool available in Linux/Mac/Windows. See [[Linux#Remove_GPS_metadata_from_jpg_files_-_exiftool| Remove GPS metadata from jpg files - exiftool]].


On Step 8, it complains "cd System\Library\CoreServices\". Change to use fs1 instead of fs2 fixes a problem.
== Best Preview Features ==
https://youtu.be/X5iZTXAg8vs


I am setting up a new user (brb/arraytools). Note the password must be at least 4 characters.
* [https://youtu.be/X5iZTXAg8vs?t=13 Copy from clipboard]
* [https://youtu.be/X5iZTXAg8vs?t=43 Fill and sign documents]
* [https://youtu.be/X5iZTXAg8vs?t=79 Remove image background], [https://youtu.be/4joNekG26LU Using Instant Alpha to Remove Image Backgrounds in OSX Preview] (Instant Alpha)
* [https://youtu.be/X5iZTXAg8vs?t=118 Photo editing]
* [https://youtu.be/X5iZTXAg8vs?t=147 Add/Remove pages in pdf]


It  shows 12 GB was used when I first boot up the machine.
== Shape and filler ==
Find the icon next to "A" on the toolbar. Click the 'down' arrow and select the one with a red diagonal line. This will remove filler in the shape.


The "TheTechBlogger_APFSEfi.iso" should be kept there.
https://youtu.be/MOnHrtiH2HU?t=222


== Create an ISO from the Sierra install app obtained from the Mac app store ==
== Markup toolbar ==
https://klue.github.io/blog/2017/04/macos_kernel_debugging_vbox/
* [https://support.apple.com/guide/preview/annotate-an-image-prvw1501/mac Annotate an image in Preview on Mac]
* [https://youtu.be/NIUL5UtWwrI?t=268 Crop, Arrows, Text] (video)


== How to Run Your Mac’s Boot Camp Partition as a Virtual Machine ==
== Combine images ==
https://www.howtogeek.com/315083/how-to-run-your-macs-boot-camp-partition-as-a-virtual-machine/
[https://www.makeuseof.com/combine-photos-into-collage-macos/ 3 Quick Ways to Combine Photos Into a Collage on macOS]


= Remote connection (ssh) =
= Image editor =
Use Preferences -> Sharing -> Select Remote Login. http://osxdaily.com/2011/09/30/remote-login-ssh-server-mac-os-x/
* https://www.howtogeek.com/304677/the-best-free-photo-editors-for-macos/
* [https://www.makeuseof.com/tag/best-image-viewer-apps-mac/ The 5 Best Mac Image Viewer Apps With Unique Features]
* [https://www.makeuseof.com/best-free-drawing-apps-mac/ The 4 Best Free Drawing Apps for macOS]. GIMP, Krita, MediBang Paint, Paintbrush]


To uses a command line to enable it, see
Note when I use the 'Preview' program, it will automatically save the changes without any warnings when I exit the program.
* http://apple.stackexchange.com/questions/237038/os-x-terminal-command-to-turn-on-off-ssh-server
* http://osxdaily.com/2016/08/16/enable-ssh-mac-command-line/
* http://superuser.com/questions/416096/enabling-ssh-daemon-from-terminal-os-x-lion


== ssh key ==
== [https://www.imagetasks.com/pixea/ Pixea] ==
'''Remote/Virtual machine''':
Viewing only.
go to system preferences -> sharing and enable remote login. Suppose the user name is 'brb' and the hostname is 'brbs-MacBook-Pro.local'.
* It has an option to show thumbnails (browse the contents of folders and archives w/o extracting them).  
* Including a Slideshow function.
* But it is not suitable if we just want to open a few image files and toggle between them (GIMP works in this situation).


'''Host machine''':
== qView ==
<syntaxhighlight lang='bash'>
[https://interversehq.com/qview/ website]. [https://github.com/jurplel/qView Open source], cross-platform. '''But it does not do panning.'''
ssh-keygen -t rsa -f ~/.ssh/virtmac  # press 'Enter' 3 times
cat ~/.ssh/virtmac.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"
ssh -i ~/.ssh/virtmac brb@brbs-MacBook-Pro.local
</syntaxhighlight>


When I run testings, I need to restore the virtual machine to its initial status. I can use this method in order to avoid the message "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" when I use the 'ssh' command.
== Paintbrush ==
https://paintbrush.sourceforge.io/


= Remote Desktop Connection to Mac =
Works fine. It does prompt to save for any changes when I quit the program.
On Mac, go to system preferences -> System Preferences -> Sharing -> '''Screen Sharing'''. It will show the vnc address of the Mac computer.


On my Ubuntu, see [https://help.ubuntu.com/community/AppleRemoteDesktop AppleRemoteDesktop]
== macSVG ==
* The built-in program '''Remmina Remote Desktop Client''' does not work. After clicking the 'connect' button & entering username/password, the screen flashed and disappeared.
https://macsvg.org/
* RealVNC. I download the tarball (VNC Connect 6.0.3, Generic x64, default). Extract it to the Download folder and run '''vncviewer''' program. Yes, I can connect to Mac. But since the Mac has a very high resolution, I need to adjust the resolution setting in my connection. To do that: close the connection, right click a connection icon (created from last connection), choose Properties. In 'Options' tab, select Scaling -> Scale to fit window.
** After connection, a toolbar will appear on the top of screen.  It has a series of icons: Full screen mode, No scaling, Ctrl Alt Del, Info, Properties, Disconnect.
** Even Mac screen lid is closed, VNC still works.
** The connection speed is not ideal. You can see the screen refresh slowly.
* Vinagre. It has to be installed from Ubuntu Software. Unfortunately it does not even allow me to enter a long password:(


= Remote Desktop Connection from Mac =
== Convert images to different formats ==
When I try to use the '''Screen Sharing''' (1.7) program in Mac to connect to Ubuntu 16.04 (type 'vnc://192.168.1.188'), I get an error 'The software on the remote computer appears to be incompatible with this version of Screen Sharing.'
[https://www.howtogeek.com/439289/how-to-convert-png-tiff-and-jpeg-images-to-a-different-format-on-your-mac/ How to Convert PNG, TIFF, and JPEG Images to a Different Format on Your Mac]


[[File:Failscreensharing.png|250px]]
== Photo collage ==
[https://www.makeuseof.com/combine-photos-into-collage-macos/ 3 Quick Ways to Combine Photos Into a Collage on macOS]


Another remote desktop program is called '''Remote Desktop Connection for iMac'''. It appears to be used to connect to a Windows-based computer.
To stitch them horizontally, use the following (it works when I tested on Mac Ventura 13.5)
<pre>
brew install imagemagick
convert +append 1.jpg 2.jpeg 3.jpg ~/Desktop/Result.jpg
</pre>
To combine photos vertically, replace '''+append''' with '''-append'''.
 
= Text editor =
http://beebom.com/best-text-editors-for-mac/


= Tips =
For printing to pdf files with line numbers, I am using GEdit in Ubuntu VM. Some promising editors like BBEdit cannot even let me open rmd files.
== Got a New Mac? Do This First! ==
http://www.makeuseof.com/tag/new-mac-setup/


== Update date and time using command line ==
== Change the default text editor ==
<syntaxhighlight lang='bash'>
Just right (or control) click a file of the type you want to change and:
sudo ntpdate -u time.apple.com
"Get Info" -> "Open with:" -> (Select your program) -> "Change All".
sudo ntpdate -u ntp1.nih.gov
</syntaxhighlight>


== Forget a wifi network ==
The above method can be used to change the default player too (iTune -> VLC).
* http://osxdaily.com/2014/03/09/forget-wifi-network-mac-os-x/. Go to 'Advanced' and click '-' to remove.
* https://forums.macrumors.com/threads/my-macbook-wont-connect-automatically-to-my-wifi-network-now-that-it-has-lion.1210649/


== macOS wants to use the "login" keychain ==
If you use the '''open''' command in a terminal to open a text file, the default program will be used.
It asks me to enter my keychain password where I have my PIV card inserted. I need to enter my PIN not password.


I need to enter my PIN (PIV card is connected) for wifi to connect to office network.
== Replace nano editor ==
The default nano editor is too old (2.0.6). It is located at /usr/bin folder.


== Scopedbookmarkagent wants to use keychain ==
Using homebrew ('''brew install nano''') we can update it to the latest version. The new nano is located at /usr/local/bin/ folder.
I need to enter my PIN (PIV card is connected) for wifi to connect to office network.


== List DNS servers ==
Note that '''echo $PATH''' shows '''/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Tex/texbin:/opt/X11/bin'''.
[https://superuser.com/questions/258151/how-do-i-check-what-dns-server-im-using-on-mac-os-x How do I check what DNS server I'm using (on Mac OS X)]
<pre>
$ scutil --dns | grep 'nameserver\[[0-9]*\]'
</pre>
To change the DNS settings, follow [https://www.safervpn.com/support/articles/115000327609-Change-DNS-Settings-on-Windows-Mac-Android-IOS-Linux#E.%20Linux%20(Ubuntu) this].


== [http://smallbusiness.chron.com/keep-ipad-dropping-wifi-signals-49630.html How to Keep an iPad From Dropping Wi-Fi Signals] ==
<syntaxhighlight lang='bash'>
Renew the iPad's DHCP lease.
$ which nano
/usr/local/bin/nano
$ whereis nano
/usr/bin/nano
$ nano --version      # Still 2.0.6
# Close the terminal and open a new one
$ nano --version      # 4.2
</syntaxhighlight>


Change the channel on your wireless channel ([http://macintoshhowto.com/networking/how-to-get-a-good-range-on-your-wireless-network.html pick the channel has the lowest signals]).
== [https://atom.io/ Atom] editor from Github ==
 
Complains: too frequent updates. It makes multiple instances on the right click menu in '''Finder''' on '''macOS''' (seems it is only a problem on Mac). See a report [https://github.com/atom/atom/issues/11047 here]. A solution is
== PS1 ==
If I give '''PS1="\[\w$ "'''
it will change my prompt from
<pre>
<pre>
NCI-12345678-ML:bdge USERNAME$
rm -rf ~/Library/Caches/com.github.atom.ShipIt
killall Finder
</pre>
</pre>
to
and then launch Finder manually.
<pre>
~/github/bdge$
</pre>
where the new one is probably better. We can replace '''\w''' with '''\W''' to get the directory basename instead of the full path.


The default '''PS1='\h:\W \u\$ '''' is defined in '''/etc/bashrc'''.
[http://flight-manual.atom.io/ Atom Flight Manual]


My El Capitan, I need to create a new file '''~/.profile''' (not in ~/.bash_profile) and put the command there.
* The atom application requires no installation. So once it is downloaded (we actually download a zip file. After download has finished Safari browser will automatically decompress the zip file), we can drag it to the Application folder.
<pre>
* [https://stackoverflow.com/questions/22390709/how-to-open-atom-editor-from-command-line-in-os-x Open atom from a terminal].
export PS1="\w (\!)\$ "
Method 1 (GUI). Atom -> Install Shell Commands. Two symbolic links ('''atom''' and '''apm''') will be created in /usr/local/bin to point to the currently opened Atom application.
</pre>


See
Method 2 (Manual):
* [https://opensource.com/article/17/7/bash-prompt-tips-and-tricks Bash prompt tips and tricks]
<syntaxhighlight lang='bash'>
* https://www.askdavetaylor.com/how_to_set_linux_mac_terminal_shell_ps1_prompt/
ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom
* [https://superuser.com/questions/147043/where-to-find-the-bashrc-file-on-mac-os-x-snow-leopard-and-lion Where to find the .bashrc file on Mac OS X]
</syntaxhighlight>
* When you open the Atom the first time, it will split the screen into two '''panes''': [http://flight-manual.atom.io/getting-started/sections/atom-basics/ on the LHS it has a 'Welcome' and on the RHS it has a 'Welcome Guide']. You can choose to close any one of them by View -> Panes -> Close Pane. You may reopen the Welcome Guide by Help -> Welcome Guide. 
* You can hide the directory on the left hand side by View -> Toggle Tree View.
* Command Palette: Press Cmd+Shift+P.  
** You can search by any keyword to find the keyboard shortcut.
** You can use it to [http://flight-manual.atom.io/getting-started/sections/installing-atom/ install the terminal commands '''atom''' and '''apm'''] if they were not installed during installing Atom.
* Settings: Atom -> Preferences.
* Open a file: Cmd+o. Save a file: Cmd+s.
* If a file is modified and not saved yet, the changes are saved to a cache. Even we close Atom, the changes are there. The original file is still intact.
* Open a directory as a project. Open a folder will add a tree view to the editor where you can browse all the files. You can toggle the tree view on the side of the window by Cmd+\.
* Jump to a specific line: Ctrl+g.
* Find and replace: Cmd+f. To search the whole project, Cmd+Shift+f.
* Folding: Alt+Cmd+[ and Alt+Cmd+]
* '''Panes''' splitting: Cmd+K Up/Down/Left/Right
* Preview a markdown file (toggle): Ctrl+Shift+M
* [https://discuss.atom.io/t/syntax-highlighting-for-r-language/12508/4 R syntax highlight]
<syntaxhighlight lang='bash'>
$ apm install language-r
Installing language-r to /Users/USERNAME/.atom/packages ✓
# Re-start Atom to enable it
</syntaxhighlight>
 
Printing. No way!


== app Store ==
== Visual Studio Code ==
* Need a credit card information. The [https://support.apple.com/en-us/HT204034 'None' option] is not available. [https://www.labnol.org/software/apple-id-without-credit-card/19299/ Some tricks].
[https://stackoverflow.com/a/29966094 VS code is based on Electron and Atom shell archive].  
* Cannot log in my account. [https://discussions.apple.com/thread/5476482?start=0&tstart=0 Activity clock just keeps spinning and spinning]
[https://apple.stackexchange.com/a/271123 Repeatedly "trying to add a new helper tool" on each restart for same application(s)].
* If macOS has been downloaded, the 'Download' button will be changed to 'Open' button in 'App Store' application.
 
* If my macOS is already Sierra, we don't need to sign into 'App Store' in order to download a newer version Sierra image.
== [http://macdown.uranusjr.com/ Macdown]- markdown editor ==
If I use macDown to open a text file, macDown will still assume the file is a markdown file and give a preview on the right panel.


== Upgrading to macOS Sierra (nee OSX) for R users ==
== Sublime ==
http://www.win-vector.com/blog/2017/01/upgrading-to-macos-sierra-nee-osx-for-r-users/  
http://www.sublimetext.com/


== Access the Root Directory ==
[https://stackoverflow.com/questions/9961350/in-sublime-text-2-how-do-i-open-new-files-in-a-new-tab How do I open new files in a new tab?]
http://osxdaily.com/2013/01/17/access-root-directory-mac-os-x/


== Disable update notification ==
== [http://macromates.com/download TextMate] ==
http://news.softpedia.com/news/how-to-disable-os-x-update-notifications-493961.shtml
http://lifehacker.com/5817833/the-best-programming-text-editor-for-mac


== How to download macOS update using the terminal ==
For some reason when I open an old file, TextMate does not open it on a new tab; it opened the file in a new window??
https://www.howtogeek.com/347920/how-to-download-macos-updates-using-the-terminal/


== Console/All Messages ==
== BBEdit ==
This is like the system log application in Linux/
[http://ccc.technews.tw/2019/04/08/bbedit-return-mac-app-store/ 5 年過去了,知名文字檔編輯軟體 BBEdit 回歸 Mac App Store]


* [https://support.omnigroup.com/console-osx/ Retrieving Console logs on Mac]
== gedit ==
* [https://www.macobserver.com/tmo/article/mac_os_x_using_console_to_troubleshoot_problems Using Console to Troubleshoot Problems]
http://macappstore.org/gedit/ Does not work. I got the same error.


== Does not sleep when the lid is closed ==
= Jekyll =
* [https://alvinalexander.com/macos/why-is-macbook-warm-when-lid-closed-sleep-mode Why is my MacBook warm when the lid is closed (in sleep mode)?]
http://idratherbewriting.com/documentation-theme-jekyll/mydoc_install_jekyll_on_mac.html
<pre>
 
$ syslog | grep 'Wake reason' | grep 'Mar 22'
= Text to speech =
...  processWakeReason Wake reason: Host (0x01)
* In Chrome/Safari select a paragraph and right click -> Speech -> Start speaking.
...  Wake reason: ?
* [https://nosrac.github.io/Dictater/ Dictater]
...  processWakeReason Wake reason: Host (0x01)
* [http://osxdaily.com/2010/03/28/how-to-make-your-mac-talk-text-to-speech/ How to Make a Mac Talk: Text to Speech]
...  Wake reason: RTC (Alarm)
 
...  processWakeReason Wake reason: Host (0x01)
= Dictionary =
...  Wake reason: EC.LidOpen (User)
[https://www.makeuseof.com/tag/easily-expanding-apple-dictionary-mac-only/ Expand Your Mac’s Dictionary App by Adding Additional Languages]
 
I add 'Simplified Chinese - English' dictionary and move it to the top. With the change, when I right click a word and choose 'Look Up' in a browser, the 'Simplified Chinese -English' will be shown up on top.


$ pmset -g assertions
= Videos =
2018-03-22 19:45:03 -0400
[https://www.tekrevue.com/tip/trim-videos-quick-look-mojave/ How to Trim Videos with Quick Look in macOS Mojave]
Assertion status system-wide:
  BackgroundTask                0
  ApplePushServiceTask          0
  UserIsActive                  1
  PreventUserIdleDisplaySleep    0
  PreventSystemSleep            0
  ExternalMedia                  0
  PreventUserIdleSystemSleep    1
  NetworkClientActive            0
Listed by owning process:
  pid 120(hidd): [0x00050da000090379] 00:16:13 UserIsActive named: "com.apple.iohideventsystem.queue.tickle"
Timeout will fire in 1189 secs Action=TimeoutActionRelease
  pid 2903(RStudio): [0x0004b27a000124c2] 08:02:10 PreventUserIdleSystemSleep named: "R Computation"
  pid 2903(RStudio): [0x0004b27a000124ba] 08:02:10 PreventUserIdleSystemSleep named: "R Computation"
No kernel assertions.
Idle sleep preventers: IODisplayWrangler
</pre>
* It seems mac wakes up every 2 hours according to the syslog output. [https://forums.macrumors.com/threads/wake-reason-rtc-alarm-how-to-deactivate.1766477/ This issue is indeed caused by the discoveryd process].
* It may be useful to run ping from another machine to see if Mac is still connected to the internet (cannot check if it is live)
* Since when I wake up the machine the next morning, the internet is not connected, it may be useful to send emails in a regular time interval to see how long the machine still is connected to the internet.
* Battery life went down from 98% to 88% the next day morning even I put the machine to sleep in the afternoon before I left.
* [https://www.tonymacx86.com/threads/wake-reason-rtc-alarm-4530s-waking-alone-from-sleep.48520/ Turn Off in Power management "Wake up by Wifi"]
* [https://apple.stackexchange.com/questions/234351/imac-randomly-wakes-up-from-sleep/234679 iMac randomly wakes up from sleep]. In my case, I see '''Rstudio''' and '''hidd''' processes show 'Yes'.


== Prevent ssh from sleep ==
== imovie ==
http://osxdaily.com/2011/03/21/temporarily-prevent-a-mac-from-sleeping/
* https://www.apple.com/imovie/
<pre>
* From support.apple.com
pmset noidle
** [https://support.apple.com/en-us/HT203049 Move your iMovie for Mac library]. Just copy "~/Movies/iMovie\ Library.imovielibrary/" folder to a USB drive.
</pre>
** [https://support.apple.com/kb/PH22822?viewlocale=en_US&locale=en_US iMovie for Mac: Work with multiple libraries]
* [https://www.beingtechsavvy.com/copy-or-move-imovie-libaray-files-external-hard-disk/17917 How to Copy or Move iMovie Projects to an External Hard Disk?]
* [https://howchoo.com/g/njm4ywnmzjn/how-to-copy-or-move-an-imovie-project-to-another-library How to copy or move an iMovie project to another library]


This method does not prevent Mac from displaying screensaver & locking the screen. But it seems to fix the problem of broken pipe in ssh connection.
== Final Cut Pro ==
* https://www.apple.com/final-cut-pro/
* [https://youtu.be/dU2RXL_LfqA?t=184 How I make my videos] by FlemingYachts


A better way is to modify '''.ssh/config''' file. See [[Linux#Way_to_avoid_ssh_connection_timeout|Way to prevent ssh connection timeout]].
= Java =
[https://solarianprogrammer.com/2018/09/28/installing-openjdk-macos/ Installing OpenJDK 11 on macOS Mojave]. The instruction works for Java 12.
<syntaxhighlight lang='bash'>
ls /Library/Java/JavaVirtualMachines/ # empty but the folder does exist
sudo mv jdk-12.0.1.jdk /Library/Java/JavaVirtualMachines/
java -version
javac -version
cat > hello.java <<EOF
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
EOF
javac hello.java
java HelloWorld
</syntaxhighlight>


== How to Configure a Proxy Server ==
= Printer =
https://www.howtogeek.com/293444/how-to-configure-a-proxy-server-on-a-mac/
To print a test page: Mac -> System Preferences > Printers and Scanners. Double click a printer, go to the menu on top and select Print -> Print Test Page.


== Open a chm file ==
When installing an office printer (\\nciprint\5W012CAN5560, Canon iR-ADV C5550/5560 UFR II), mac asks for the driver (1. Generic PostScript Printer 2. Generic PCL Printer 3. Select Software). If I choose Generic PostScript Printer, the test page shows the driver name "Generic.ppd" and version 1.0. When I download the driver from [https://www.usa.canon.com/internet/portal/us/home/support/details/copiers-mfps-fax-machines/multifunction-copiers/imagerunner-advance-c5560i Canon] website and add the printer using the new driver, the test print page shows driver name CNPZUIRAC5550ZU.ppd.
[http://download.cnet.com/iChm/3000-2094_4-10878883.html iChm] program works fine. Chmox is too old (power pc) and not works.


[https://itunes.apple.com/us/app/chm-reader/id424182884?mt=12 CHM Reader] from Mac App Store is not different from iChm.
= PDF =
== Disable autosave ==
[https://apple.stackexchange.com/a/214625 Open System Preferences, Go to "General", Enable "Ask to keep changes when closing documents"]


== Back up ==
== Markup toolbar ==
* [https://www.howtogeek.com/305540/how-to-encrypt-your-macs-time-machine-backup/ How to Encrypt Your Mac’s Time Machine Backup]
[https://youtu.be/vOKx-p048F0?t=161 How to Circle or Highlight Items with Preview on Mac] (video).
* [https://www.howtogeek.com/347166/how-to-back-up-your-mac-to-your-synology-nas/ How to Back Up Your Mac to Your Synology NAS]
* [https://www.howtogeek.com/399058/how-to-make-a-bootable-clone-of-your-macs-hard-drive/ How to Make a Bootable Clone of Your Mac’s Hard Drive]


== Record sound ==
== Preview Cant Open Multiple PDF in same Window ==
Use 'QuickTime player'.  
https://apple.stackexchange.com/a/303731  System Preferences > (Select) Dock > (Go down to 5th option) Prefer open tabs when opening documents: > (Select from option menu) Always.


The build-in microphone is located inside the left speaker. The recording sound is weak. Go to System Preferences -> Sound. Select 'Input' tab and increase the 'input volume' from the smallest to the loudest.
[https://osxdaily.com/2017/10/24/set-apps-prefer-tabs-mac/ How to Set All Mac Apps to Prefer Tabs with New Document and Windows]


If we want to use an external mic, make sure the [https://youtu.be/oaiYc9Cqpis headphone connector has 4 sections].
== Print to PDF from the print dialog ==
In the Print dialog, look for the “PDF” button in the lower left corner, click on that pull-down menu, and select “Save as PDF”. Click “Save” in the save dialogue box, and save the file to whatever location you want.


== XXX can't be opened because it is from an unidentified developer ==
== Command line to print a file to pdf ==
* http://osxdaily.com/2012/07/27/app-cant-be-opened-because-it-is-from-an-unidentified-developer/
* https://apple.stackexchange.com/questions/273758/is-there-a-simple-way-to-convert-a-unicode-text-file-to-pdf-on-the-command-line
* Enroll in the [https://developer.apple.com/programs/ Apple's OS X developer program]. The yearly fee is [https://developer.apple.com/programs/enroll/ $99].  https://forum.qt.io/topic/38876/solved-running-app-on-mac-osx-app-structure/5
<pre>
# Suppose we have an R file. We like to print it to PDF with line numbers.
$ cat -n tmp.R > tmp.txt
$ cupsfilter tmp.txt > tmp.pdf


== /private/var/folders ==
# OK. But how to control the font size? How to deal with indentation for line wrapping. Landscape orientation.
https://discussions.apple.com/thread/1933443?start=0&tstart=0
</pre>
* [http://www.eprg.org/pdfcorner/text2pdf/ text2pdf]
* Use pandoc to convert it to docx (so we can control font size) and convert it again to PDF.


If SeqTools was downloaded through a browser, then when we launch it the R script folder in <run_variantannose.sh> becomes something like  ''/private/var/folders/1h/kcm8vkdx6nl00z5wjm5bqlw00000gp/T/AppTranslocation/051E078E-7C2D-4C6C-90FF-F651985EC9C0/d/SeqTools.app/Contents/MacOS/SeqTools/code''
== Convert a pptx to pdf ==
The 'Zoom' function is kind of slow to response with Office 2016. There is no this problem with converted PDF file.


== Extreme NAC Assessment Agent ==
* Use 'Save As...'
https://isdp.nih.gov/isdp/version.action?prodid=220
* Don't use print to PDF. The quality will reduced.


'Please enter the host name or IP address of the Extreme NAC Assessment Agent server' 137.187.64.22.
== Delete/add/reorder page pages using Preview ==
http://osxdaily.com/2010/01/20/delete-pages-in-a-pdf-document/


== Which Processes Can You Safely Quit in Activity Monitor on a Mac ==
There is no need to save the document. It will be saved automatically.
[https://www.howtogeek.com/406573/which-processes-in-activity-monitor-can-you-safely-quit/ Which Processes Can You Safely Quit in Activity Monitor on a Mac?]


== Command line to find the IP address ==
For some reason, after I join pdf files and export the merged pdf, the exported file contains only 1 page.
'''ipconfig getifaddr en0'''  # it will return XX.XXX.XX.XXX


Or use '''ifconfig''' to show all of the interfaces and their IPs.
A more reliable way is to use a built-in [https://apple.stackexchange.com/questions/230437/how-can-i-combine-multiple-pdfs-using-the-command-line command line program 'join.py'] (works on OS X El Capitan)
<syntaxhighlight lang='bash'>
# Use Cmd + c to copy PDF files relative paths from /home/$USER/Downloads directory


== Uninstall inSync ==
cd /User/$USER/Downloads/
https://www.insynchq.com/uninstall
"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" \
  -o FILE.pdf \
  file1.pdf file2.pdf /PATH/TO/A/WHOLE/DIR/*.pdf
</syntaxhighlight>


== Use AirDrop to share files between Macs and iOS devices ==
== Print multiple pages per sheet ==
[https://www.howtogeek.com/342810/how-to-add-an-airdrop-icon-to-your-macos-dock/ How to Add an AirDrop Icon to Your macOS Dock]
"Preview" does not have this option. Use [https://www.wikihow.com/Print-Multiple-Pages-Per-Sheet-in-Adobe-Reader Adobe Reader].
== Merge/combine several PDF files ==
[https://www.tekrevue.com/tip/combine-pdfs-mac-quick-actions/ How to Use Mojave’s Quick Actions to Quickly Combine PDFs on the Mac]


== How to Transfer Files From PC to iPhone and iPad (And Vice Versa) ==
== Crop pdf files ==
[https://www.makeuseof.com/tag/transfer-files-wirelessly-computers-ios-devices-fileapp/ How to Transfer Files From PC to iPhone and iPad (And Vice Versa)], [https://itunes.apple.com/us/app/fileapp-file-manager/id297804694?mt=8 FileApp]
Preview. See a demonstration on [https://youtu.be/mneEdGBEs5o youtube]. This is very good and the crop experience is similar to [https://sourceforge.net/projects/briss/ briss].


== Share Files Between Mac & Windows Computers  ==
# View → Thumbnails
[https://www.makeuseof.com/tag/how-to-easily-share-files-across-mac-windows-computers/ Share files on your Mac so that it appears on Windows computers automatically.]
# Select all pages by Cmd+a. Use Cmd+click to unselect any pages.
 
# Click the '''Show Markup Toolbar''' button from the RHS of the toolbar and click the '''Rectangular Selection''' button or directly click on Tools → Rectangular Selection
== Share Files Between iOS and Mac  ==
# Use mouse to select an area on the first page (or on a specific page). A rectangular area will show up on ALL pages.
[https://www.makeuseof.com/tag/what-is-airdrop/ What Is Airdrop? How to Share Files Between iOS and Mac]
# Adjust the width/height as you want from the 1st page (or from the specific page).
 
# Close the document and the changes will be automatically saved.
== Digital color meter ==
[https://www.techrepublic.com/blog/apple-in-the-enterprise/discover-the-digitalcolor-meter-tool-on-your-mac/ Discover the DigitalColor Meter tool on your Mac] Very useful when you want to know the color's RGB value from any dot on your screen.


== Notes folder ==
Note that this method cannot save the cropped PDF file permanently. A better way is to use [https://sourceforge.net/projects/briss/ briss]. After we install Java runtime library (see [[#Java here]]), we can run briss from a terminal
[https://apple.stackexchange.com/questions/111633/where-do-my-notes-written-in-the-notes-application-on-my-mac-get-saved  Where do my notes written in the Notes application on my Mac get saved?]
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
$ ls ~/Library/Group\ Containers/group.com.apple.notes/
java -jar briss-0.9.jar
Library NoteStore.sqlite NoteStore.sqlite-shm NoteStore.sqlite-wal
</syntaxhighlight>
</syntaxhighlight>


The data can be synchronized through iCloud. [https://www.payetteforward.com/how-sync-iphone-notes-mac-pc-computer-fix/ How Do I Sync My iPhone Notes With Mac Or PC?].
== Undo cropping of pdf files ==
[https://discussions.apple.com/thread/3461580 How do I uncrop a PDF in Preview?] Zoom out so you can have what would be the whole page in view. Use the selection tool to select an area at least as big as the original page. Recrop the image to the new selection, and voilà!


== PIV card ==
== Edit (eg highlight) by Preview ==
* Open '''Keychain Access'''. It should show up "PIV-USER NAME-A" on the first item.
* [https://www.imore.com/how-use-preview-mac How to use Preview on Mac] highlight/underline/strike through (a highlighter icon), crop, add signature. To remove highlights, highlight a selection and right click -> choose "Remove Highlight".
* Change browsers (Chrome -> Safari). Firefox does not help.
* [https://support.apple.com/guide/preview/highlight-underline-and-strike-out-text-prvw757d4d5b/mac Highlight, underline, and strike out text in a PDF using Preview on Mac]. To turn off highlighting, click the highlight tool again.
* [[Javascript#Reload_Javascript_in_browser.2FEmpty_Cache|Empty Cache]] in Chrome
* [https://support.apple.com/en-us/HT201740 Use the Preview app to view and edit images and PDFs]
* Incognito mode (not help)
* Reboot
* Change PIC card reader (new one uses less power)


= Git GUI Client =
== Search woe in Preview ==
https://git-scm.com/download/gui/mac
It seems enclosing the phrase in quotation marks does not work. But clicking the '''magnifying glass icon''' in the search field and selecting “Exact Phrase” from the drop-down menu.


== SourceTree ==
== Preview Keyboard shortcuts  ==
[https://www.sourcetreeapp.com/ sourcetree]. See also [https://www.rstudio.com/resources/videos/happy-git-and-gihub-for-the-user-tutorial/ Happy Git and Gihub for the useR] from Jenny Bryan.
* Hide sidebar: CMD + Option +1
* Show sidebar: CMD + Option +2
* Show Table of Contents: CMD + Option +3
 
== Kill Preview ==
Using the command line: '''killall Preview'''


Unfortunately it requires a Bitbucket account in order to finish its installation.
== Open Preview ==
It seems Preview will remember closed documents after close and re-open.


== Github Desktop ==
== The volume can't be ejected because it's currently in use ==
Looks good. It is OK to bypass to login a Github account in the installation process.  
[https://mycyberuniverse.com/macos/how-fix-volume-cant-be-ejected-because-currently-use.html How to fix].  
<pre>
sudo lsof | grep /Volumes/Elements
sudo killall mds
diskutil unmount /Volumes/Elements
</pre>


= Useful Apps =
== Icon/symbol next to opened documents under 'Window' menu ==
[https://www.makeuseof.com/tag/ultimate-list-mac-menu-bar-apps/ The Ultimate List of Mac Menu Bar Apps]
https://developer.apple.com/design/human-interface-guidelines/macos/menus/menu-anatomy/


== [https://itunes.apple.com/app/amphetamine/id937984704?mt=12 Amphetamine]: keeps your Mac awake (not sleep) ==
* Checkmark: the active document
Caffeine is too old. [https://github.com/newmarcel/KeepingYouAwake KeepingYouAwake] is a small menu bar utility that is inspired by Caffeine from Lighthead Software. The app is a small wrapper around Apple's caffeinate command line utility.
* Diamond: document that is currently minimized in the Dock.


See a [http://muggingsg.com/study-tools/amphetamine-keeps-your-mac-screen-alive-while-studying/ review] of Amphetamine and one from [https://lifehacker.com/macos-app-of-the-week-amphetamine-1825108890 lifehacker].
= Disk =
== Trash can ==
See its icon in the Dock.


[https://itunes.apple.com/uz/app/lungo/id1263070803?mt=12 Lungo] is another one (paid) and it requires macOS 10.13.
[http://www.dummies.com/computers/macs/mac-operating-systems/using-the-trash-folder-in-mac-os-x-lion/ Using the trash folder]


== Take a break ==
== Alternative to WinDirStat ==
[https://www.techrepublic.com/blog/five-apps/five-free-apps-to-help-remind-you-to-take-a-break/ Five free apps to help remind you to take a break].  
https://alternativeto.net/software/windirstat/?license=free&platform=mac
* Time Out looks cool. Some features like put the app in the menu bar are available for supporters:(
 
* Break Timer, memory leak?
* ncdu
* [https://github.com/hovancik/stretchly/ Stretchly]
<pre>
brew install ncdu
</pre>
* [http://www.derlien.com/ Disk Inventory X]. It shows the sizes of files and folders in a special graphical way called "treemaps". The filename is ''DIX1.0Universal.dmg''. It froze my Mac:(
* [https://github.com/shundhammer/qdirstat QDirStat] based on Qt. No binary for macOS
* [https://daisydiskapp.com/ DaisyDisk] $10.
 
== system taking too much space ==
It takes over 327GB on my macbook pro. I run '''sudo mdutil -E /''', change spotlight search categories to only 'Applications', 'Mail & Messages' and reboot the computer. Now the system is taking only 83GB (more acceptable). Some cleanup software does little help and ncdu command broke during scanning the root directory.
 
* https://discussions.apple.com/thread/7683120
* [https://forums.macrumors.com/threads/system-taking-alot-of-space.2015434/ reindex Spotlight] '''sudo mdutil -E /'''
* [https://discussions.apple.com/thread/5595772 mds_stores] process and [https://discussions.apple.com/thread/8510132 mdworker_share] process
 
== Outlook took too much space ==
[https://answers.microsoft.com/en-us/msoffice/forum/all/message-attachments-in-outlook-2016-for-mac/ab37e5c6-9ed9-4e56-b787-492cb47a26f2 Message Attachments in Outlook 2016 for Mac]
 
I found out the issue when Druva inSync needs to sync 3.8GB data. Further investigation shows it is backing up lots of files under ~/Library in Home Folder. '''ncdu''' shows the folder "~/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/Message Attachments" took 9.3GB space.
 
== Increase space ==
[https://www.howtogeek.com/437850/how-to-increase-your-macbooks-storage/ How to Increase Your MacBook’s Storage]


== My installed apps ==
== Clean Drive from Parallels ==
* iTerm2
https://kb.parallels.com/en/124591
* RStudio, R
 
* Amphetamine
= Browsers =
* Anaconda-Navigator
* [https://www.makeuseof.com/fastest-browser-on-a-mac/ What Is the Fastest Browser to Use on a Mac?]
* Firefox
* '''Brave''' or '''Opera''' can block youtube ads (normal or private mode)
* Flux
* Safari, Firefox Focus, Edge, DuckDuckgo, Aloha browsers cannot block youtube ads
* Lightshot Screenshot
* Meld
* Paintbrush
* Stretchly
* The Unarchiver
* VirtualBox
* VLC
* Xcode
* SourceTree
* Atom
* Visual Studio Code
* [https://github.com/kamranahmedse/pennywise Pennywise]. Cross-platform application to open any website or media in a floating window .
* XQuartz (R does not need it; R uses [https://en.wikipedia.org/wiki/Quartz_(graphics_layer) Quartz] for plotting).
** However when I try to install tinytex package, it complains unable to load shared object '/Library/Frame/R.framework/Resources/modules//R_X11.so'. It seems to be related to missing XQuartz. See the discussion [https://stackoverflow.com/a/26490114 here]. [http://osxdaily.com/2012/12/02/x11-mac-os-x-xquartz/ Run X11 in Mac OS X with XQuartz].
** Another case is when I try to use svg() to save an image. It shows "Unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so'".
** Another case is edit() won't work with data frame.
** You will need to log out and log back in to make XQuartz your default X11 server.
* Stopwatch & Timer
* Qt Creator
* Chargeberry


= Missing Linux commands =
= Google Chrome browser =
== wget ==
* https://en.wikipedia.org/wiki/Google_Chrome and [https://chromereleases.googleblog.com/search/label/Stable%20updates Chrome stable updates]
Method 1: [http://rudix.org/packages/wget.html Rudix]
* [https://www.whatismybrowser.com/guides/the-latest-version/chrome What's the latest version of Chrome?]
<syntaxhighlight lang='bash'>
curl -O https://raw.githubusercontent.com/rudix-mac/rpm/2016.12.13/rudix.py
python rudix.py install rudix
sudo rudix install wget
which wget
# /usr/local/bin/wget


$ wget https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
== Read articles ==
--2017-02-26 08:41:09--  https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
[https://9to5google.com/2020/09/16/google-ios-read-articles/ Google app for iOS can now read articles aloud with a tap].
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.192.133, 151.101.128.133, 151.101.0.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.192.133|:443... connected.
ERROR: cannot verify raw.githubusercontent.com's certificate, issued by ‘CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’:
  Unable to locally verify the issuer's authority.
To connect to raw.githubusercontent.com insecurely, use `--no-check-certificate'.
$ wget https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh --no-check-certificate
--2017-02-26 08:41:26--  https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.192.133, 151.101.128.133, 151.101.0.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.192.133|:443... connected.
WARNING: cannot verify raw.githubusercontent.com's certificate, issued by ‘CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’:
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 200 OK
Length: 8502 (8.3K) [text/plain]
Saving to: ‘install_rnaseq.sh’


install_rnaseq.sh                        100%[===============================================================================>]  8.30K  --.-KB/s    in 0.001s 
For Android users which was powered by Google Assistant, simply asking “Hey Google, read this article (page)” would pull the content of the page into a new interface that plays it word-by-word.


2017-02-26 08:41:26 (15.7 MB/s) - ‘install_rnaseq.sh’ saved [8502/8502]
[https://support.google.com/assistant/answer/9795643?co=GENIE.Platform%3DAndroid&hl=en Fix issues with "Hey Google" on a mobile device]
</syntaxhighlight>


Method 2: [http://stackoverflow.com/questions/33886917/how-to-install-wget-in-macos-capitan-sierra homebrew]
= Safari =
<syntaxhighlight lang='bash'>
* [https://www.howtogeek.com/368817/how-to-view-websites-on-mac-that-require-internet-explorer-or-a-pc/ How to View Websites on Mac that Require Internet Explorer/Edge (or a PC)]
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
* [https://www.howtogeek.com/702305/how-to-install-safari-extensions-on-mac/ How to Install Safari Extensions on Mac]
brew install wget --with-libressl
* [https://www.howtogeek.com/757666/how-to-install-and-use-safari-extensions-on-iphone-and-ipad/ How to Install and Use Safari Extensions on iPhone and iPad]
</syntaxhighlight>
* [https://www.howtogeek.com/704177/how-to-check-which-websites-are-tracking-you-on-safari/ How to Check Which Websites Are Tracking You on Safari]


Method 3: Build from [http://osxdaily.com/2012/05/22/install-wget-mac-os-x/ source] (require Xcode, works on my OS X 10.12 Sierra w/ Xcode 8.2.1)
= Read out loud =
<syntaxhighlight lang='bash'>
[https://www.makeuseof.com/how-to-use-spoken-content-mac/ How to Use Spoken Content to Make Your Mac Read Out Loud to You]
xcode-select --install
cd ~/Downloads


curl -O https://www.openssl.org/source/openssl-1.0.2h.tar.gz
= Developer =
tar xzvf openssl-1.0.2h.tar.gz
Macs (unlike Linux) don’t come with a package manager, but there are a couple of popular package managers you can install. See [http://www.scipy.org/install.html SciPy].
cd openssl-1.0.2h
./configure darwin64-x86_64-cc
make
sudo make install


curl -O http://ftp.gnu.org/gnu/wget/wget-1.18.tar.gz # version 1.19 won't work at the 'make' step
== Install [https://developer.apple.com/xcode/ Xcode] ==
tar -zxvf wget-1.18.tar.gz
http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/
cd wget-1.15/
./configure –with-ssl=openssl –with-libssl-prefix=/usr/local/ssl
make
sudo make install
</syntaxhighlight>


For some reason, when I use wget to download files from https server, I will get a message: '''ERROR: cannot verify site certificate. Unable to locally verify the issuer’s authority'''.  See
Note:  
* http://thenubbyadmin.com/2014/01/29/solving-wget-error-cannot-verify-site-certificate-unable-to-locally-verify-the-issuers-authority/
* Download directly from https://developer.apple.com/download/more/ (log in required)
* https://finkers.wordpress.com/2009/10/06/wget-and-https/  (fink solution)
* [https://mac.r-project.org/tools/ Compile R for macOS]
* http://stackoverflow.com/questions/9224298/how-do-i-fix-certificate-errors-when-running-wget-on-an-https-url-in-cygwin (cygwin solution)
* It seems there is no way to run this automatically without the alert box. Users need to [https://www.maketecheasier.com/install-command-line-tools-without-xcode/ agree the license].
* http://stackoverflow.com/questions/30105376/error-cannot-verify-www-youtube-coms-certificate-with-wget-http-www-yout (brew has the same problem)
 
== watch ==
http://stackoverflow.com/questions/9574089/osx-bash-watch-command
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
while :; do clear; your_command; sleep 2; done
xcode-select --install
</syntaxhighlight>
</syntaxhighlight>
The installed tools (like ar, gcc, g++, git, libtool, make, nm, otool, svn, et al) are located in '''/Library/Developer/CommandLineTools/usr/bin/''' directory. If the command is run again, you will get a message
<pre>
xcode-select: error: command line tools are already installed, use "Software update" to install updates
</pre>


== top command ==
To check the Xcode version (if you have installed a ''full'' Xcode)
To sort by CPU
<syntaxhighlight lang='bash'>
<pre>
$ xcodebuild -version  # if you have the full Xcode installed
top -u
Xcode 8.2.1
</pre>
Build version 8C1002  # if you only have the command line tool installed
$ xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer
directory '/Library/Developer/CommandLineTools' is a command line tool instance
</syntaxhighlight>


To sort by Memory
To check whether Xcode has been installed
<pre>
<syntaxhighlight lang='bash'>
top -o mem
$ xcode-select -p
</pre>
/Library/Developer/CommandLineTools            # if you have installed the command line tool only
# or
/Applications/Xcode.app/Contents/Developer  # if you have the full Xcode package installed
# or
xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one
(or see `man xcode-select`)
</syntaxhighlight>


== htop ==
To accept the XCode license through command line, follow the post [https://klue.github.io/blog/2017/04/macos_kernel_debugging_vbox/ Debugging macOS Kernel using VirtualBox]:
http://unix.stackexchange.com/questions/98253/how-do-i-install-htop-inside-mac-os-x
<syntaxhighlight lang='bash'>
$ sudo xcodebuild -license accept # it seems not working. A dialog is still popped up.
</syntaxhighlight>


It seems the result is not accurate. For example when the fan is working (esets_daemon is running), htop does not show much CPU from eset_daemon but Activity Monitor shows esets_daemon is on the top cpu usage list.
The '''df''' command shows installing the command line developer tools takes about 600MB space.


== md5sum ==
== git ==
It is called '''md5''' instead of md5sum in Linux.
[https://stackoverflow.com/q/59080773 The "git" command requires the command line developer tools. Would you like to install?] I got this message when I open RStudio.


For SHA-1 and SHA-256 use
== Uninstall Xcode ==
<syntaxhighlight lang='bash'>
http://osxdaily.com/2012/02/20/uninstall-xcode/
shasum filename
# OR
shasum -a 1 filename


shasum -a 256 filename
== Header file location ==
</syntaxhighlight>
* /usr/include (does not exist on my 10.12 Sierra)
* /usr/local/include (some are over there; e.g. from "sudo make install" command)
* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/ (if you have installed a full Xcode)


== tar ==
I get the following error
If we run the following command
<pre>
<pre>
tar xzvf filename.tar.gz -C directory 2> error.log
In file included from init.c:1:
</pre>
/Library/Frameworks/R.framework/Resources/include/R.h:55:11: fatal error: 'stdlib.h' file not found
we will get a non-empty file in <error.log> even the extraction is successful.
# include <stdlib.h> /* Not used by R itself, but widely assumed in packages */
 
          ^~~~~~~~~~
Therefore it is better to use the following way
1 error generated.
<pre>
make: *** [init.o] Error 1
tar xzvf filename.tar.gz -C directory
ERROR: compilation failed for package ‘later’
if [ $? -eq 0 ]; then
    echo OK
else
    echo FAIL
fi
</pre>
</pre>
when I install some package. The stdlib.h file is missing from /usr/local/include. However, a simple C code compiles fine.
<syntaxhighlight lang='c'>
#include <stdio.h>
#include <stdlib.h>


== Diff tools ==
int main ()
* [https://www.git-tower.com/blog/diff-tools-mac Diff Tools on macOS]
{
* FileMerge - part of XCode from Apple. Too un-intuitive compared to ''WinMerge'' on Windows or ''Meld'' on Linux:(
  char str[10] = "3.14";
* [https://sourcegear.com/diffmerge/ DiffMerge]. Still not intuitive.
  printf("The value is %f\n",atof(str));
* [https://yousseb.github.io/meld/ Meld for OSX] - BEST!
  return 0;
** Invalid byte sequence in conversion input ??
}
* '''git diff''' will give a colored output on your terminal
</syntaxhighlight>
** Still a command line based
 
** The compared files do not need to be in the local git directory
See this post [https://stat.ethz.ch/pipermail/r-sig-mac/2018-December/012880.html (R-SIG-Mac) 'math.h' file not found]
** Green means the 1st file has more contents
<syntaxhighlight lang='bash'>
** Red means the 2nd file has less contents
sudo installer -pkg \
* Beyond Compare (commercial)
  /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg \
* Araxis Merge (commercial)
  -target /
* DeltaWalker (commercial)
</syntaxhighlight>
* Kaleidoscope (commercial)
However, I don't have "Packages" directory.


== zcat ==
See [https://stackoverflow.com/questions/28362994/where-is-my-stdio-h-in-mac Where is my “stdio.h” in Mac?] & [https://superuser.com/questions/995360/missing-usr-include-in-os-x-el-capitan/1009364 Simply installing Xcode will not install all of the command line developer tools]. Try
macOS always adds .Z to the .gz filename. A more portable solution is to use '''gunzip -c''' such as gunzip -c XXX.gz.  
* Run "sudo ln -sf /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /usr/include". Get a message '' "Operation not permitted". '' See this post [https://apple.stackexchange.com/q/196224 Unix “ln -s” command not permitted in OSX El Capitan Beta3]
* Run "xcode-select --install". Get a message '' "Can't install the software because it is not currently available from the Software Update server." ''


See [https://github.com/dalibo/pgbadger/issues/70 zcat on OS X is running in POSIX mode and will always append .Z to all filenames].
Search within [https://www.google.com/search?source=hp&ei=dfR_XKCwGYmw5wK5xbeoAQ&q=site%3Ahttps%3A%2F%2Fstat.ethz.ch%2Fpipermail%2Fr-sig-mac%2F+stdlib.h&btnK=Google+Search&oq=site%3Ahttps%3A%2F%2Fstat.ethz.ch%2Fpipermail%2Fr-sig-mac%2F+stdlib.h&gs_l=psy-ab.3...1864.7270..7601...0.0..0.52.648.15......0....1j2..gws-wiz.....0..0i131j0j0i131i10.khUOoin_wpw R-SIG-Mac Archives].


= R =
=== System Integrity Protection/SIP  ===
== failed to load cairo DLL ==
* [https://support.apple.com/en-us/HT204899 About System Integrity Protection on your Mac]
I got an error when I use svg() command.
* [https://www.ihash.eu/2015/11/how-to-disableenable-sip-on-mac-os-x-el-capitan/ How To Disable/Enable SIP on Mac OS X 10.11 El Capitan]
<pre>
* [https://stackoverflow.com/questions/53104473/macos-clang-via-homebrew-broken-under-mojave-wchar-h wchar.h not found]. I got the same error when I try to compile buggy.cpp file by following [https://www.bioconductor.org/developers/how-to/c-debugging/ Debugging C/C++ code] on Bioconductor.
svg("~/Downloads/3dPiePlot.svg")
Warning messages:
1: In svg("~/Downloads/3dPiePlot.svg") :
  unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so':
  dlopen(/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so, 6): Library not loaded: /opt/X11/lib/libXrender.1.dylib
  Referenced from: /Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so
  Reason: image not found
2: In svg("~/Downloads/3dPiePlot.svg") : failed to load cairo DLL
</pre>
http://r.789695.n4.nabble.com/Cairo-package-error-quot-unable-to-load-quot-td4694453.html


you don't have X11 installed and it no longer ships with OS X 10.9 - you need to get it from
== Lib location ==
* /usr/lib
* /usr/local/lib
* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib/ (if you have installed a full Xcode)


http://xquartz.macosforge.org
== ldd on Mac ==
<pre>
otool -L  <exec>
</pre>


At the end of installation, it will ask you to log out and log in again to make xquartz a default X11 server.
== openssl ==
 
'''Method 1''': brew
= Tex/Latex =
* https://solitum.net/openssl-os-x-el-capitan-and-brew/
* http://tug.org/mactex/ and http://tug.org/mactex/mactex-download.html
<syntaxhighlight lang='bash'>
* http://mactex-wiki.tug.org/wiki/index.php?title=TeX_Live_Manager
brew doctor
* http://ctan.org/mirrors
brew update
* http://dante.ctan.org/mirmon/
brew upgrade
brew install openssl  # the opposite operation is 'uninstall'
cd /usr/local/include
ln -s ../opt/openssl/include/openssl .
</syntaxhighlight>


== Download failure ==
'''Method 2''': compile yourself
[[File:BasictexErr.png|250px]]
* http://apple.stackexchange.com/questions/221587/how-to-make-a-clean-install-of-openssl-on-el-capitan
* http://mac-dev-env.patrickbougie.com/openssl/


The error seems to be related to a new release (6/7/2017). The download link for basicTex is http://tug.org/cgi-bin/mactex-download/BasicTeX.pkg. It downloaded the file mactex-basictex-20161009.pkg. But the new release is mactex-basictex-20170607.pkg. The download works fine on 6/8/2017.
== Python packages ==
http://www.scipy.org/install.html


http://ctan.org/pkg/mactex-basic website is working fine but the downloaded file name is <BasicTex.pkg> so it is not clear about the release date.
= Install macOS on a PC =
http://www.makeuseof.com/tag/how-to-install-mac-os-x-on-a-pc-without-using-a-mac/ (7/17/2017)


== tlmgr error ==
= KVM =
* https://tex.stackexchange.com/questions/64261/updating-tlmgr-2011-to-2012
* [https://howto.azureedge.net/how-to-run-macos-on-kvm-qemu/ How To run macOS on KVM / QEMU]
* https://tex.stackexchange.com/questions/253599/repository-and-local-installation
* [https://github.com/foxlet/macOS-Simple-KVM macOS-Simple-KVM]
<syntaxhighlight lang='bash'>
$ tlmgr update --self
tlmgr: The Tex Live versions supported by the repository
http://ctan.sharelatex.com/tex-archive/systems/texlive/tlnet
  (2016-2016)
do not include the version of the local installation
  (2017).
</syntaxhighlight>


== Install a new package through tlmgr ==
Docker:
When I try to knitr an R markdown file in RStudio, an error was popped up complaining about missing 'framed.sty' file. The solution is to [https://github.com/rstudio/rmarkdown/issues/378 install the framed package] on macOS or [https://stackoverflow.com/questions/9590134/why-is-knitr-unable-to-find-framed-sty-or-kpsewhich texlive-latex-extra package] on Ubuntu/Debian.
[https://github.com/taylorcoffelt/macos-docker macOS in Docker]
<syntaxhighlight lang='bash'>
sudo tlmgr update --self
sudo tlmgr install framed
</syntaxhighlight>


= Microsoft Outlook =
== UTM ==
== [https://support.office.com/en-us/article/customize-views-in-outlook-for-mac-257d7104-5c90-4ee3-bad2-9935ab424c64?ui=en-US&rs=en-US&ad=US Customize views] ==
[https://www.howtogeek.com/how-to-run-windows-on-your-mac-for-free/ How to Run Windows on Your Mac for Free with UTM]
* Sidebar (from the ''outside'' Menu bar): View > Sidebar
* Organize (from the ''inside'' menu or blue Ribbon): Focused Inbox, Message Preview.


== Import a calendar into Outlook ==
= VirtualBox =
[https://stackoverflow.com/questions/6102956/add-ics-file-to-outlook-2011-mac-as-new-calendar Add ics file to outlook 2011 (Mac) as new calendar]. Drag and drop.
* [https://www.makeuseof.com/tag/macos-windows-10-virtual-machine/ How to Run macOS on Windows 10 in a Virtual Machine ]
* [https://www.wikigain.com/how-to-install-macos-big-sur-on-virtualbox-on-windows-pc/ How to Install macOS Big Sur on VirtualBox on Windows – PC]


== Outlook search is incomplete ==
== Touchpad ==
[https://answers.microsoft.com/en-us/msoffice/forum/all/outlook-for-mac-search-results-are-incomplete/0b547a9a-260e-4299-8d8b-f4296b2f5f18 Issue on Mojave]. Users can should OWA https://outlook.office365.com instead.
The direction of scrolling up and down in guest machine is opposite to the host machine.


== Temp folder ==
== Keyboard shortcuts (macOS + Windows keyboard)==
On my Outlook (365 subscription), it is ''/private/var/folders/2q/slryb0rx4tj97t66v7l6pwvr_z6g3s/T/com.microsoft.Outlook/Outlook\ Temp/''. It is obtained by '''Open''' an attachment and then select & copy a file.
Since there is no Command key on Windows keyboards, we need to modify preferences.  


== Encrypted emails ==
[https://www.howtogeek.com/219156/how-to-remap-your-windows-cutcopypaste-to-os-x-like-controls-and-vice-versa/ Copy and paste]: go to preferences -> keyboard -> Modifier keys. Change 'Option' key to 'Command' key and 'Command' key to 'Option' key. Since the 'Option' key is 'Alt' on Windows keyboards, the layout will be very similar to using Mac keyboards. This is consistent with [https://www.amazon.com/gp/product/B01LZAK8MM/ref=ox_sc_act_title_1 Logitech K780] multi-device keyboard where 'Alt' key shares with the 'Command' key.
Unable to read encrypted emails.


Go to Preferences > Account > Advanced > Security.
Do not use Ctrl to replace Command; you will not able to use the Ctrl key in '''nano''' and you are missing Ctrl + a to move mouse to HOME in Terminals. NOTE: [[#Terminal_replacement|iTerm2]] is a good replacement for macOS's built-in '''Terminal''' program; HOME/END works.
* Digital signing Certificate: XXXX-S
* Encryption Certificate: XXX-E
* Certificate authentication Authentication: XXX-S


Rebooting computer helps.
== Keyboard shortcuts (Windows OS + mac keyboard) ==
* Left CMD is used by VirtualBox to switch to full screen (at least on VirtualBox)
* Right CMD = Windows key
* fn + delete = DEL/Backspace key


To check PIV card is inserted: open the 'Keychain Access' app.
== Guest additions ==
VirtualBox doesn't have guest additions for OSX. http://askubuntu.com/questions/372982/virtualbox-4-3-guest-additions-on-osx-guest


== Save an email ==
In order to share files between the host and guest machine, we need to 1. add 'host-only' network adapter to the guest machine and 2. enable 'Remote Login' by going to the System Preferences -> Sharing.  
The file format is *.eml.


= Apple Server =
For example, from the host machine, I can use the following on the host machine to access the guest machine
* [http://www.apple.com/mac-pro/ Mac Pro] server (up to 64 GB DDR3 memory)
<syntaxhighlight lang='bash'>
* [http://insights.dice.com/2012/12/18/why-apple-will-never-offer-another-server-again/ Why Apple Will Never Offer Another Server Again]
$ ssh brb@brbs-MacBook-Pro.local
== OS Server ==
</syntaxhighlight>
* http://www.apple.com/macos/server/
* https://en.wikipedia.org/wiki/MacOS_Server


= Hackintosh =
However, it is unsuccessfully to do access the host machine from the guest machine??
== How to Triple Boot Your Hackintosh with Windows and Linux ==
<syntaxhighlight lang='bash'>
http://lifehacker.com/5698205/how-to-triple-boot-your-hackintosh-with-windows-and-linux
</syntaxhighlight>


== How To Install macOS Sierra Hackintosh On PC ==
== Smart card reader ==
http://www.redmondpie.com/how-to-install-macos-sierra-hackintosh-on-pc-guide/
If USB is enabled in the guest machine, the Smart Card reader will not be available on the host machine. That is, we cannot use the smart card in Mac. So it is necessary to uncheck the USB from the USB setting in the guest machine.


== Building a GTX 1080 Ti-powered Hackintosh: Installing macOS Sierra step-by-step ==
== Screen resolution ==
https://9to5mac.com/2017/04/28/building-a-gtx-1080-ti-powered-hackintosh-installing-macos-sierra-step-by-step-video/
https://forums.virtualbox.org/viewtopic.php?f=22&t=54030 works. 
<syntaxhighlight lang='bash'>
$ VBoxManage setextradata "vm_name" VBoxInternal2/EfiGopMode 4
</syntaxhighlight>
The number '3' corresponds to a resolution of 1280x1024 (5:4) and '4' corresponds to 1440x900 (8:5). On lenovo laptop (1600 x 900, 16:9), the height will fill the screen but there are little black spaces on both sides. See [https://en.wikipedia.org/wiki/Graphics_display_resolution#Overview_by_vertical_resolution_and_aspect_ratio Display resolution and aspect ratio].


= iOS =
Note that I need to enable Full Screen for the guest machine b/c the desktop is too large.
== iPad Pro 10.5 vs iPad 9.7 (2017) ==
* [http://www.pocket-lint.com/news/140754-apple-ipad-pro-10-5-vs-ipad-9-7-2017-what-s-the-difference Apple iPad Pro 10.5 vs iPad 9.7 (2017): What's the difference?]
* [https://www.makeuseof.com/tag/find-ipad-model/ How to Find Out Which iPad Model You Own]


== Screen shut off automatically ==
== El Capitan (10.11) ==
Settings -> Display & Brightness -> Auto-Lock. If you select 'Never', the screen will never turn it off by itself.
* http://www.wikigain.com/install-mac-os-x-el-capitan-virtualbox/
* http://www.wikigain.com/complete-guide-fix-virtualbox-errors-installing-mac-os-x/


== Share an internet/hotspot ==
It works on my VirtualBox 5.1.14 and Macbook Pro 2015.
[https://www.howtogeek.com/397133/how-to-use-instant-hotspot-on-your-iphone-ipad-or-mac/ How to Use Instant Hotspot on Your iPhone, iPad, or Mac]


== [https://support.mozilla.org/en-US/kb/focus Firefox Focus] ==
Note: if I skip the following commands, the macOS booting will keep re-run again and again.
Feel quite fast on my iPad. The 'setting' (gear symbol) on the top right hand side cannot be seen unless we click 'Erase' first. On the setting, we can change the search engine, '''Send usage data''', etc.
<pre>
 
VBoxManage modifyvm macElcapitan --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
But the regular Firefox has an option called "Tracking Protection" which is doing the same thing.
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC"
</pre>


== File manager ==
Con: The image downloaded there is already a virtual machine image format.
https://www.makeuseof.com/tag/file-manager-apps-iphone-ipad/


'''Documents by Readdle''' is a file manager with an integrated web browser, which makes it easy to download and transfer YouTube videos. See [https://www.makeuseof.com/tag/youtube-videos-iphone-camera-roll/ How to Download and Save YouTube Videos on iPhone].
If I try to use the iso file downloaded from internet, I saw an error "Missing Bluetooth Controller Transport" (https://gist.github.com/frdmn/de12c894a385bc8e6bff).


== The Fastest File Transfer Methods Between PCs and Mobile Devices ==
== [https://en.wikipedia.org/wiki/MacOS_Sierra Sierra (10.12)] ==
https://www.makeuseof.com/tag/x-fastest-ways-transfer-file-pc-mobile-device/
# [https://www.howtoisolve.com/enable-picture-in-picture-for-youtube-in-macos-sierra/ Enable Picture-in-picture]. It works on Safari and Chrome browsers. Right click on a video and then immediately right click again. It will show an option "picture in picture" in the right-click menu. This is cool but it seems there is no way to control the video except play/pause.
 
#* Another choice is '''[https://github.com/kamranahmedse/pennywise Pennywise]''' which keep all the keyboard shortcuts the original website provided. By default it has a NAVBAR (Left, Right and URL) at the top. We can toggle it by using Cmd/Ctrl + Shift + L.
== Split screen ==
#* Another choice is Google chrome browser. See [https://www.addictivetips.com/web/chrome-picture-in-picture-mode/ How to use Chrome picture in picture mode].
[https://www.makeuseof.com/tag/ipad-split-screen-tips-tricks/ How to Split Screen on iPad (And the Best Tips and Tricks When Doing It)]
# The official image (e.g. '''Install macOS Sierra.app''') we downloaded from ''Apple Store'' is saved under '''/Applications''' folder.
 
# We can follow the instruction https://github.com/geerlingguy/macos-virtualbox-vm to convert the app folder into an iso file. The ''prepare-iso.sh'' script seems to always put the iso file onto the Desktop folder; i.e. output folder and name is not taken.
== MiniKeePass ==
# When we want to create a virtual machine in VirtualBox
Dropbox -> KeePass file -> "..." -> Export -> Open in -> Copy to MiniKeePass.
#* video memory change from 16GB to 128MB
 
#* increase memory to 4096MB
== Voice recorder ==
#* turn off audio
https://www.makeuseof.com/tag/iphone-voice-recorder-apps/
<pre>
 
VBoxManage modifyvm "{vmname}" --cpuidset 00000001 000306a9 00020800 80000201 178bfbff
== Take a screenshot ==
</pre>
# Press and hold the Sleep/Wake (on/off) button on the top of your iPad.
Another [https://techsviewer.com/install-macos-sierra-virtualbox-windows/ instruction] is to run ('''this seems to be necessary even we uses 'import Appliance' method''')
# Quickly click the Home button at the bottom of the screen.
<pre>
# Release both buttons.
VBoxManage modifyvm "Sierra10.14" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
</pre>
 
After booting, select the preferred language and (before click the 'Continue' button) go to Utilities > Disk Utility. Select the VirtualBox disk (VBOX HARDDISK Media)and choose Erase to format it as a Mac OS Extended (Journaled) drive. Installing macOS took about 15 minutes on my Dell T3600 Desktop running Ubuntu/Mint.
 
After a successful login, the 'df -h' command shows macOS uses 8.6 GB space.


When you successfully trigger a screen shot, you'll see a white flash and, if audio is on, hear the camera shutter sound.  
Unfortunately, the Mac guest machine cannot install guest additions.


== HDR photo ==
I get a 'Guru meditation' error when I test the iso on an old non-mac machine (intel core 2 duo CPU).
[https://www.makeuseof.com/tag/hdr-iphone/ How to Shoot in HDR on Your iPhone]


The best use cases for HDR photography are landscapes, objects in direct sunlight, and low-light or backlit scenes.
Note there is an error ('''IOConsoleUsers: gIOScreenLockState 3, hs 0, bs 0, now 0, sm 0x0''') to install Sierra '''10.12.4''' as a guest machine. See https://benlimmer.com/2017/04/23/macos-sierra-virtualbox-10-12-4/.


== How to Take Better Fireworks Photos ==
== High Sierra (10.13) ==
https://lifehacker.com/how-to-take-better-fireworks-photos-with-your-iphone-1827324154
[https://www.tekrevue.com/tip/download-high-sierra-mojave/ How to Download macOS High Sierra From macOS Mojave]


== Procreate ==
== Mojave (10.14) ==
https://www.makeuseof.com/tag/procreate-for-ipad-one-of-the-most-beautiful-and-powerful-art-apps-for-ios-available-today/
* [https://www.wikigain.com/install-macos-mojave-on-virtualbox-windows/ How to install macos mojave on virtualbox windows]
* [https://techsviewer.com/install-macos-10-14-mojave-virtualbox-windows/ How to Install macOS Mojave Final on VirtualBox on Windows PC]
* [https://thetechbloggerguy.blogspot.com/2018/12/macos-mojave-virtualbox-win10.html?m=1 How to Install macOS Mojave in VirtualBox on Windows 10]
 
On VB 5.2.x.
<pre>
# cd "C:\Program Files\Oracle\VirtualBox\"
VBoxManage modifyvm "macMojave" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
</pre>
 
Change Settings. Select USB and check 3.0 USB. This is to enable [https://techsviewer.com/how-to-install-virtualbox-extension-pack-and-enable-usb-3-0/ mouse and keyboard] support in the virtual machine.
 
After the first reboot, I need to remove the iso file. But it dropped to Shell after I boot up. It's more complicated. See the 3rd link above.
 
On Step 8, it complains "cd System\Library\CoreServices\". Change to use fs1 instead of fs2 fixes a problem.
 
I am setting up a new user (brb/arraytools). Note the password must be at least 4 characters.
 
It  shows 12 GB was used when I first boot up the machine.
 
The "TheTechBlogger_APFSEfi.iso" should be kept there.
 
== Catalina 10.15 ==
[https://www.kocpc.com.tw/archives/305342 Windows 如何透過 VirtualBox 安裝 macOS Catalina 虛擬機? 5 個步驟輕鬆完成]
 
== Create an ISO from the Sierra install app obtained from the Mac app store ==
https://klue.github.io/blog/2017/04/macos_kernel_debugging_vbox/
 
== How to Make a MacOS Big Sur ISO File ==
[https://osxdaily.com/2020/12/14/how-create-macos-big-sur-iso/ How to Make a MacOS Big Sur ISO File]
 
== How to Run Your Mac’s Boot Camp Partition as a Virtual Machine ==
https://www.howtogeek.com/315083/how-to-run-your-macs-boot-camp-partition-as-a-virtual-machine/
 
= Run Windows Apps =
[https://www.howtogeek.com/870346/how-to-run-windows-apps-on-your-mac-without-running-windows/ How to Run Windows Apps on Your Mac Without Running Windows]
 
= Remote connection (ssh) =
Use Settings -> General -> Sharing -> Select Remote Login. [https://www.makeuseof.com/remote-login-remotely-access-mac/ How to Access Your Mac From Anywhere With Remote Login]
 
To uses a command line to enable it, see
* http://apple.stackexchange.com/questions/237038/os-x-terminal-command-to-turn-on-off-ssh-server
* http://osxdaily.com/2016/08/16/enable-ssh-mac-command-line/
* http://superuser.com/questions/416096/enabling-ssh-daemon-from-terminal-os-x-lion
 
== ssh key ==
'''Remote/Virtual machine''':
go to system preferences -> sharing and enable remote login. Suppose the user name is 'brb' and the hostname is 'brbs-MacBook-Pro.local'.
 
'''Host machine''':
<syntaxhighlight lang='bash'>
ssh-keygen -t rsa -f ~/.ssh/virtmac  # press 'Enter' 3 times
cat ~/.ssh/virtmac.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"
ssh -i ~/.ssh/virtmac [email protected]
</syntaxhighlight>
 
When I run testings, I need to restore the virtual machine to its initial status. I can use this method in order to avoid the message "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" when I use the 'ssh' command.
 
= Remote Desktop Connection (screen sharing) to Mac =
* [https://mackeeper.com/blog/how-to-screenshare-on-mac/ How to Set Up and Use Screen Sharing on Your Mac]
* [https://www.makeuseof.com/tag/screen-sharing-mac/ How to Use Screen Sharing on a Mac]
 
On Mac, go to system preferences -> System Preferences -> Sharing -> '''Screen Sharing'''. It will show the vnc address of the Mac computer.
 
On my Ubuntu, see [https://help.ubuntu.com/community/AppleRemoteDesktop AppleRemoteDesktop]
* The built-in program '''Remmina Remote Desktop Client''' does not work. After clicking the 'connect' button & entering username/password, the screen flashed and disappeared.
* RealVNC. I download the tarball (VNC Connect 6.0.3, Generic x64, default). Extract it to the Download folder and run '''vncviewer''' program. Yes, I can connect to Mac. But since the Mac has a very high resolution, I need to adjust the resolution setting in my connection. To do that: close the connection, right click a connection icon (created from last connection), choose Properties. In 'Options' tab, select Scaling -> Scale to fit window.
** After connection, a toolbar will appear on the top of screen.  It has a series of icons: Full screen mode, No scaling, Ctrl Alt Del, Info, Properties, Disconnect.
** Even Mac screen lid is closed, VNC still works.
** The connection speed is not ideal. You can see the screen refresh slowly.
* Vinagre. It has to be installed from Ubuntu Software. Unfortunately it does not even allow me to enter a long password:(
 
= Remote Desktop Connection from Mac =
When I try to use the '''Screen Sharing''' (1.7) program in Mac to connect to Ubuntu 16.04 (type 'vnc://192.168.1.188'), I get an error 'The software on the remote computer appears to be incompatible with this version of Screen Sharing.'
 
[[File:Failscreensharing.png|250px]]
 
Another remote desktop program is called '''Remote Desktop Connection for iMac'''. It appears to be used to connect to a Windows-based computer.
 
= Passwords =
== Keepass ==
[https://macpassapp.org/ MacPass]
 
== Passkeys ==
[https://www.howtogeek.com/how-to-use-passkeys-iphone-ipad-mac/ How to Use Passkeys on Your iPhone, iPad, and Mac]
 
= Keychain Access =
https://en.wikipedia.org/wiki/Keychain_(software)
 
== Copy keychains to another Mac ==
* [https://support.apple.com/guide/keychain-access/copy-keychains-kyca1121/mac Copy keychains to another Mac]
* [https://apple.stackexchange.com/a/230509 Backup and restore Keychain]
 
== If you need to update your '''keychain password''' on Mac ==
https://support.apple.com/guide/keychain-access/if-you-need-to-update-your-keychain-password-kyca2429/mac
 
== How to Edit Saved Passwords on Mac with Keychain Access ==
[https://osxdaily.com/2021/06/08/how-edit-saved-passwords-mac-keychain/ How to Edit Saved Passwords on Mac with Keychain Access]
 
== PIV card ==
* Open '''Keychain Access'''. It should show up "PIV-USER NAME-A" on the first item.
* Change browsers (Chrome -> Safari). Firefox does not help.
* [[Javascript#Reload_Javascript_in_browser.2FEmpty_Cache|Empty Cache]] in Chrome
* Incognito mode (not help)
* Reboot
* Change PIC card reader (new one uses less power)
 
== FileVault ==
After I change my password on cloud, I need to run Self-Service -> FileFault -> Repair and sync my password. Search: How to Change or Reset Your Password (Mac)
 
== Encrypted emails ==
Unable to read encrypted emails.
 
Go to Preferences > Account > Advanced > Security.
* Digital signing Certificate: XXXX-S
* Encryption Certificate: XXX-E
* Certificate authentication Authentication: XXX-S
 
Rebooting computer helps.
 
To check PIV card is inserted: open the 'Keychain Access' app.
 
== macOS wants to use the "login" keychain ==
It asks me to enter my keychain password where I have my PIV card inserted. I need to enter my PIN not password.
 
I need to enter my PIN (PIV card is connected) for wifi to connect to office network.
 
== Scopedbookmarkagent wants to use keychain ==
I need to enter my PIN (PIV card is connected) for wifi to connect to office network.
 
== Mac Keeps Asking for Keychain “Local Items” Password ==
* https://appuals.com/mac-keeps-asking-for-keychain-local-items-password/. ''cd ~/Library/Keychains && rm -rf XXXX''. This solution messed up everything related to my PIV card.
* My account is [email protected]
* [https://www.reddit.com/r/AdobeZii/comments/t0vrx5/how_to_get_rid_of_core_sync_wants_to_use_local/ How to get rid of Core Sync wants to use "Local Items" keychain - message?]
* My case is "Core Sync" (adobe) app wants to ask the password. [https://services.dartmouth.edu/TDClient/1806/Portal/KB/ArticleDet?ID=70196 Error: Adobe Desktop Service Wants to Use Local Item Keychain] '''Click General, then click Reset My Default Keychain.''' [https://apple.stackexchange.com/questions/312424/repeated-safari-wants-to-use-the-local-items-keychain-alert Here] has some screenshots for doing this.
* [https://www.tenorshare.com/keychain/safari-wants-to-use-the-local-items-keychain.html Safari Wants to Use the Local Items Keychain]. It is because the login Keychain password is out of sync with the new iCloud Keychain you just created.
* [https://macmule.com/2014/03/30/the-local-items-keychain-in-mavericks/ THE “LOCAL ITEMS” KEYCHAIN IN MAVERICKS]
* [https://www.makeuseof.com/what-is-keychain-password-mac/ What Is the Keychain Password on a Mac?]
 
= Tips =
== Got a New Mac? Do This First! ==
* http://www.makeuseof.com/tag/new-mac-setup/
* My list:
** Settings. Trackpad (Tap to click). Displays (increase font size & night shift). Desktop & Dock (position on screen - left, Default web browser - Chrome). Appearance - dark.
** Webex, Teams, Zoom. Enable blur background.
** Adobe Acrobat
** Activity Monitor
** Chrome as default
** iTerm2. It'll prompt to install command line developer tools.
** R, RStudio, Rig
** Visual Studio Code
** Sublime Text
** p4merge
** Quicktime player
** qView
** Docker
** GIMP
** draw.io
** Amphetamine
** Paintbrush
** Meld
** The Unarchiver
* Files and folders on my new Mac
** Default folders are: Desktop, Documents, Downloads, Library, Movies, Music, Pictures, Public, .config
** Files: .bash_history, .bash_sessions
* Files, folders
** ~/.ssh
** ~/.bashrc, ~/.bash_profile
** ~/.Rprofile
** ~/.gitconfig
** ~/.nanorc
** ~/.profile
** ~/.tmux.conf
* Chrome extension
** UBlock origin
** Play on Kodi
** ColorZilla
** GoFullPage
 
== Best Mac tips ==
[https://www.techradar.com/how-to/software/operating-systems/50-best-mac-tips-tricks-and-timesavers-1310283 The 50 best Mac tips, tricks and timesavers]
 
== Update date and time using command line ==
<syntaxhighlight lang='bash'>
sudo ntpdate -u time.apple.com
sudo ntpdate -u ntp1.nih.gov
</syntaxhighlight>
 
== Forget a wifi network ==
* http://osxdaily.com/2014/03/09/forget-wifi-network-mac-os-x/. Go to 'Advanced' and click '-' to remove.
* https://forums.macrumors.com/threads/my-macbook-wont-connect-automatically-to-my-wifi-network-now-that-it-has-lion.1210649/
 
== Ad hoc network ==
[https://www.makeuseof.com/how-to-create-a-secure-ad-hoc-network-in-macos/ How to Create a Secure Ad Hoc Network in macOS]
 
== List DNS servers ==
[https://superuser.com/questions/258151/how-do-i-check-what-dns-server-im-using-on-mac-os-x How do I check what DNS server I'm using (on Mac OS X)]
<pre>
$ scutil --dns | grep 'nameserver\[[0-9]*\]'
</pre>
To change the DNS settings, follow
* [https://electrictoolbox.com/mac-osx-change-dns-servers-command-line/ Change DNS using the networksetup command line tool on OS X]
* [https://www.softwarert.com/change-dns-server-mac/ Changing DNS server settings on Mac OS X]
 
=== Flush DNS cache ===
* [https://www.howtogeek.com/180356/how-to-reset-the-dns-cache-on-mac-os-x/ How to Reset the DNS Cache on macOS]
* [https://youtu.be/CS72kN2c6hU?t=823 Clear the dns before using the ping command] from the video "Tracking your Dynamic ISP IP Address for use with your Home Server with Cloudflare DDNS & Duck DNS".
 
== /etc/hosts ==
To modify it, use '''sudo nano /etc/hosts'''
 
== [http://smallbusiness.chron.com/keep-ipad-dropping-wifi-signals-49630.html How to Keep an iPad From Dropping Wi-Fi Signals] ==
Renew the iPad's DHCP lease.
 
Change the channel on your wireless channel ([http://macintoshhowto.com/networking/how-to-get-a-good-range-on-your-wireless-network.html pick the channel has the lowest signals]).
 
== Force to reboot ==
[https://macreports.com/ipad-freezes-or-stops-responding-fix/ iPad Freezes or Stops Responding, Fix]. Press and hold both '''Power''' button & '''Home''' button.
 
== Spinning rainbow wheel ==
* [https://www.howtogeek.com/448234/8-warning-signs-your-mac-might-have-a-problem-and-how-to-fix-it/ 8 Warning Signs Your Mac Might Have a Problem (and How to Fix It)]
* [https://www.lifewire.com/fix-spod-spinning-pinwheel-of-death-2260811 Fix SPOD - How to Fix a Spinning Pinwheel of Death]
* [https://macpaw.com/how-to/the-spinning-wheel-on-mac How to Stop the Spinning Wheel on Mac]
* [https://www.howtogeek.com/701206/how-to-stop-the-spinning-wheel-on-your-mac/ How to Stop the Spinning Wheel on Your Mac]
 
== app Store ==
* Need a credit card information. The [https://support.apple.com/en-us/HT204034 'None' option] is not available. [https://www.labnol.org/software/apple-id-without-credit-card/19299/ Some tricks].
* Cannot log in my account. [https://discussions.apple.com/thread/5476482?start=0&tstart=0 Activity clock just keeps spinning and spinning]
* If macOS has been downloaded, the 'Download' button will be changed to 'Open' button in 'App Store' application.
* If my macOS is already Sierra, we don't need to sign into 'App Store' in order to download a newer version Sierra image.
 
== Upgrading to macOS Sierra (nee OSX) for R users ==
http://www.win-vector.com/blog/2017/01/upgrading-to-macos-sierra-nee-osx-for-r-users/
 
== Access the Root Directory ==
http://osxdaily.com/2013/01/17/access-root-directory-mac-os-x/
 
== Disable update notification ==
http://news.softpedia.com/news/how-to-disable-os-x-update-notifications-493961.shtml
 
== How to check a Mac’s OS upgrade history ==
[https://www.macworld.com/article/234916/how-to-check-a-macs-os-upgrade-history-in-system-profiler.html How to check a Mac’s OS upgrade history in System Profiler]
 
== How to download macOS update using the terminal ==
https://www.howtogeek.com/347920/how-to-download-macos-updates-using-the-terminal/
 
== Console/All Messages ==
This is like the system log application in Linux/
 
* [https://support.omnigroup.com/console-osx/ Retrieving Console logs on Mac]
* [https://www.macobserver.com/tmo/article/mac_os_x_using_console_to_troubleshoot_problems Using Console to Troubleshoot Problems]
 
== Does not sleep when the lid is closed ==
* [https://alvinalexander.com/macos/why-is-macbook-warm-when-lid-closed-sleep-mode Why is my MacBook warm when the lid is closed (in sleep mode)?]
<pre>
$ syslog | grep 'Wake reason' | grep 'Mar 22'
...  processWakeReason Wake reason: Host (0x01)
...  Wake reason: ?
...  processWakeReason Wake reason: Host (0x01)
...  Wake reason: RTC (Alarm)
...  processWakeReason Wake reason: Host (0x01)
...  Wake reason: EC.LidOpen (User)
 
$ pmset -g assertions
2018-03-22 19:45:03 -0400
Assertion status system-wide:
  BackgroundTask                0
  ApplePushServiceTask          0
  UserIsActive                  1
  PreventUserIdleDisplaySleep    0
  PreventSystemSleep            0
  ExternalMedia                  0
  PreventUserIdleSystemSleep    1
  NetworkClientActive            0
Listed by owning process:
  pid 120(hidd): [0x00050da000090379] 00:16:13 UserIsActive named: "com.apple.iohideventsystem.queue.tickle"
Timeout will fire in 1189 secs Action=TimeoutActionRelease
  pid 2903(RStudio): [0x0004b27a000124c2] 08:02:10 PreventUserIdleSystemSleep named: "R Computation"
  pid 2903(RStudio): [0x0004b27a000124ba] 08:02:10 PreventUserIdleSystemSleep named: "R Computation"
No kernel assertions.
Idle sleep preventers: IODisplayWrangler
</pre>
* It seems mac wakes up every 2 hours according to the syslog output. [https://forums.macrumors.com/threads/wake-reason-rtc-alarm-how-to-deactivate.1766477/ This issue is indeed caused by the discoveryd process].
* It may be useful to run ping from another machine to see if Mac is still connected to the internet (cannot check if it is live)
* Since when I wake up the machine the next morning, the internet is not connected, it may be useful to send emails in a regular time interval to see how long the machine still is connected to the internet.
* Battery life went down from 98% to 88% the next day morning even I put the machine to sleep in the afternoon before I left.
* [https://www.tonymacx86.com/threads/wake-reason-rtc-alarm-4530s-waking-alone-from-sleep.48520/ Turn Off in Power management "Wake up by Wifi"]
* [https://apple.stackexchange.com/questions/234351/imac-randomly-wakes-up-from-sleep/234679 iMac randomly wakes up from sleep]. In my case, I see '''Rstudio''' and '''hidd''' processes show 'Yes'.
 
== Prevent ssh from sleep ==
http://osxdaily.com/2011/03/21/temporarily-prevent-a-mac-from-sleeping/
<pre>
pmset noidle
</pre>
 
This method does not prevent Mac from displaying screensaver & locking the screen. But it seems to fix the problem of broken pipe in ssh connection.
 
A better way is to modify '''.ssh/config''' file. See [[Linux#Way_to_avoid_ssh_connection_timeout|Way to prevent ssh connection timeout]].
 
== How to Configure a Proxy Server ==
https://www.howtogeek.com/293444/how-to-configure-a-proxy-server-on-a-mac/
 
== Open a chm file ==
[http://download.cnet.com/iChm/3000-2094_4-10878883.html iChm] program works fine. Chmox is too old (power pc) and not works.
 
[https://itunes.apple.com/us/app/chm-reader/id424182884?mt=12 CHM Reader] from Mac App Store is not different from iChm.
 
== Record sound ==
Use 'QuickTime player'.
 
The build-in microphone is located inside the left speaker. The default recording sound is too weak. Go to System Preferences -> Sound. Select 'Input' tab and increase the 'input volume' from the smallest to the loudest. See [https://support.apple.com/guide/mac-help/control-access-to-your-microphone-on-mac-mchla1b1e1fe/mac Control access to your microphone on Mac].
 
If we want to use an external mic, make sure the [https://youtu.be/oaiYc9Cqpis headphone connector has 4 sections].
 
== Record video ==
[https://www.makeuseof.com/record-video-mac/ How to Record Video on Mac: 4 Methods]
 
== Bluetooth device is not auto connected ==
https://apple.stackexchange.com/a/354319
 
== Bluetooth codec ==
[https://www.howtogeek.com/425605/how-to-force-macos-to-use-the-aptx-or-aac-codecs-for-bluetooth-headphones/ How to Force macOS to Use the aptX or AAC Codecs for Bluetooth Headphones]
 
== XXX can't be opened because it is from an unidentified developer ==
* http://osxdaily.com/2012/07/27/app-cant-be-opened-because-it-is-from-an-unidentified-developer/
* Enroll in the [https://developer.apple.com/programs/ Apple's OS X developer program]. The yearly fee is [https://developer.apple.com/programs/enroll/ $99].  https://forum.qt.io/topic/38876/solved-running-app-on-mac-osx-app-structure/5
 
== Cannot be opened because the developer cannot be verified ==
[https://howtoremove.guide/cannot-be-opened-because-the-developer-cannot-be-verified/ Cannot be opened because the developer cannot be verified]. '''Control-click''' on the selected application and then, from the Shortcut menu, select Open.
 
== /private/var/folders ==
https://discussions.apple.com/thread/1933443?start=0&tstart=0
 
If SeqTools was downloaded through a browser, then when we launch it the R script folder in <run_variantannose.sh> becomes something like  ''/private/var/folders/1h/kcm8vkdx6nl00z5wjm5bqlw00000gp/T/AppTranslocation/051E078E-7C2D-4C6C-90FF-F651985EC9C0/d/SeqTools.app/Contents/MacOS/SeqTools/code''
 
== Extreme NAC Assessment Agent ==
https://isdp.nih.gov/isdp/version.action?prodid=220
 
'Please enter the host name or IP address of the Extreme NAC Assessment Agent server' 137.187.64.22.
 
== Which Processes Can You Safely Quit in Activity Monitor on a Mac ==
[https://www.howtogeek.com/406573/which-processes-in-activity-monitor-can-you-safely-quit/ Which Processes Can You Safely Quit in Activity Monitor on a Mac?]
 
== Activity Monitor doesn’t show columns ==
Column sizing is just buggy, the other columns are way over on the right. https://www.reddit.com/r/MacOS/comments/d8e1ow/help_activity_monitor_doesnt_show_columns/
 
== Command line to find the IP address ==
'''ipconfig getifaddr en0'''  # it will return XXX.XXX.XX.XXX
 
Or use '''ifconfig''' to show all of the interfaces and their IPs.
 
The following command works on macOS 14 Sonoma.
<pre>
ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'
</pre>
 
== Uninstall inSync ==
https://www.insynchq.com/uninstall
 
== AirDrop to share a website ==
Only Safari comes with the "Share" button (Chrome does not).
 
== Use AirDrop to share files between Macs and iOS devices ==
[https://www.howtogeek.com/342810/how-to-add-an-airdrop-icon-to-your-macos-dock/ How to Add an AirDrop Icon to Your macOS Dock]
 
AirDrop uses wifi to transfer files. If wifi is not on, the Airdrop window will ask you to turn on wi-fi.
 
To use Airdrop, both iOS and Mac needs to change their settings.
* iOS: Settings -> General -> Airdrop. Choose "Everyone" (default is "Receiving Off").
* Mac: in Airdrop change "Allow me to be discovered by: No One" to "Allow me to be discovered by: Contacts only" or "Everyone".
* Mac: Find -> go to the folder containing the file to be sent. Right click and choose 'Share' -> 'AirDrop'. Click XXX's iPad on Mac. Now click "Accept" on iPad in order to receive files. The AirDrop on iOS will ask what app to open the file. I can choose "Files" -> "iCloud Drive" -> Downloads.
 
[[:File:Airdrop.png]]
 
== How to Transfer Files From PC to iPhone and iPad (And Vice Versa) ==
* https://snapdrop.net/
** It is better to use '''Safari''' browser if we want the file to be saved on the iPad (the file goes to the iCloud Drive's 'Downloads' dir on my iPad).
** If I use the chrome browser on iPad, it is not clear where the file is saved if the file is not a common type like pdf, txt, image, etc. For pptx, it just open the file in chrome. it seems I cannot save the file.
* '''Airdroid''' works fine. The received files can be found by clicking the little clock icon on top right corner. The received files are not available in the "Files" app.
* [https://www.makeuseof.com/tag/transfer-files-wirelessly-computers-ios-devices-fileapp/ How to Transfer Files From PC to iPhone and iPad (And Vice Versa)], [https://itunes.apple.com/us/app/fileapp-file-manager/id297804694?mt=8 FileApp]
 
== Share Files Between Mac & Windows Computers  ==
* [https://www.makeuseof.com/tag/how-to-easily-share-files-across-mac-windows-computers/ Share files on your Mac so that it appears on Windows computers automatically.]
* [https://osxdaily.com/2021/02/24/how-access-windows-shared-folder-iphone-ipad/ How to Access Windows Shared Folders from iPhone & iPad]
 
== Share Files Between iOS and Mac  ==
[https://www.makeuseof.com/tag/what-is-airdrop/ What Is Airdrop? How to Share Files Between iOS and Mac]
 
== Digital color meter ==
[https://www.techrepublic.com/blog/apple-in-the-enterprise/discover-the-digitalcolor-meter-tool-on-your-mac/ Discover the DigitalColor Meter tool on your Mac] Very useful when you want to know the color's RGB value from any dot on your screen.
 
== Notes folder ==
* [http://osxdaily.com/2020/01/15/where-notes-stored-locally-mac/ Where are Notes Stored on Mac?]
* [https://apple.stackexchange.com/questions/111633/where-do-my-notes-written-in-the-notes-application-on-my-mac-get-saved  Where do my notes written in the Notes application on my Mac get saved?]
<syntaxhighlight lang='bash'>
$ ls ~/Library/Group\ Containers/group.com.apple.notes/
Library NoteStore.sqlite NoteStore.sqlite-shm NoteStore.sqlite-wal
</syntaxhighlight>
 
The data can be synchronized through iCloud. [https://www.payetteforward.com/how-sync-iphone-notes-mac-pc-computer-fix/ How Do I Sync My iPhone Notes With Mac Or PC?].
 
== cron ==
* [https://osxdaily.com/2020/04/27/fix-cron-permissions-macos-full-disk-access/ How to Fix Cron Permission Issues in MacOS Catalina & Mojave]
* [https://youtu.be/w2Ka5u5jlJU R tip: Schedule R scripts on a Mac]
 
= Git GUI Client =
* https://git-scm.com/download/gui/mac
* [https://www.fossmint.com/gui-git-clients-for-mac/ 10 Best GUI Git Clients for Mac]
 
== gitk ==
It still works. I can use it to see changes of a specific file '''gitk [filename]'''.
<pre>
brew update
brew upgrade
brew install git # needed only if we haven't had git yet
brew install git-gui
</pre>
 
== Github Desktop ==
Looks good. It is OK to bypass to login a Github account in the installation process.
 
== Fork ==
https://git-fork.com/
 
Good. It supports tabs. It automatically saves the opened tabs. But it is not open source.
 
== SourceTree ==
[https://www.sourcetreeapp.com/ sourcetree]. See also [https://www.rstudio.com/resources/videos/happy-git-and-gihub-for-the-user-tutorial/ Happy Git and Gihub for the useR] from Jenny Bryan.
 
Unfortunately it requires a Bitbucket account in order to finish its installation.
 
= Useful Apps =
[https://www.makeuseof.com/tag/ultimate-list-mac-menu-bar-apps/ The Ultimate List of Mac Menu Bar Apps]
 
== [https://itunes.apple.com/app/amphetamine/id937984704?mt=12 Amphetamine]: keeps your Mac awake (not sleep) ==
Caffeine is too old. [https://github.com/newmarcel/KeepingYouAwake KeepingYouAwake] is a small menu bar utility that is inspired by Caffeine from Lighthead Software. The app is a small wrapper around Apple's caffeinate command line utility.
 
See a [http://muggingsg.com/study-tools/amphetamine-keeps-your-mac-screen-alive-while-studying/ review] of Amphetamine and one from [https://lifehacker.com/macos-app-of-the-week-amphetamine-1825108890 lifehacker].
 
[https://itunes.apple.com/uz/app/lungo/id1263070803?mt=12 Lungo] is another one (paid) and it requires macOS 10.13.
 
[https://www.muo.com/tag/4-ways-keep-mac-from-sleeping/ How to Keep Your Mac From Sleeping: 5 Methods That Work]
 
== Caffeinate ==
<ul>
<li>[https://support.apple.com/guide/mac-help/change-lock-screen-settings-on-mac-mh11784/mac Change Lock Screen settings on Mac]
<li>[https://osxdaily.com/2015/02/03/set-or-disable-sleep-due-to-mac-system-inactivity-from-the-command-line-in-os-x/ Set or Disable Sleep Due to Mac System Inactivity from Command Line in Mac OS X]
<li>terminal (it does not work to '''Lock Screen''')
<pre>
caffeinate &  # you can quit Terminal if you want
killall caffeinate
</pre>
<li>[https://www.igeeksblog.com/how-to-prevent-mac-from-sleeping/ How to Stop Your Mac from Sleeping (3 Methods Explained)]
<li>[https://www.reddit.com/r/macsysadmin/comments/11e2lgm/comment/jaejv39/?utm_source=share&utm_medium=web2x&context=3 Changing Lock Screen settings with a script] & [https://superuser.com/a/1671068 Disabled screen lock on macOS]. But it still does not help.
<pre>
sysadminctl -screenLock status -password -   
# 5 seconds  # match with the settings
sysadminctl -screenLock off -password -
sysadminctl -screenLock status -password -
# off
</pre>
</ul>
 
== Take a break ==
[https://www.techrepublic.com/blog/five-apps/five-free-apps-to-help-remind-you-to-take-a-break/ Five free apps to help remind you to take a break].
* Time Out looks cool. Some features like put the app in the menu bar are available for supporters:(
* Break Timer, memory leak?
* [https://github.com/hovancik/stretchly/ Stretchly]
 
== Quartz ==
In a new macbook computer, when I drew a plot in R from a terminal, it launched a window with the title "Quartz 2[*]" with menu items R, Edit, Quartz & Window. See also [https://www.rdocumentation.org/packages/grDevices/versions/3.6.2/topics/quartz quartz()].
 
== XQuartz ==
* https://en.wikipedia.org/wiki/XQuartz
* https://www.xquartz.org/
 
[https://www.tech2max.com/x11-forwarding-on-os-x-macos/ X11 forwarding on OS X (macOS)], [https://tamemymonkeymind.blogspot.com/2017/03/ssh-x11-forwarding-and-mac-os-x-sierra.html SSH X11 Forwarding and Mac OS X Sierra]
 
I have found out the '''-X''' cannot forward X11. I need to use '''-Y''' option. Note that
* I don't need to pre-open XQuartz app.
* I don't need to run "export DISPLAY" on the remote computer.
* This is tested on macOS Catalin 10.15.3.
* [https://askubuntu.com/a/35518 What is the difference between `ssh -Y` (trusted X11 forwarding) and `ssh -X` (untrusted X11 forwarding)?]
<pre>
ssh -Y XXX.XXX.X.XX
nautilus &
</pre>
 
* BiplotML loading error. It depends on the "rgl" package which requires XQuartz. Install it by '''brew install --cask xquartz''' will fix the error.
<pre>
Error: package or namespace load failed for ‘shapes’:
.onLoad failed in loadNamespace() for 'rgl', details:
  call: rgl.init(initValue, onlyNULL)
  error: OpenGL is not available in this build
Error: package ‘shapes’ could not be loaded
In addition: Warning messages:
1: Loading rgl's DLL failed.
This build of rgl depends on XQuartz, which failed to load.
See the discussion in https://stackoverflow.com/a/66127391/2554330
2: Trying without OpenGL...
</pre>
 
== My installed apps ==
* iTerm2
* RStudio, R
* Amphetamine
* Anaconda-Navigator
* Firefox
* Flux
* Lightshot Screenshot
* Meld
* Paintbrush
* Stretchly
* The Unarchiver
* VirtualBox
* VLC
* Xcode
* SourceTree
* Atom
* Visual Studio Code
* [https://github.com/kamranahmedse/pennywise Pennywise]. Cross-platform application to open any website or media in a floating window .
* XQuartz (R does not need it; R uses [https://en.wikipedia.org/wiki/Quartz_(graphics_layer) Quartz] for plotting).
** However when I try to install tinytex package, it complains unable to load shared object '/Library/Frame/R.framework/Resources/modules//R_X11.so'. It seems to be related to missing XQuartz. See the discussion [https://stackoverflow.com/a/26490114 here]. [http://osxdaily.com/2012/12/02/x11-mac-os-x-xquartz/ Run X11 in Mac OS X with XQuartz].
** Another case is when I try to use svg() to save an image. It shows "Unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so'".
** Another case is edit() won't work with data frame.
** You will need to log out and log back in to make XQuartz your default X11 server.
* Stopwatch & Timer
* Qt Creator
* Chargeberry
 
= Missing Linux commands =
== wget ==
Method 1: [http://rudix.org/packages/wget.html Rudix]
<syntaxhighlight lang='bash'>
curl -O https://raw.githubusercontent.com/rudix-mac/rpm/2016.12.13/rudix.py
python rudix.py install rudix
sudo rudix install wget
which wget
# /usr/local/bin/wget
 
$ wget https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
--2017-02-26 08:41:09--  https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.192.133, 151.101.128.133, 151.101.0.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.192.133|:443... connected.
ERROR: cannot verify raw.githubusercontent.com's certificate, issued by ‘CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’:
  Unable to locally verify the issuer's authority.
To connect to raw.githubusercontent.com insecurely, use `--no-check-certificate'.
$ wget https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh --no-check-certificate
--2017-02-26 08:41:26--  https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.192.133, 151.101.128.133, 151.101.0.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.192.133|:443... connected.
WARNING: cannot verify raw.githubusercontent.com's certificate, issued by ‘CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’:
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 200 OK
Length: 8502 (8.3K) [text/plain]
Saving to: ‘install_rnaseq.sh’
 
install_rnaseq.sh                        100%[===============================================================================>]  8.30K  --.-KB/s    in 0.001s 
 
2017-02-26 08:41:26 (15.7 MB/s) - ‘install_rnaseq.sh’ saved [8502/8502]
</syntaxhighlight>
 
Method 2: [http://stackoverflow.com/questions/33886917/how-to-install-wget-in-macos-capitan-sierra homebrew]
<syntaxhighlight lang='bash'>
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install wget --with-libressl
</syntaxhighlight>
 
Method 3: Build from [http://osxdaily.com/2012/05/22/install-wget-mac-os-x/ source] (require Xcode, works on my OS X 10.12 Sierra w/ Xcode 8.2.1)
<syntaxhighlight lang='bash'>
xcode-select --install
cd ~/Downloads
 
curl -O https://www.openssl.org/source/openssl-1.0.2h.tar.gz
tar xzvf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
./configure darwin64-x86_64-cc
make
sudo make install
 
curl -O http://ftp.gnu.org/gnu/wget/wget-1.18.tar.gz # version 1.19 won't work at the 'make' step
tar -zxvf wget-1.18.tar.gz
cd wget-1.15/
./configure –with-ssl=openssl –with-libssl-prefix=/usr/local/ssl
make
sudo make install
</syntaxhighlight>
 
For some reason, when I use wget to download files from https server, I will get a message: '''ERROR: cannot verify site certificate. Unable to locally verify the issuer’s authority'''.  See
* http://thenubbyadmin.com/2014/01/29/solving-wget-error-cannot-verify-site-certificate-unable-to-locally-verify-the-issuers-authority/
* https://finkers.wordpress.com/2009/10/06/wget-and-https/  (fink solution)
* http://stackoverflow.com/questions/9224298/how-do-i-fix-certificate-errors-when-running-wget-on-an-https-url-in-cygwin (cygwin solution)
* http://stackoverflow.com/questions/30105376/error-cannot-verify-www-youtube-coms-certificate-with-wget-http-www-yout (brew has the same problem)
 
== watch ==
http://stackoverflow.com/questions/9574089/osx-bash-watch-command
<syntaxhighlight lang='bash'>
while :; do clear; your_command; sleep 2; done
</syntaxhighlight>
 
== glances command ==
[https://nicolargo.github.io/glances/ glances]
 
[https://glances.readthedocs.io/en/stable/cmds.html Command Reference], [https://glances.readthedocs.io/en/latest/aoa/load.html Load]
 
[https://www.maketecheasier.com/glances-monitor-system-ubuntu/ Color code]: Blue=careful, Violet=alert, Red=critical
 
[https://www.tecmint.com/glances-monitor-remote-linux-in-web-server-mode/ Use Glances to Monitor Remote Linux in Web Server Mode]
 
* '''glances -w''' # run Glances in web server mode. The port number is shown on the terminal. It is not working if I use the server mode '''glances -s'''.
* n: hide network status
* Use mouse left click to sort processes by CPU, MEM, ..
 
== top command ==
To sort by CPU
<pre>
top -u
</pre>
 
To sort by Memory
<pre>
top -o mem
</pre>
 
== htop ==
http://unix.stackexchange.com/questions/98253/how-do-i-install-htop-inside-mac-os-x
 
It seems the result is not accurate. For example when the fan is working (esets_daemon is running), htop does not show much CPU from eset_daemon but Activity Monitor shows esets_daemon is on the top cpu usage list.
 
== gotop ==
https://github.com/cjbassi/gotop
 
== md5sum ==
It is called '''md5''' instead of md5sum in Linux.
 
For SHA-1 and SHA-256 use
 
<pre style="white-space: pre-wrap; /* CSS 3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* IE 5.5+ */ " >
shasum filename
# OR
shasum -a 1 filename
 
shasum -a 256 filename
 
echo "add4614b6fe3bb8e7dddcaab0ea97c476fbd4ffe288f2a4912cb06f1a47dcfa0 *ubuntu-18.04.3-desktop-amd64.iso" | shasum -a 256 --check
</pre>
 
== tar ==
If we run the following command
<pre>
tar xzvf filename.tar.gz -C directory 2> error.log
</pre>
we will get a non-empty file in <error.log> even the extraction is successful.
 
Therefore it is better to use the following way
<pre>
tar xzvf filename.tar.gz -C directory
if [ $? -eq 0 ]; then
    echo OK
else
    echo FAIL
fi
</pre>
 
(2019-10-15) If I create a tarball on Mac and extract it on Linux, I'll get a strange message ''tar: Ignoring unknown extended header keyword 'SCHILY.dev' ''.
[https://superuser.com/questions/318809/linux-os-x-tar-incompatibility-tarballs-created-on-os-x-give-errors-when-unt Linux / OS X tar incompatibility – tarballs created on OS X give errors when untarred in Linux]. The reason is macOS uses '''BSD tar''' and Linux uses '''GNU tar'''. So one solution is to run ''brew install gnu-tar''. After that, run ''nano ~/.bashrc'' and add the gnubin directory to your PATH by following its terminal instruction. Run ''source ~/.bashrc'' and ''man tar'' will show we are using GNU-tar.
 
== Diff tools ==
* [https://www.git-tower.com/blog/diff-tools-mac Diff Tools on macOS]
* FileMerge - part of XCode from Apple. Too un-intuitive compared to ''WinMerge'' on Windows or ''Meld'' on Linux:(
* [https://sourcegear.com/diffmerge/ DiffMerge]. Still not intuitive.
* [https://www.perforce.com/downloads/visual-merge-tool P4Merge] free. It works. The application theme by default is light and can be changed to dark. One complain is the Preferences window is too long (without a scrollbar).
** It cannot be used to compare folders.
** [https://www.perforce.com/manuals/p4merge/Content/P4Merge/diff-merge.p4merge.html#Merge_text Merge text]
<ul>
<li> [https://yousseb.github.io/meld/ Meld for OSX] - BEST free!</li>
<ul>
<li>[https://meldmerge.org/help/vc-mode.html Version control]</li>
<li> Dark theme issue in OS. It is very difficult to look at the interface when mac is in a dark them. One trick is to switch to a light scheme in mac (Preferences > General). Open Meld application. The background in meld will be white. Now we can switch to the dark them in mac in order to get everything else right.</li>
[[File:Meldss.png|400px]]
<li> [https://www.alexkras.com/how-to-run-meld-on-mac-os-x-yosemite-without-homebrew-macports-or-think/ How to launch it from command line?]. (2020-04-13) I create a sh file as the instruction but it still cannot do 'meld File1 File2'.</li>
<li> [https://stackoverflow.com/a/35701478 Command line solution], [https://formulae.brew.sh/cask/meld#default cask] with meld 3.21.0-r2 (latest from https://github.com/yousseb/meld/releases 2 days ago)
<syntaxhighlight lang='bash'>
brew cask install meld # /usr/local/bin/meld
meld File1 File2  # it works!
</syntaxhighlight>
</li>
</ul>
</ul>
* KDiff3: old (2014)
* '''git diff''' will give a colored output on your terminal
** Still a command line based
** The compared files do not need to be in the local git directory
** Green means the 1st file has more contents
** Red means the 2nd file has less contents
* Beyond Compare (commercial)
* Araxis Merge (commercial)
* DeltaWalker (commercial)
* Kaleidoscope (commercial)
 
== zcat ==
macOS always adds .Z to the .gz filename. A more portable solution is to use '''gunzip -c''' such as gunzip -c XXX.gz.
 
See [https://github.com/dalibo/pgbadger/issues/70 zcat on OS X is running in POSIX mode and will always append .Z to all filenames].
 
= R =
== failed to load cairo DLL ==
I got an error when I use svg() command.
<pre>
svg("~/Downloads/3dPiePlot.svg")
Warning messages:
1: In svg("~/Downloads/3dPiePlot.svg") :
  unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so':
  dlopen(/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so, 6): Library not loaded: /opt/X11/lib/libXrender.1.dylib
  Referenced from: /Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so
  Reason: image not found
2: In svg("~/Downloads/3dPiePlot.svg") : failed to load cairo DLL
</pre>
http://r.789695.n4.nabble.com/Cairo-package-error-quot-unable-to-load-quot-td4694453.html
 
you don't have X11 installed and it no longer ships with OS X 10.9 - you need to get it from
 
http://xquartz.macosforge.org
 
At the end of installation, it will ask you to log out and log in again to make xquartz a default X11 server.
 
= Tex/Latex =
* http://tug.org/mactex/ and http://tug.org/mactex/mactex-download.html
* http://mactex-wiki.tug.org/wiki/index.php?title=TeX_Live_Manager
* http://ctan.org/mirrors
* http://dante.ctan.org/mirmon/
 
== Download failure ==
[[File:BasictexErr.png|250px]]
 
The error seems to be related to a new release (6/7/2017). The download link for basicTex is http://tug.org/cgi-bin/mactex-download/BasicTeX.pkg. It downloaded the file mactex-basictex-20161009.pkg. But the new release is mactex-basictex-20170607.pkg. The download works fine on 6/8/2017.
 
http://ctan.org/pkg/mactex-basic website is working fine but the downloaded file name is <BasicTex.pkg> so it is not clear about the release date.
 
== tlmgr error ==
* https://tex.stackexchange.com/questions/64261/updating-tlmgr-2011-to-2012
* https://tex.stackexchange.com/questions/253599/repository-and-local-installation
<syntaxhighlight lang='bash'>
$ tlmgr update --self
tlmgr: The Tex Live versions supported by the repository
http://ctan.sharelatex.com/tex-archive/systems/texlive/tlnet
  (2016-2016)
do not include the version of the local installation
  (2017).
</syntaxhighlight>
 
== Install a new package through tlmgr ==
When I try to knitr an R markdown file in RStudio, an error was popped up complaining about missing 'framed.sty' file. The solution is to [https://github.com/rstudio/rmarkdown/issues/378 install the framed package] on macOS or [https://stackoverflow.com/questions/9590134/why-is-knitr-unable-to-find-framed-sty-or-kpsewhich texlive-latex-extra package] on Ubuntu/Debian.
<syntaxhighlight lang='bash'>
sudo tlmgr update --self
sudo tlmgr install framed
</syntaxhighlight>
 
== Miktex on Mac ==
https://miktex.org/howto/install-miktex-mac
 
== LaTeXiT ==
* https://www.chachatelier.fr/latexit/
* https://mac.filehorse.com/download-latexit/
 
= Microsoft Outlook =
== [https://support.office.com/en-us/article/customize-views-in-outlook-for-mac-257d7104-5c90-4ee3-bad2-9935ab424c64?ui=en-US&rs=en-US&ad=US Customize views] ==
* Sidebar (from the ''outside'' Menu bar): View > Sidebar
* Organize (from the ''inside'' menu or blue Ribbon): Focused Inbox, Message Preview.
* Remove Focused and Other: By Conversations -> uncheck "Turn on focused inbox". Or go to the "Organize" menu to uncheck "Focused Inbox".
 
== Import a calendar into Outlook ==
[https://stackoverflow.com/questions/6102956/add-ics-file-to-outlook-2011-mac-as-new-calendar Add ics file to outlook 2011 (Mac) as new calendar]. Drag and drop.
 
== Outlook search is incomplete ==
[https://answers.microsoft.com/en-us/msoffice/forum/all/outlook-for-mac-search-results-are-incomplete/0b547a9a-260e-4299-8d8b-f4296b2f5f18 Issue on Mojave]. Users can should OWA https://outlook.office365.com instead.
 
== Temp folder ==
* On my Outlook (365 subscription), it is ''/private/var/folders/2q/slryb0rx4tj97t66v7l6pwvr_z6g3s/T/com.microsoft.Outlook/Outlook\ Temp/''. It is obtained by '''Open''' an attachment and then select & copy a file.
* When I install R packages, the binary packages are downloaded to ''/var/folders/2q/slryb0rx4tj97t66v7l6pwvr_z6g3s/T//RtmpnqOp8D/downloaded_packages''. In fact, ''/var'' is soft link to ''/private/var''.
 
== Save an email ==
The file format is *.eml.
 
== Automatic replies in Outlook ==
* [https://support.microsoft.com/en-us/office/automatic-replies-in-outlook-for-mac-071d6e22-c315-410d-b754-964baf2ef88d Automatic replies in Outlook for Mac]
* [https://www.extendoffice.com/documents/outlook/3552-outlook-auto-reply-to-specific-sender.html How To Automatically Reply To Specific Sender (Email Address) In Outlook?]
* [https://www.windowscentral.com/how-master-outlooks-out-office-automatic-replies How to master Outlook's out-of-office automatic replies]
 
== What’s New in Outlook 365 for Mac’s Fall 2020 Update ==
[https://www.howtogeek.com/700319/what%e2%80%99s-new-in-outlook-365-for-macs-fall-2020-update/ What’s New in Outlook 365 for Mac’s Fall 2020 Update]
 
= Apple Server =
* [http://www.apple.com/mac-pro/ Mac Pro] server (up to 64 GB DDR3 memory)
* [http://insights.dice.com/2012/12/18/why-apple-will-never-offer-another-server-again/ Why Apple Will Never Offer Another Server Again]
== OS Server ==
* http://www.apple.com/macos/server/
* https://en.wikipedia.org/wiki/MacOS_Server
 
= Apple Silicon =
[https://www.howtogeek.com/700319/what%e2%80%99s-new-in-outlook-365-for-macs-fall-2020-update/ Apple Silicon + Big Sur + RStudio + R Field Report]
 
== Unified memory ==
[https://www.makeuseof.com/what-is-unified-memory/ What Is Unified Memory and How Much Do You Need?]
 
= Hackintosh =
* https://en.wikipedia.org/wiki/Hackintosh
* https://www.reddit.com/r/hackintosh/
* [https://www.reddit.com/r/hackintosh/comments/f17l4z/catalina_install_on_ancient_core_2_quad_wolfdale/ Catalina install on ancient Core 2 Quad Wolfdale CPU with SSE4.1, special requirements?]
 
== OpenCore ==
* [https://youtu.be/eUnVzJsINCI?t=163 Install macOS on any PC | OpenCore Guide]. [https://dortania.github.io/getting-started/ OpenCore Getting Started]
* [https://youtu.be/p3epD8qqVeA?t=951 Intel NUC8 CATALINA HACKINTOSH | Complete Install Guide 2020] TechNolli
 
== How to Triple Boot Your Hackintosh with Windows and Linux ==
http://lifehacker.com/5698205/how-to-triple-boot-your-hackintosh-with-windows-and-linux
 
== How To Install macOS Sierra Hackintosh On PC ==
http://www.redmondpie.com/how-to-install-macos-sierra-hackintosh-on-pc-guide/
 
== Building a GTX 1080 Ti-powered Hackintosh: Installing macOS Sierra step-by-step ==
https://9to5mac.com/2017/04/28/building-a-gtx-1080-ti-powered-hackintosh-installing-macos-sierra-step-by-step-video/
 
= iOS =
== iPad Pro 10.5 vs iPad 9.7 (2017) ==
* [http://www.pocket-lint.com/news/140754-apple-ipad-pro-10-5-vs-ipad-9-7-2017-what-s-the-difference Apple iPad Pro 10.5 vs iPad 9.7 (2017): What's the difference?]
* [https://www.makeuseof.com/tag/find-ipad-model/ How to Find Out Which iPad Model You Own]
 
== Screen shut off automatically ==
Settings -> Display & Brightness -> Auto-Lock. If you select 'Never', the screen will never turn it off by itself.
 
== install ipa file ==
* [https://developer.apple.com/forums/thread/124115 How to load .ipa onto iPhone within Catalina?]
* [https://github.com/qnblackcat/uYouPlus#download YouTube vanced]
 
== Accessibility, display, black and white ==
* [https://www.howtogeek.com/449389/how-to-enable-grayscale-on-your-mac/ How to Enable Grayscale on Your Mac]
* [https://www.howtogeek.com/how-to-turn-your-iphone-screen-black-and-white-and-why/ How to Turn Your iPhone Screen Black and White (And Why)]
 
== How to Stop Apps from Using Cellular Data ==
[https://osxdaily.com/2021/11/04/block-apps-using-cellular-data-iphone-ipad/ How to Stop Apps from Using Cellular Data on iPhone & iPad]
 
== Multitasking ==
[https://www.makeuseof.com/tag/multitasking-text-editing-ipados/ How to Use Multitasking and Text Editing Gestures on iPadOS]
 
== Shortcuts/automation ==
[https://www.howtogeek.com/705089/how-to-trigger-an-action-at-sunrise-or-sunset-on-iphone/ How to Trigger an Action at Sunrise or Sunset on iPhone]
 
== How to Use Multiple Windows of An App ==
[https://www.howtogeek.com/441373/how-to-use-multiple-windows-of-an-app-on-your-ipad/ How to Use Multiple Windows of An App on Your iPad]
 
== Share an internet/hotspot ==
[https://www.howtogeek.com/397133/how-to-use-instant-hotspot-on-your-iphone-ipad-or-mac/ How to Use Instant Hotspot on Your iPhone, iPad, or Mac]
 
== [https://support.mozilla.org/en-US/kb/focus Firefox Focus] ==
Feel quite fast on my iPad. The 'setting' (gear symbol) on the top right hand side cannot be seen unless we click 'Erase' first. On the setting, we can change the search engine, '''Send usage data''', etc.
 
But the regular Firefox has an option called "Tracking Protection" which is doing the same thing.
 
== Download files in safari ==
[https://osxdaily.com/2020/09/02/how-download-files-safari-iphone-ipad/ How to Download Files from Safari on iPhone & iPad]
 
== File manager ==
[https://www.makeuseof.com/tag/file-manager-apps-iphone-ipad/ The 6 Best File Manager Apps for iPhone and iPad]
 
'''Documents by Readdle''' is a file manager with an integrated web browser, which makes it easy to download and transfer YouTube videos. See [https://www.makeuseof.com/tag/youtube-videos-iphone-camera-roll/ How to Download and Save YouTube Videos on iPhone].
 
== App storage ==
[https://apple.stackexchange.com/a/251745 Reduce Pocket app size]. For Pocket, I open the app, click Profile -> Setting -> Clear Downloaded Files.
 
== FE file explorer ==
No ads. Support sftp. Android & iOS are available. https://www.skyjos.com/fileexplorer/
 
== The Fastest File Transfer Methods Between PCs and Mobile Devices ==
https://www.makeuseof.com/tag/x-fastest-ways-transfer-file-pc-mobile-device/
 
== Split screen ==
* [https://www.makeuseof.com/tag/ipad-split-screen-tips-tricks/ How to Split Screen on iPad (And the Best Tips and Tricks When Doing It)]
* [https://www.howtogeek.com/665906/whats-the-difference-between-split-view-and-slide-over-on-an-ipad/ What’s the Difference Between Split View and Slide Over on an iPad?]  To fully close a Slide Over window, hold your finger on the control bar at the top and slide it slowly toward the edge of the screen until it becomes part of Split View.
 
== MiniKeePass ==
Dropbox -> KeePass file -> "..." -> Export -> Open in -> Copy to MiniKeePass.
 
Not maintained after 2020. [https://keepassium.com/ KeePassium] seems to work fine initially.
 
== Voice recorder ==
* [https://www.howtogeek.com/769338/how-to-record-audio-on-iphone/ How to Record Audio on iPhone]. Voice Memos App
* [https://www.makeuseof.com/tag/iphone-voice-recorder-apps/ 5 Feature-Rich iPhone Voice Recorder Apps]
 
== Live transcribe ==
[https://www.makeuseof.com/how-to-use-live-captions-on-mac/ How to Use Live Captions on Your Mac to Transcribe Audio]
 
== Take a screenshot ==
# Press and hold the Sleep/Wake (on/off) button on the top of your iPad.
# Quickly click the Home button at the bottom of the screen.
# Release both buttons.
 
When you successfully trigger a screen shot, you'll see a white flash and, if audio is on, hear the camera shutter sound.
 
Where to find screenshots: Open Photos, then go to Albums > Screenshots.
 
[https://www.howtogeek.com/722401/how-to-take-a-full-page-screenshot-of-a-website-on-an-iphone-or-ipad/ How to Take a Full-Page Screenshot of a Website on an iPhone or iPad]. The full screenshot works on Safari, but not Chrome.
 
== HDR photo ==
[https://www.makeuseof.com/tag/hdr-iphone/ How to Shoot in HDR on Your iPhone]
 
The best use cases for HDR photography are landscapes, objects in direct sunlight, and low-light or backlit scenes.
 
== Burst photos ==
[https://osxdaily.com/2021/07/09/convert-burst-photos-to-gif-iphone-ipad How to Convert Burst Photos to GIF on iPhone or iPad]
 
== How to Take Better Fireworks Photos ==
https://lifehacker.com/how-to-take-better-fireworks-photos-with-your-iphone-1827324154
 
== Live photos ==
[https://www.makeuseof.com/how-to-make-video-live-photo/ How to Make Videos Into Live Photos on iPhone]
 
== Procreate ==
https://www.makeuseof.com/tag/procreate-for-ipad-one-of-the-most-beautiful-and-powerful-art-apps-for-ios-available-today/
 
== Garden apps ==
* [https://www.reviewgeek.com/40893/grow-your-green-thumb-with-these-gardening-apps/ Grow Your Green Thumb with These Gardening Apps]
* [https://osxdaily.com/2022/06/02/identify-flowers-plants-objects-iphone/ How to Identify Flowers & Plants with iPhone with a Cool Hidden Feature]
 
== GoodNotes ==
http://www.goodnotes.com/
 
== Note taking ==
* [https://www.makeuseof.com/best-ipad-note-taking-apps/ The 5 Best Free iPad Note-Taking Apps]
* [https://lifehacker.com/tech/how-to-use-freeform-app Freeform Is the Best iOS App You're Not Using]
 
== Replace desktop? ==
* How to download pdf files?
* How to search on pdf files?
 
== AirDrop ==
[https://support.apple.com/en-us/HT204144 Use AirDrop on your iPhone, iPad, or iPod touch]
 
== AirPlay, mirror screen ==
* [https://support.apple.com/en-us/HT204289 How to AirPlay video and mirror your device's screen]
* [https://www.makeuseof.com/mirror-iphone-to-pc-via-usb-imobie/ How to Mirror Your iPhone to Your PC via a USB Connection]
 
== Shell/terminal ==
[https://www.bleepingcomputer.com/news/linux/ish-an-ios-linux-shell-for-your-iphone-or-ipad/ iSH] - An iOS Linux Shell for Your iPhone or iPad
 
== AirDroid: wifi transfer files ==
AirDroid works on iOS. It has frequent updates and gets good reviews. Another popular android app "Portal" does not get updates and does not have a good review on iOS.
 
== Turn off passcode ==
https://appsliced.co/ask/how-do-i-disable-the-passcode-lock-on-my-ipad
 
Under Settings -> Touch ID &N Passcode
 
== Turn off auto-lock ==
http://www.solveyourtech.com/disable-auto-lock-ipad-2/
 
Under Settings -> Display & Brightness
 
== Reducing eye strain ==
https://www.makeuseof.com/tag/reduce-eye-strain-iphone/
 
== iCloud ==
[https://www.makeuseof.com/tag/spare-icloud-storage-uses/ 6 Nifty Uses for Spare iCloud Storage ]
 
== Music ==
* [https://lifehacker.com/learn-the-basics-of-beatmaking-with-this-open-source-sy-1828030421 Learn the Basics of Beatmaking with This Open-Source Synthesizer App]
* MusiCloud Pro $2.99. It will give an URL for the iPad so we can upload songs there (much like AirDroid in Android).
 
== [https://www.noveleffect.com/ Novel Effect] Make Story Magic ==
 
== Chrome keyboard shortcuts ==
[http://osxdaily.com/2019/04/16/chrome-ipad-keyboard-shortcuts/ 22 Chrome for iPad Keyboard Shortcuts]


== GoodNotes ==
== Games ==
http://www.goodnotes.com/
* [https://www.reviewgeek.com/16102/five-of-the-best-premium-ios-games-with-no-in-app-purchases/ Five of the Best Premium iOS Games with No In-App Purchases]
* [https://www.howtogeek.com/727183/how-to-pair-the-xbox-wireless-controller-with-an-iphone-or-ipad/ How to Pair the Xbox Wireless Controller with an iPhone or iPad]
* [https://www.makeuseof.com/tag/best-offline-games-iphone-ipad/ The 12 Best Offline Games for iPhone and iPad to Play Without Data or Wi-Fi]
* [https://www.howtogeek.com/817170/how-to-turn-your-iphone-into-a-handheld-gaming-console/ How to Turn Your iPhone Into a Handheld Gaming Console (With a Controller)]
* [https://www.makeuseof.com/best-flight-simulators-for-iphone/ The 8 Best Flight Simulators for Your iPhone]


== Replace desktop? ==
== Rubik cubes ==
* How to download pdf files?
[https://lifehacker.com/the-best-apps-for-solving-a-rubiks-cube-1840509349  The Best Apps for Solving a Rubik's Cube]
* How to search on pdf files?


== AirDrop ==
== VLC ==
[https://support.apple.com/en-us/HT204144 Use AirDrop on your iPhone, iPad, or iPod touch]
[http://osxdaily.com/2014/08/03/watch-mkv-avi-video-ipad-iphone-vlc/ How to Watch MKV & AVI Video on iPad or iPhone Free with VLC]


== Shell/terminal ==
== VPN ==
[https://www.bleepingcomputer.com/news/linux/ish-an-ios-linux-shell-for-your-iphone-or-ipad/ iSH] - An iOS Linux Shell for Your iPhone or iPad
[https://www.makeuseof.com/tag/best-free-vpn-for-iphone/ The 5 Best Free VPNs for the iPhone]


== AirDroid: wifi transfer files ==
== ssh ==
AirDroid works on iOS. It has frequent updates and gets good reviews. Another popular android app "Portal" does not get updates and does not have a good review on iOS.
* Termius
 
* [http://www.blink.sh/ Blink], mentioned in [https://www.raspberrypi.org/blog/connect-your-raspberry-pi-4-to-an-ipad-pro/ Connect your Raspberry Pi 4 to an iPad Pro]
== Turn off passcode ==
https://appsliced.co/ask/how-do-i-disable-the-passcode-lock-on-my-ipad


Under Settings -> Touch ID &N Passcode
== Twitter ==
[https://www.reviewgeek.com/52119/the-best-twitter-apps-for-every-platform/ The Best Twitter Apps for Every Plat]


== Turn off auto-lock ==
== Check the privacy policies ==
http://www.solveyourtech.com/disable-auto-lock-ipad-2/
[https://www.howtogeek.com/712070/how-to-check-the-privacy-policies-of-your-installed-iphone-apps/ How to Check the Privacy Policies of Your Installed iPhone Apps]


Under Settings -> Display & Brightness
== local network privacy policy in iOS 14 ==
* [https://stackoverflow.com/a/63525062 Bonjour/...(app name) would like to find and connect to devices on your local network in iOS 14 permission notification on iOS 14?],
* [https://www.nytimes.com/wirecutter/blog/iphone-ios-14-privacy-alerts/ Why Your iPhone Has So Many New Privacy Alerts in iOS 14],
* [https://www.twilio.com/changelog/support-ios-140-local-network-privacy-policy Support for iOS 14.0 Local Network Privacy Policy]


== Reducing eye strain ==
== spyware ==
https://www.makeuseof.com/tag/reduce-eye-strain-iphone/
[https://www.rd.com/article/remove-spyware-iphone/ How to Remove Spyware on an iPhone]


== iCloud ==
== Emergency Contacts on Your iPhone ==
[https://www.makeuseof.com/tag/spare-icloud-storage-uses/ 6 Nifty Uses for Spare iCloud Storage ]
[https://www.makeuseof.com/how-to-set-up-emergency-contacts-iphone/ How to Set Up Emergency Contacts on Your iPhone]


== Music ==
= iPad =
* [https://lifehacker.com/learn-the-basics-of-beatmaking-with-this-open-source-sy-1828030421 Learn the Basics of Beatmaking with This Open-Source Synthesizer App]
* MusiCloud Pro $2.99. It will give an URL for the iPad so we can upload songs there (much like AirDroid in Android).


== [https://www.noveleffect.com/ Novel Effect] Make Story Magic ==
== Air is laminated ==
[https://slickdeals.net/f/16173898-apple-10-9-ipad-10th-gen-64gb-wi-fi-only-blue-399-00-at-b-h-photo?src=recombee_interspersed&prop=rcmid-94b07df059bff5b5b3d75db8a33c2743&attrsrc=Test%3ADesktopInterspersePers%3AWith+JFY+and+with+personalized+deals Apple 10.9" iPad (10th Gen)]. Keep in mind that the screen on the '''Air''' is '''laminated''', while this is not. You will feel (and hear) a small gap between the screen and the pencil, which might get a bit annoying if you'll be using it a lot that way.


== Chrome keyboard shortcuts ==
== Selling Your iPad ==
[http://osxdaily.com/2019/04/16/chrome-ipad-keyboard-shortcuts/ 22 Chrome for iPad Keyboard Shortcuts]
[https://www.makeuseof.com/what-to-do-before-giving-away-ipad/ Selling or Giving Away Your iPad? Here Are 7 Things You Should Do First]

Revision as of 09:13, 21 April 2024

macOS

https://en.wikipedia.org/wiki/MacOS

Darwin (operating system) and release history (first is September 30, 2015). Check the current machine's build number About this Mac > System Report > Software. I found after I installed the latest updates, the available disk space is increased.

Find OS version by command line

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.11.6
BuildVersion:	15G1004

$ sw_vers -productVersion
10.11.6

How to differentiate Linux and Mac

Use uname (unix name) with -s (system name) flag

# Mac
$ uname -s
Darwin

# Linux
$ uname -s
Linux

BSD and Linux

Darwin, MacOS, OpenSource?

http://superuser.com/questions/19492/is-mac-os-x-open-source. Darwin is like Linux, FreeBSD, etc... Mac OS X GUI is like KDE, GNome, etc...

Apple Open Source https://opensource.apple.com/. It includes Kernel, macOS, Developer Tools, etc.

Partition format

fdisk will show it is HFS/ HFS+. Ubuntu OS can read but can't write to it.

/dev/sdb1  *       64 250675199 250675136 119.5G af HFS / HFS+

However, I got a problem when I run cp command.

$ ls -l /media/brb/SamsungUSB/
-rw------- 1 99 99 10592270336 Feb 26 09:45 macSierra.ova
-rw-r--r-- 1 99 99  6922018816 Feb 15 14:40 Sierra10.12.3.iso
$ md5sum '/media/brb/SamsungUSB/macSierra.ova' 
md5sum: /media/brb/SamsungUSB/macSierra.ova: Permission denied

$ sudo chown brb /media/brb/SamsungUSB/macSierra.ova 
chown: changing ownership of '/media/brb/SamsungUSB/macSierra.ova': Read-only file system

Some suggestion is to disable journaled file system as this.

But I found the problem should be resolved in macOS. That is, running 'sudo chmod 644' on the file from an Mac computer.

How to partition

Disk space

Three ways to find out

  1. About this mac (eg 338GB available out of 499.96GB)
  2. Finder -> Macintosh HD -> Get Info (eg Available 338GB, used 159GB)
  3. df -hl command (the sum of the following example is 153GB) ["-l" show local file systems only]

Beta version of macOS

How to get the new version of macOS 10.13

Download macOS installers

How to Download Full MacOS Installers the Easy Way with MDS

The download speed is good when I tried to download Big Sur 11.4. The file <Install_macOS_11.4-20F71.dmg> took 12.45GB.

How to Convert Disk Image Between .DMG and .ISO Format on Mac OS X.

hdiutil makehybrid -iso -joliet -o ~/Desktop/filename.iso ~/Desktop/filename.dmg

Preferences

Set all app windows to close when quitting apps

https://support.apple.com/guide/mac-help/quit-apps-mchl834d18c2/mac. I need this for the Preview app. But it does not work. The command line way 'defaults write com.apple.Preview ApplePersistenceIgnoreState -bool no' does not help either.

Single click to reveal desktop/hide all apps

How to turn off macOS Sonoma 'click to reveal desktop': switch off the most annoying change in Mac update history

Stage manager

Use Stage Manager to organize apps and windows on Mac

Privacy: camera, microphone, share desktop in Webex

Camera location: Roughly 1/2 inch to the right of the camera. You cannot see it because it is covered with a tinted and transparent plate. If you want to experiment and confirm then operate your computer in a bright area and note the screen brightness.

To test the built-in camera on Mac we can use Photo Booth, FaceTime, ...

Catalina / WebEx Cannot share Desktop or Apps or Support for Cisco Webex Meetings for macOS Catalina. Check your Systems Preferences > Security & Privacy > Privacy settings. Click the lock to make changes - and enter your password. Check the box next to Cisco WebEx for all of the following:

  • Camera
  • Microphone
  • Input Monitoring
  • Full Disk Access
  • Screen Recording

Screen Sharing in Cisco Webex Meetings Virtual Desktop App

Share Content in Cisco Webex Meetings and Cisco Webex Events

I'm Hearing an Echo of My Voice in the Audio Conference

Energy Saver

Multiple desktops

Mission Control 101: How to Use Multiple Desktops on a Mac

Dashboard

Finder window relocating to different Space Desktop

Right click on the Finder icon in the dock. Select "Options" then under "Assign to" select "This Desktop". See this.

How to prevent Mac from changing the order of Desktops/Spaces

How to prevent Mac from changing the order of Desktops/Spaces

Universal Control, Sidecar

How to Switch From Universal Control to Sidecar on a Mac and iPad

Second screen: Deskreen (cross platforms)

Split screen

4 Features That Make It Easy to Work With Multiple Apps on a Mac

https://support.apple.com/en-us/HT204948

  1. Hold down the full-screen button in the upper-left corner of a window.
  2. As you hold the button, the window shrinks and you can drag it to the left or right side of the screen.
  3. Release the button, then click another window to begin using both windows side by side.

Click the green button to exit the split mode (and entering the full screen mode).

Black screen with cursor

After I opened the lid to wake it up and type my password, the screen kept black with a cursor only. My solution: hold the power button for a few seconds and the screen will pop us a dialog asked me for a few options. I choose 'restart' and the desktop is back. Later it shows Your Mac hasn't restarted because RStudio failed to quit. To continue restarting, quit RStudio. If I clicked 'Try again', the Mac will re-start.

https://www.cnet.com/news/macbook-pro-blank-screen-on-wake-from-sleep-2-fixes/

Sleep wake failure

Catalina 10.15.3. Screen is black.

Booting problem

How to Repair Your Mac’s Disk Using Safe Mode, fsck, and More

Shut down randomly

Your Mac Keeps Shutting Down Randomly? Here's What You Can Do

Boot keys and backup

WindowServer process takes a lot of memory

When no my own applications are running, macOS already took 6GB RAM 😕

MacOS 10.15.3, WindowServer uses 780MB.

What Is the Process WindowServer, and Why Is It Running on My Mac?

How to Reduce WindowServer's CPU Usage on Mac

docker for mac memory usage in com.docker.hyperkit

docker for mac memory usage in com.docker.hyperkit. the Real Memory usage is much lower than what you see in the "Memory" column in Activity Monitor.

Emoji

  • Click Flag on the toolbar -> Show emoji and symbols
  • Control + command + space bar

Automator

Reset password

How to Reset MacOS Password with Terminal

Relocated Items folder on your Mac after upgrading macOS

If you see a Relocated Items folder on your Mac after upgrading macOS

/Users/Shared/Relocated Items/

OS X File System

Home directory

/Users/USERNAME

The following is the default directories under $HOME.

$ ls ~/
Applications	Documents	Library		Music		Public	
Desktop		Downloads	Movies		Pictures

See also How to reclaim the /home directory.

/ (root) directory

Some directory may be hidden. See http://www.westwind.com/reference/OS-X/invisibles.html

$ ls -l /
total 45
drwxrwxr-x+ 62 root  admin  2108 Feb 15 12:41 Applications
drwxr-xr-x+ 69 root  wheel  2346 Feb  9 11:02 Library
drwxr-xr-x@  3 root  wheel   102 Feb  9 08:47 Network
drwxr-xr-x@  4 root  wheel   136 Sep 16 17:07 System
drwxr-xr-x   7 root  admin   238 Feb  7 15:32 Users
drwxrwxrwt@  4 root  admin   136 Feb 15 13:32 Volumes
drwxr-xr-x@ 39 root  wheel  1326 Jul  8  2016 bin
drwxrwxr-t@  2 root  admin    68 Sep 16 16:59 cores
dr-xr-xr-x   3 root  wheel  4311 Feb  9 08:47 dev
lrwxr-xr-x@  1 root  wheel    11 Sep 16 16:59 etc -> private/etc
dr-xr-xr-x   2 root  wheel     1 Feb 14 15:31 home
-rw-r--r--@  1 root  wheel   313 Aug  2  2015 installer.failurerequests
dr-xr-xr-x   2 root  wheel     1 Feb 14 15:31 net
drwxr-xr-x@  3 root  wheel   102 Feb  9 14:58 opt
drwxr-xr-x@  6 root  wheel   204 Sep 16 16:59 private
drwxr-xr-x@ 59 root  wheel  2006 Sep 16 16:59 sbin
lrwxr-xr-x@  1 root  wheel    11 Sep 16 16:59 tmp -> private/tmp
drwxr-xr-x@ 12 root  wheel   408 Feb  9 11:02 usr
lrwxr-xr-x@  1 root  wheel    11 Sep 16 16:59 var -> private/var

Library folder & show hidden files/folders

What is the Library folder on Mac?

How to show hidden files and folders including ~/Library on a Mac

In MacOS Sierra & Majove, use Shift + CMD + . (dot) to toggle.

Or follow Quickly Show/Hide Hidden Files on macOS Sierra, OS X El Capitan & Yosemite

6 macOS Folders You Can Safely Delete to Save Space

https://www.makeuseof.com/tag/macos-folders-delete-save-space/

5 macOS Folders You Should Never Touch

5 macOS Folders You Should Never Touch (And Why)

Tune Up Your Mac for Best Performance

10 Easy Ways to Tune Up Your Mac for Best Performance

  1. Clear Some Free Space
  2. Check Activity Monitor
  3. Reduce Your Login Items
  4. Run A Scan For Malware
  5. Empty The Caches
  6. Run First Aid On Your Disk
  7. Disable System Animations
  8. Speed Up Your Browser
  9. Reindex Spotlight
  10. Update Your Apps

Temp Folder

Where’s the Temp Folder on Mac OS? How to Find & Open the Mac Temporary Directory

  • echo $TMPDIR (/var/folders/XX/RANDOMCHARACTERS/T). Note: R's tempdir() will create a subfolder in OS's $TMPDIR.
  • /tmp (which links to /private/tmp)
  • ~/Library/Caches/TemporaryItems/ (not found on Mojave)

/Volumes and Machintosh HD directory

Macintosh HD is just a symbolic link to / (root) on your system; that is done in /Volumes.

$ ls -l /Volumes/
total 8
lrwxr-xr-x  1 root  admin    1 Feb  9 08:47 Macintosh HD -> /
drwxrwxr-t  8 root  admin  340 Jan 18 14:06 OS X Install ESD

/Users/Shared folder

macOS Sierra: Share files with others who use your Mac

Format SD card as FAT

Use SD Memory Card Formatter (Windows and mac only). See NOOBS.

How to Format an SD Card on Your Mac

rsync

The built-in rsync utility is too old (it does not support multiple files by using curly braces from remote server). Use brew install rsync to get a new one.

Mac File System

Which Mac File System Is Best for an External Drive?

Ext4: macFUSE

ExFat: Best drive/partition format to share data between Mac, Linux and OS X

http://superuser.com/questions/398190/what-is-the-best-drive-format-to-share-data-between-mac-linux-and-os-x

  • Mac OS doesn't support writing to NTFS drives.
  • Mac OS can't find ext3/ext4 partition. See some solutions How can I mount an ext4 file system on OS X?
  • NTFS and REFS are a bad choice because Linux and Mac can't properly decode it
  • Ubuntu does not support exFAT by default. To get exFAT support, run sudo apt-get install exfat-fuse exfat-utils
  • exFAT doesn't support symlinks. So the Illumina igenomes data won't work on exFAT partitioned drive.
  • Fat32 has a 4GB single file limit and 2TB partition size.
  • In one case when my NTFS partition (USB drive) is broken, it becomes a format called 'RAW' shown on Windows Disk Management utility.
  • It is easy to create exfat partition format on Windows 7. When I move the USB drive to a Linux machine, fdisk -l shows
$ sudo fdisk -l /dev/sdc
WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sdc: 123.6 GB, 123633401856 bytes
255 heads, 63 sectors/track, 15030 cylinders, total 241471488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5b508967

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048   241469439   120733696    7  HPFS/NTFS/exFAT

For some reason using Disk Utility to erase/format a 16GB USB drive to ExFat failed (Media kit reports not enough space on device). Fortunately the command line method works (and fast at least for the 16GB space case).

diskutil list     # get the name to the disk you're trying to format
diskutil unmountDisk force disk2
sudo dd if=/dev/zero of=/dev/disk2 bs=1024 count=1024 # use bs=4000000 and skip count for an alternative
diskutil partitionDisk disk2 GPT ExFat "toshiba" 0g

use dd command to burn an ubuntu image

The bs parameter on Mac should be 4m instead of 4M.

The USB drive will not be able to start. It will give an error in GRUB step: illegal numeric value. This is tested on Ubuntu 18.04

Find partition type

df -hT

blkid /dev/sda1

mount

sudo file -sL /dev/sd*

sudo fdisk -l

rsync: mkstemp FILENAME failed: Function not implemented (38)

http://blog.marcelotmelo.com/linux/ubuntu/rsync-to-an-exfat-partition/

# Do not use 'rsync -av SRC DEST'

# Use
rsync -rltDv  --info=progress2 SRC DEST

APFS Volume

Add a volume

What Is a Volume and How Do You Add One to the Drive in a Mac?

Delete an APFS volume

How to Delete an APFS Volume from Mac

Install MacOS Catalina Beta on APFS Volume to Dual Boot with Mojave

How to Install MacOS Catalina Beta on APFS Volume to Dual Boot with Mojave

What is the “wheel” user in OS X?

wheel is the system administrator group in BSD, much like root is the system administrator user. See http://superuser.com/questions/191955/what-is-the-wheel-user-in-os-x

/bin/sh and /bin/bash differences

https://discussions.apple.com/thread/3177477?start=0&tstart=0

How to Auto-Hide the Dock With No Delay

http://www.makeuseof.com/tag/auto-hide-dock-no-delay-mac/

Customize the Time and Date in the Mac Menu Bar

How to Customize the Time and Date in the Mac Menu Bar

Hide username from menu bar

https://apple.stackexchange.com/questions/57712/hide-username-from-menu-bar/57715. The other options are to show full name or icon only.

Menu bar color in macOS 14

MacOS Sonoma Menu bar color. Settings - Wallpaper - Colors.

Move icons in the menu bar

Hold the CMD key and then click and drag the icon.

What Does a Green or Orange Dot in the Menu Bar Mean

macOS Monterey: What Does a Green or Orange Dot in the Menu Bar Mean? Green color means an app is using the camera, and orange color means the mic is used.

Move icons in the Dock

drag and drop QUICKLY. Another trick is to drag the icon out of the Dock and put it back somewhere in the Dock.

Extract icons from Mac apps

How to Extract a High Quality Icon From a Mac App

Move a window when the titlebar is not available

https://apple.stackexchange.com/a/231924 If you move the mouse to the right/left edge until you see the horizontal resize icon, then dragging vertically will allow you to move the window instead of resizing. Same goes for the bottom edge resize cursor + horizontal drag (Tested. It works.)

How do I move a window whose title bar is off-screen?

In the case of P4merge's Preference, we just need to maximize the window to see the Cancel & OK buttons.

Don't show recent applications in Dock in Mojave

macOS Mojave: Turn Off Recent Applications to Remove Extra Dock Icons

Minimize windows into application icon

macOS: Tips on Minimizing Windows into the Dock

Connecting to WiFi but no internet

My case:

  • Forget and reconnect my wifi does not help.
  • ping google.com not working but ping 1.1.1.1 works. Change DNS by Preferences - Network - Advanced - DNS by adding 1.1.1.1. Now Chrome works but Outlook or Webex is still not working?? Reboot. Everything is fine.

How can I list my open network ports with netstat?

http://apple.stackexchange.com/questions/117644/how-can-i-list-my-open-network-ports-with-netstat

The 1st column shows the command/program name.

sudo lsof -i -P | grep -i "listen"

nmap localhost
sudo lsof -P -i TCP -s TCP:LISTEN | grep XXXXX

Ethernet status icon

Consider "Ethernet Status" app. Horizon icon in bright color shows the ethernet is connected and grey color shows the ethernet is not connected. Free version works fine and the full version costs $1.99. See the discussion.

Another way is to open "Network Utility" from Spotlight or /System/Library/CoreServices/Applications.

The third way is just open "Network" from System Preferences.

Root account vs admin account

SMB network file sharing

.DS_Store file

Consequences of deleting .DS_Store. In most cases nothing will happen if you delete them, or at worst custom Finder view settings (icon size, position, background color, etc) will be lost.

@ sign in file attributes

# seqtools-dl is a folder extracted from the SeqTools zip file.

# Case 1. the zip file is downloaded through a browser
brbs-iMac:~ brb$ ls -l@ Documents/seqtools-dl/SeqTools.app/Contents/MacOS/code
total 176
-rwxr-xr-x  1 brb  staff  18229 May 15 09:15 createGeneListSNPEFF.sh
-rwxr-xr-x  1 brb  staff   1550 Oct 24  2016 gdown.pl
-rwxr-xr-x  1 brb  staff   4214 May 15 09:15 gdown_mac.sh
-rwxr-xr-x  1 brb  staff  22264 May 15 09:15 statsVariantGeneAnno_Auto.sh
...

# Case 2. the zip file is obtained through the scp command
brbs-iMac:~ brb$ ls -l@ Downloads/seqtools-dl/SeqTools.app/Contents/MacOS/code
total 176
-rwxr-xr-x@ 1 brb  staff  18229 May 15 09:15 createGeneListSNPEFF.sh
	com.apple.quarantine	   57
-rwxr-xr-x@ 1 brb  staff   1550 Oct 24  2016 gdown.pl
	com.apple.quarantine	   57
-rwxr-xr-x@ 1 brb  staff   4214 May 15 09:15 gdown_mac.sh
	com.apple.quarantine	   57
-rwxr-xr-x@ 1 brb  staff  22264 May 15 09:15 statsVariantGeneAnno_Auto.sh
	com.apple.quarantine	   57
...

"App" is not optimized for your Mac and needs to be updated

32-bit app compatibility with macOS High Sierra 10.13.4 and later

Uninstall a program

How to Uninstall Programs on Mac

Case sensitive

In R, it seems to be case insensitive. load("file.Rdata") or load("file.RData") or load("file.rdata") works fine.

Create a Bootable macOS Installer

Make sure you use a USB flash drive or other removable media that has at least 12GB of available disk space.

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia \
     --volume /Volumes/usb16g --applicationpath /Applications/Install\ macOS\ Sierra.app

Reboot, holding down the OPTION key and selecting the “Install OS X Sierra” drive upon boot..

免 USB 開機碟,重灌最原始乾淨的 Mac 系統

https://www.kocpc.com.tw/archives/308906. 唯一缺點是必須處於有網路的環境下.

How to Run macOS Mojave in Parallels For Free

https://www.howtogeek.com/364272/how-to-run-macos-mojave-in-parallels-for-free/

Install to a USB drive

To boot from your external Sierra drive, plug it into the Mac in question, press the power button, and hold the Option key until the recovery disk screen appears. From there, you can select your external drive and click the arrow to boot into it for that session.

How to Install and Use macOS Sierra on an External Drive

https://www.howtogeek.com/293476/how-to-install-and-use-macos-sierra-on-an-external-drive/

How to Burn OS X El Capitan to a USB Flash Drive

http://lifehacker.com/how-to-burn-os-x-el-capitan-to-a-usb-flash-drive-1733425133

Install, Boot, and Run Mac OS X From an External Hard Drive

Pressing the Option key on boot displays a list of your Mac’s bootable drives.

Terminal

Where is the terminal

Macintosh HD/Applications/Utilities/Terminal.

Message of the Day

Change the Terminal Message of the Day in Mac OS X. In my case, I just did mv /etc/motd /etc/motd.bak and I will not receive the annoying message.

Mouse pointer

A temporary solution is to hold the 'Alt' key while moving the mouse in the terminal. This strategy also works on RStudio's code panel.

Another solution is to use iTerm2 instead.

Keyboard symbols

Alt key

What Is the Alt Key on Mac? A Complete Guide

Keyboard shortcuts

The Mac Terminal Commands Cheat Sheet

  • going to the beginning of the line
    • Cmd + left arrow
    • fn + left arrow
    • Ctrl + a (may conflict with the Prefix key I use for tmux)
  • going to the end of the line
    • Cmd + right arrow
    • fn + right arrow
    • Ctrl + e (may conflict with the Prefix key I use for tmux)
  • fn + Down arrow = page down
  • fn + Up arrow = page up

fn/global key

Shell

Check the current shell and the default shell

echo $0      # current shell

echo $SHELL  # default shell

On my 10.14.X, it returns /bin/sh. On 10.15.X, the default will be zsh; see Apple replaces bash with zsh as the default shell in macOS Catalina.

Change the default shell

http://osxdaily.com/2012/03/21/change-shell-mac-os-x/. Open 'Terminal' and click CMD + ",". Click the tab "Shell". On Startup, check "Run command" and type, for example, /bin/bash. Uncheck "Run inside shell". Quit terminal and open it again. It will go straight to the bash shell.

Note that after the change, iTerm app will also have the new default shell after it has restarted.

How to Change the Default Shell to Bash on macOS Catalina

Change default shell to bash on Macos Catalina

Oh My Zsh

How to Uninstall Oh My Zsh on Mac

Changing Your Shell Temporarily

Changing Your Shell Temporarily

Bash vs Zsh

Rename terminal tabs

Click the “Shell” menu and select “Edit Title” to bring up the Terminal Inspector window

Terminal replacement: iTerm2

iTerm2. GPL2 license. Source code is in github.

  • (Update 5/14/2018) Copy from RStudio to iTerm2 R console may mess up. Don't find a solution yet.
  • Save window/tabs on exit?. Works.
  • The HOME/END keys work when I work in a virtual machine. To change font size, go to Preferences -> Profile -> Text -> Font or just use the keyboard shortcut Command + +/-.
  • Copy won't include the background color.
  • We can change the cursor color from grey to anything (Preferences -> Profile -> Colors -> Cursor Colors).
  • It can display image on its terminal using their own utility imgcat. After downloading it, chmod +x and then move it to /usr/local/bin directory.
  • iTerm2 Leaks Everything You Hover in Your Terminal via DNS Requests (9/20/2017)

How I'm still not using GUIs in 2019: A guide to the terminal by Lucas F. Costa

Keyboard shortcuts

Difference between Login Shell and Non-Login Shell?

https://unix.stackexchange.com/a/46856

Shell integration

From my testing, right click menu's "Download with scp" has been greyed out for some unknown reason.

But it can remember directories from open tabs when I quit and restart 'iTerm2'.

Change the title to the current directory

For iTerm2, how do I make the working directory appear in the window title?. The first example below will show the current directory on the title and the 2nd example will show the full path.

echo -n -e "\033]0;${PWD##*/}\007"

echo -ne "\033]0;$PWD\007"

This will work one time. If we switch to another directory, we need to run the command again. Besides, it keeps showing the characters "-ne" after each command.

The follow method can change the title dynamically based on the current directory. The problem is if the prompt already contains the current directory why do we worry about the window's title.

export PROMPT_COMMAND='echo "\033]0;${PWD##*/}\007"'

PS1

If I give PS1="\[\w$ " it will change my prompt from

NCI-12345678-ML:bdge USERNAME$

to

~/github/bdge$ 

where the new one is probably better. We can replace \w with \W to get the directory basename instead of the full path.

The default PS1='\h:\W \u\$ ' is defined in /etc/bashrc.

My El Capitan, I need to create a new file ~/.profile (not in ~/.bash_profile) and put the command there.

export PS1="\w (\!)\$ "

The following choice will not show the hostname nor the current directory name. However the current iTerm2 (version 3.3.0) can show the current directory in the status bar. Preferences > Profiles > Session > Configure status bar (at the bottom of the GUI). export PS1='$ '

See

Color

By default "ls" 1) does not distinguish the colors for files and folders, 2) "ls -G" will shows a very dark blue color for folders. The remedy is Changing color of folders, files, execs on iTerm2

  • add alias ls="ls -G" to .zshrc
  • modify the iTerm2 settings - Profiles - Color. I change the "Normal" blue color in ANSI Colors to "0095ff".

Meta key and nano

https://stackoverflow.com/a/197092 Go to Preferences -> Profiles -> Keys and choose Left option Key acts as: +Esc. This allows me to use 'Option + n' to toggle line numbering.

Infinite scroll back

Preferences -> Profiles -> Terminal -> check the option of "Unlimited scroll back"

iTerm2 + tmux

Remember to change the preference in order to use mouse/touchpad for copy/paste. See Linux > tmux.

iTerm2 + .bashrc + .profile

.bashrc not sourced in iTerm + Mac OS X. Create/edit the file ".profile" and put "source ~/.bashrc". Quit and open iTerm2.

The same trick can be used for ".zshrc" file. By default there is no ".bashrc" nor ".zshrc" file.

This is useful if I want to have colored man page.

Customize the zsh Prompt in the macOS Terminal

My .zshrc

export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'
alias ls="ls -G"
alias grep="grep --color"
alias sshnokey='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
alias scp="scp -p"
alias rsync='rsync --exclude=".*"  --exclude="~*"'
# PROMPT='%F{cyan}%n%f:~$ '   # username
# PROMPT='%F{cyan}%d$ '       # current full directory
# PROMPT='%F{cyan}%1~$ '      # current directory (not full)
# main problem with PROMPT is it will affect the color of ALL text 
# PS1="%B%F{034}%~$%f%b "       # green prompt
PS1="%B%F{yellow}%~$%f%b "      # or red, magenta 
PATH=$PATH:~/Library/Python/3.9/bin  # mainly for 'jupyter-lab'

exit does not close a terminal/tab

You can change the setting by Preferences -> Profiles -> Shell. See https://superuser.com/questions/158375/how-do-i-close-the-terminal-in-osx-from-the-command-line.

Mac Terminal’s Hidden Task Manager to See Background Processes

https://www.howtogeek.com/309273/how-to-use-the-mac-terminals-hidden-task-manager-to-see-background-processes/

terminal fun

Recording the terminal

asciinema

paste text from Clipboard to terminal is not complete

I have not found a solution yet:(

The clipboard service is called pboard. Search in Activity Monitor.

The text in the clipboard can be found by using Finder -> Edit -> Show Clipboard.

How to access clipboard (copy-paste) history on a Mac.

Copy Paste Not Working on Mac? Here’s How to Fix a Stuck Clipboard. Type the following command exactly: killall pboard and press Return. This will terminate and relaunch the pboard process, which is the clipboard daemon for Mac OS.

iTerm2 > Preferences > General > Selection > Applications in terminal may access clipboard?

Executable file/command

Keyboard shortcuts

Keyboard mappings using a PC keyboard on a Macintosh

Mac keyboard: Ctrl -> Option/Alt -> Cmd. Windows keyboard: Ctrl -> Windows -> Alt.

Mac-keyboard.jpg Windows-keyboard.jpg

Lock screen

Shift + control + power

Cut and paste files

http://osxdaily.com/2011/07/29/cut-and-paste-mac-os-x-lion/

  1. Cmd + C
  2. Cmd + Opt + V

External keyboard

How to Fix the Home and End Buttons for an External Keyboard in Mac

Minimize all windows

  • Method 1: Cmd + F3 (min apps go to the RHS)
  • Method 2: Opt + Cmd + H + M

Finder

Command + [: move back to the previous folder

See dummies.com or www.webnots.com.

Navigation in a browser or document

  • Command + up = go to the top of the document
  • Command + down = go to the end of the document
  • Command + f = search
  • Fn + Down arrow = page down (or Spacebar in a web browser)
  • Fn + Up arrow = page up (or Shift + Spacebar in a web browser)
  • Fn + Left arrow = Home
  • Fn + Right arrow = End
  • Ctrl + TAB = switch tabs in browser

Text navigation and selection

12 Keyboard Shortcuts for Navigating & Selecting Text in Mac OS X

  • Select text to beginning of a line – Shift+Command+Left Arrow
  • Select text to end of a line – Shift+Command+Right Arrow
  • Select text to beginning of current word – Shift+Option+Right Arrow
  • Select text to end of current word – Shift+Option+Right Arrow
  • Select text to beginning of all text – Shift+Command+Up Arrow
  • Select text to end of all text – Shift+Command+Down Arrow

Switch input sources

Go to System Preferences -> Keyboard -> Shortcuts -> Input Sources. Check 'Select the previous input source ^Space'. Use Ctrl + Space to switch.

Compare to Windows/Linux

  • Use Command + q to close an application instead of "Alt+F4" on Windows/Linux.
  • System Activity tool:
    • Windows: Task Manager
    • Linux: System Monitor
    • Mac: Activity Monitor

Switch between windows of the same application

Cmd + ` (backtick)

Switch desktops

^ (control) + left/right arrow keys

Switch two screens/monitors

How to quickly move mouse cursor between monitors?

Hardware

$ sysctl -n machdep.cpu.brand_string
Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz

9 Essential Details You Must Know About Your Mac

https://www.makeuseof.com/tag/essential-mac-details/

Where to Buy Refurbished MacBooks

Where to Buy Refurbished MacBooks: The 4 Best Sites

Display resolution

2880x1800 (2880/1800=1.6) on my 15-Inch Retina Display MacBook Pro. According to the Retina Display page on Wikipedia, its PPI (pixels per inch) is 220.

I scale the resolution to 1440x900 (1440/900=1.6; 16:10) to get large font size. Other resolutions have the same ratio include 1280*800, 1680*1050, 1920*1200, and 2560*1600.

Unfortunately Virtualbox (5.1.14) can only give 1440x900 (tested on Ubuntu & Windows). See a workout http://tusharm.com/articles/win7-on-retina-display-with-virtual-box/.

Mini-LED

Lid Closed in Clamshell Mode

How to Use Your MacBook With the Lid Closed in Clamshell Mode

Second Monitor

How to set the primary display on macOS.

  • You will notice that one of the displays has a white bar at the top. This white bar indicates which display is the primary display on macOS.
  • The Dock will jump to the display that you’ve just set as the primary display
  • When you select a display in the Arrangement tab, a red border appears around the screen of the one you’ve selected. This is how you identify which display is which.

External monitor

On Dell U2718Q 27-inch 4K monitor, we can get a larger font size for every app by changing the scaling through System Preferences > Display > Resolution > Scaled. The choices are

  • 1920 x 1080
  • 2560 x 1440 (more comfortable)
  • 3008 x 1692
  • 3360 x 1890
  • 3840 x 2160

On the original macbook pro, the choices are

  • 1024 x 640
  • 1280 x 800
  • 1440 x 900 (more comfortable)
  • 1680 x 1050
  • 1920 x 1200

Another Dell 27 inch monitor. Dell U2723QE 4k Monitor. It provides a PD USB-C port. Manual .

Dell Monitors - S vs P vs U series. S is the entry level (mostly tn panel), P is the professional series (for people who do series work on Photoshop type of work). U is ultra, the highest range.

Home HP 22cwa 1080p monitor

Click on "Display Settings" at the bottom on the Display window.

On the macbook pro (15inch 2018, 2880 x 1800, the ratio is 16:10, not 16:9. That's why the screen is taller), I choose it as 'Main display'. Resolution: Scaled. 1440 x 900 (fill the whole screen).

On the 1080p monitor, I choose as 'Extended display'. Resolution: Scaled. 1600 x 900 (fill the whole screen).

Mirroring display/screen

Duet

Duet Display App

Touchpad

Need to press a little bit (instead of touch) for the left-click effect. If we want to use 'tap' for the click (like other OS), go to the System Preferences to change it.

The right click is called secondary click in OS X. We can enable it by going to System Preferences/Touchpad/Secondary click. Then tapping with two fingers would work. See Change or Disable the Secondary Click in Mac OS X.

Other handy gestures:

  • Scroll: two fingers move up/down. The direction is like moving a paper; i.e. scrolling up will gradually show the next part of the content.
  • Zoom in/out: pinch with two fingers.
  • Smart zoom: double-tap with two fingers.
  • Drag and drop method 1: Use the normal three finger drag, leave two fingers on the trackpad while doing a flicking motion with the third finger (eg thumb). The more momentum you add to your motion, the further it drags.
  • Drag and drop method 2:
    1. highlight the app first
    2. lightly click the app (you should only feel one click. Do not use too much force; if you do, you will hear two click sound and it will pop up a window to show the file information) with your thumb and then use your index to move the app to “Applications” directory.
  • Show desktop: Spread with thumb and three fingers
  • Mission control: Swipe up with three fingers
  • Swipe between full-screen apps: swipe left or right with three fingers
  • Dictionary/Thesaurus: Tap with three fingers

Mouse

Logitech Pebble Wireless Mouse M350. Silent. 18-months battery life.

Scrolling direction for mouse

  • How To Set Different Scroll Direction For Mouse And Trackpad on macOS?.
  • Mos works fine on macOS 14.2 Sonoma. After installing the software (move it to the Application), open its Settings -> Privacy and Security -> Accessibility and Allow Mos to control my computer. Without the software, a PC mouse and trackpad have different scrolling directions. The default options are good and there is no need to change anything.
    • Check the option "Launch on Login" option under the general setting.

Touchbar/touch bar

GPU benchmark

Novabench can benchmark CPU and GPU. The test is quick too. Note watching 4k Youtube videos does not trigger AMD gpu. It only uses a little of Intel Iris Pro gpu.

  • (Novabench ver 4.0.2) The AMD Radeon R9 M370X 2GB (not Intel Iris Pro Graphics) from 2015 macbook pro (2.8Ghz i7, 16GB DDR3) shows usage during the test (Activity monitor -> Window -> GPU History). The overall score is 1620. CPU score=913, RAM score=269, GPU score=323 (Metal 3D: 31 FPS, OpenCL: 842 GFLOPS), Disk score=115 (write speed: 405 MB/s, read speed: 1059 MB/s).

CPU information

sysctl -n machdep.cpu.brand_string

My macbook Pro 2015 shows i7-4980HQ (see GeekBench 4 score) CPU @ 2.80GHz. Quad cores. Eight threads. Base Frequency 2.8GHz. Max Turbo Frequency 4.0GHz. Bus Speed: 5 GT/s DMI2.

CPU temperature and alias

$ gem install iStats
$ istats

# We can make an alias by inserting a line in ~/.bash_profile
$ echo "alias temperature='istats'" >> ~/.bash_profile
$ source ~/.bash_profile

Fan and CPU temperature

When it asks for the admin password for its help tool, no need to enter it (choose 'Cancel') if we don't need to change fan control. See FAQ.

After launching it, it will show an icon on the menubar. It can be configured to show the CPU temperature (CPU Proximity result is close to istats reported) and fan speed.

High CPU usage

How to Fix Xagt.exe High CPU Usage? FireEye EndPoint Agent Security software.

RAM

Can you upgrade the ram in your Mac

Power Adapter

USB-C and Thunderbolt

Keyboard

Terrible keyboard

How to file a claim in the MacBook butterfly keyboard lawsuit

Latest Macbook pro's keyboard layout is terrible. Keys are too crowded and the arrow keys are way too tiny and unusable. The touchbar version of macbook is even worse. 👎

Some alternatives:

Adding a Period after the Double Space

Magic Keyboard Home and End keys acts as Page Up and Page down

[https://apple.stackexchange.com/a/440785. Home doesn't move to the beginning of the line in macOS; that's a Windows thing. On Mac Home is 'scroll to the top', End is 'scroll to the bottom', the cursor doesn't move.

Cmd/left or right arrow moves to the beginning & end of line.

Remap Keys Using a Third-Party Keyboard

How to Use & Customize a Third-Party Keyboard on Your Mac

Keyboard battery level

macOS 10.11.6 shows the battery level is 18%.

macOS 10.12.6 corrected the calibration problem. Now it is showing 58%.

Bluetooth keyboard (AA battery version) battery life

I got a little over 3 months of battery life.

Bluetooth connection

It will ask to enter a few keys shown on the screen before connection.

It is interesting the keyboard will show as "Full Name [E]'s Keyboard" on the macOS's menu bar.

Battery

How to Keep Your MacBook Battery Healthy and Extend Its Life

Charging on hold/Optimized Battery Charging

If battery charging is paused or on hold on your Mac

Plug or unplug

Should I disconnect my MacBook Pro's power cord when the battery is fully charged?. Answer: No.

Battery diagnostic

About this Mac -> Overview -> System report -> Power.

Cycle count limits for my macbook pro 15inch Mid 2015 (shown from About This Mac) is 1000.

  • The current cycle count currently is 175 cycle count (10/20/2017). Full charge capacity (mAh) is 8421.
  • The current cycle count currently is 199 (Feb 7, 2017 -> Nov 29, 2017). Full charge capacity is 8076.
  • The current cycle count is 263 (Mar 2, 2018). Full charge capacity is 8096.
  • The current cycle count is 430 (Oct 10, 2018). Full charge capacity is 7554.
  • The current cycle count is 437 (Oct 19, 2018). Full charge capacity is 7073 (80%).

The Chargeberry app shows the factory capacity is 8755 mAh.

Ambient light sensor

http://osxdaily.com/2010/05/22/where-is-the-ambient-light-sensor-on-a-macbook-pro/

SSD

How to check your Intel and M1 Mac’s SSD health using Terminal and smartmontools.

Too hot: remove the cover, cleaning

How to Clean Dust Out of Your MacBook

Complaints

Macbook Pro 2015 & 2018

  • Even the lid is closed, the fan is turning loud (6000 RPM for both fans, something is running?) parentalcontrolsd uses 248% cpu and the CPU temperature 50+. Router showed the machine's wifi is still on. The battery is drained out fast when I open the lid: Hazard!!
  • After I open the lid, the screen can not be unlocked. I only see the mouse cursor.
  • Wifi cannot automatically connect
  • Freeze (no response after clicking a program) after sleeping.
  • Restart does not work. Force to push the power button to shutdown the machine.

Mac mini

5 Reasons the M2 Mac mini Is the Best Entry-Level Mac You Can Buy

iMac Pro

The new (2017) iMac Pro can be equipped with a 128 GB of memory and 4 TB SSD drive.

Finder - file manager

Quick Look, Preview

Freeze/frozen

It happened when I try to use AirDrop. How to Quickly Restart or Relaunch Finder in macOS.

killall Finder from Terminal

Add to Sidebar / bookmark

File -> 'Add to Sidebar'

Remember all my tabs and reopen them after restarting

Permanently delete files

  • Note that CMD + delete will move files to the Trash
  • Option + CMD + delete OR File + Option -> Delete will permanently delete files
  • To see files in the Trash, click Finder -> Go -> Go to Folder -> enter "~/.Trash/" (no double quotes) and press ENTER.

Change font size

View -> Show View Options -> Text Size

Folder Date Modified

When I open an Excel file or a Word file, even I don't modify anything the Date Modified of this folder containing the file will be changed. Very annoying! I think a more reasonable way is to change its setting. View -> Show View Options. Unselect "Date Modified" and check Date Added.

Show the full file path

How to Show Current Path in Mac OS X Finder. View -> Show Path Bar.

Copy file full path

How to View File Paths in macOS

This is important since RStudio cannot drag and drop a file to insert the file path.

  1. Navigate to the file or folder you wish to copy the path for
  2. Right-click (or Control+Click, or a Two-Finger tap/click on the trackpad) on the file or folder in the Mac Finder
  3. While in the right-click menu, hold down the OPTION/Alt key to reveal the “Copy (item name) as Pathname” option, it replaces the standard Copy option
  4. Once selected, the file or folders path is now in the clipboard, ready to be pasted anywhere

Cf. On Ubuntu, it is much simple. Just click Ctrl+C.

Enter key does not open the file

Use Command+Down instead of Enter key to open a file or go into a directory.

Enter key is only used to rename a file. See https://discussions.apple.com/thread/3140356?start=0&tstart=0.

Use Command+Down will immediately uncompress a tar.gz file.

Go to the previous/next folder

  • Cmd + [
  • Cmd + ]

Go to a folder

Use Cmd+Shift+o to go to a specific location by entering its full path. Unfortunately this option is not available in other applications in general.

Permanently mapping a network drive

Users & Groups

In System Preferences -> Users & Groups. Click Login Items tab. You will see all item (e.g. NCIMacDriveScript) that will open automatically when I log in. The item location can be found by right clicking the item.

Tag

How To Tag Files on a Mac, iPhone, or iPad

Alternative: Commander One

(Free & commercial) dual pane file manager for Mac.

  • User Guide
  • The bookmark is called 'Favorites' in Commander One. Click the 'star' icon and a Windows' style of a right click menu will pop up. You can select 'Add to Favorites' to add the current directory to the favorites. This bookmarked location will be shown when you click the 'star' icon next time.
  • The icon (multiple horizontal lines) next to the 'star' shows the recent locations. This is useful too!
  • By default, Commander One will send anonymous usage statistics to Eltima. Go to Preferences -> General to uncheck this option.
  • This Finder replacement solution also provides its users with the various ways of search.
  • Cloud Storage Compatibility

Alternative: Nimble Commander

Right click open with

Remove Duplicates from the “Open With” Right-Click Menu in Mac OS X

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\     
LaunchServices.framework/Versions/A/Support/\
lsregister -kill -r -domain local -domain user

killall Finder

Find files

The 5 Best Spotlight Alternatives for Searching Mac Files and More

FTP clients

The 5 Best FTP Clients for Mac

Cloud file manager

Cyberduck. Cyberduck is a libre server and cloud storage browser for Mac and Windows with support for FTP, SFTP, WebDAV, Amazon S3, OpenStack Swift, Backblaze B2, Microsoft Azure & OneDrive, Google Drive and Dropbox.

Open rar files

The Unarchive‪r‬ from Mac App Store.

Screenshots

Terminal

Use the screencapture command.

screencapture test.jpg

screencapture -c    # send to the clipboard

screencapture -T 10 timedshot.jpg # timer 

screencapture -w test.jpg
# OR
screencapture -W

screencapture -h     # help

To view an image file, use the open command. See also Shell tricks: the OS X open command.

open test.jpg

To view the metadata of an image file, use the mdls command such as mdls XXX.png. See How to look up file metadata in OS X

Grab

Grab is a utility. Finder -> Go -> Applications -> Utilities -> Grab.

How To Use macOS & Mac OS X Grab Utility To Take Screenshots

Take a Timed Screenshot With the Grab (built-in) Application. Open Grab, select Capture -> Selection/Window/Screen/Timed screen.

Lightshot

Lightshot works like Shutter in Ubuntu - easy to use and can sit on the taskbar.

Note: to view an image resolution in Finder, right click an image and select Get Info -> More Info.

Its icon is a feather.

Feather has an advantage that the screenshot does not need to be saved. It can be copied to a clipboard and then discarded.

Screen cast/recorder

MacOS Big Sur, Catalina, & Mojave

How to Make Screen Recordings in MacOS Big Sur, Catalina, & Mojave. Hint: Shift + CMD + 5. Note audio is not recorded. Note that I did not see the control panel anymore. But luckily I can use the touch bar to stop recording (or Command-Control-Esc). How To Record Screen On Mac With Audio & Without Audio?

How to Record Screen on Mac with Sound using a commercial software like Capto or Screenflick.

iPad/iphone

How to Record iOS Screen with Sound in Simple Clicks. The only problem is the file size could be very large.

Quicktime/QT player

  • We can record the screen (full screen or a selected region). The recorded file will be in a .mov format and saved in the Desktop (no setting to change the default directory).
  • How to record the screen on your Mac
    • Method 1: Shift + Cmd + 5
    • Method 2: Quicktime. File - New Screen Recording. Choose 'Entire screen' or 'Selected portion'. Then click the 'Recording' button to start recording. When finished, click the white circle on the top taskbar to stop recording. By default, the movie files (*.mov) are saved in my home directory.

Screenshot utility

  • How to use QuickTime to record screen and audio: Ultimate Guide
    • Tip1: Click Options, and then choose [your Mac name] Microphone if you want to record your voice to add narration to the video. The default is None.
    • Tip2: To stop recording the screen, press the CMD + Control + Esc keys. OR CMD + Shift + 5 to bring up the toolbar and press the STOP button.
    • Note: File size could be very large. For example, 19 seconds video & 2270x1548 will be 85 MB.

recordit

Screen cast o magic

http://screencast-o-matic.com/

LICEcap

LICEcap. See Harmony animation.

Application

How to Install Applications

Trouble shooting

XXX can't be opened because Apple cannot check it for malicious software

https://youtu.be/6knyHlUe1cM?t=1205. Open Preferences - Security & Privacy - General. Click 'Open Anyway'.

The binaries are not signed

Consider the yarr(Yet Another RSS Reader) application, to bypass these measures, you can run the command:

xattr -d com.apple.quarantine /Applications/yarr.app

Damaged App Cannot be Opened on MacOS Error

FIX: Damaged App Cannot be Opened on MacOS Error

Gatekeeper

How to Disable Gatekeeper to Allow App Installation from Anywhere in macOS

Keyboard shortcut to launch an application

  • F4 key - LaunchPad
  • Command + Space - Spotlight search

Messages when you launch an application

  • Google Chrome

ChromeMac.png

  • iTerm

Iterm open.png

  • SeqTools

Seqtoos open1.png Seqtoos open2.png Seqtoos open3.png

Install pkg file from command line

http://apple.stackexchange.com/questions/15658/how-can-i-open-a-pkg-file-manually

sudo installer -pkg ~/Downloads/packagename.pkg -target ~/Applications/
# OR
installer -pkg ~/Downloads/packagename.pkg -target ~/Applications/

Close an application

Clicking the red button does close/quit an application/a program. You need to use Command-Q.

Another answer: The red close button just closes the window. It is up to the application whether it quits or not - typically if the application uses documents or it has other windows that can be opened it will not quit. Applications with a single window (System Preferences, for example), will usually quit when the window is closed, since there isn't anything else it does.

Delete/remove an application

AppCleaner

How to Add, Remove, and Delay Startup Apps on a Mac

How to Add, Remove, and Delay Startup Apps on a Mac

RSS Reader

Need an RSS Reader for iPhone, iPad, or Mac? Get NetNewsWire

Package formats

app directory/Application

In Finder, the attribute of the file is an Application.

Example: App Store.app, Atom editor, SourceTree

http://apple.stackexchange.com/questions/112197/what-does-a-app-file-actually-do

apps are "Package Bundles" is Apple jargon. These are actually Unix directories, in a special format. The actual Unix Executable File is in a subdirectory named MacOS, which you can see using the Show Package Contents menu in Finder.

To deliver the program in an app format, we can zip the app folder. If we use Safari browser, it will automatically decompress the zip file so the app program will appear in the Downloads directory.

For example, in SourceTree, the download file is called 'SourceTree_X.Y.zip'. When we click the zip file, it will be automatically extracted. And when I click SourceTree.app, it will have a dialog to help user to move the program to the application folder.

Sourcetree.png

pkg file

Example: R-cran

PKG files are Mac OS X installation (setup) packages that contain installer scripts ('Scripts' file) and compressed installation files ('Payload' file) that are used to install Mac software applications onto a user's hard drive.

On the case of R-x.y.z.pkg, it contains R framework, R.app GUI, Tcl/Tk X11 and TexInfo.

To install a pkg file from terminal, see this post

sudo installer -pkg R-3.3.3.pkg -target /

pkgutil

dmg (disk image) file

Example: Google chrome, JDK, FastQC, Sketchup, Commander One.

A DMG file is a disk image, which is sort of like an archive file. When you download one, you can double-click it to “mount” it (under Devices in the Finder), allowing you to extract the application from inside it.

After the app is dragged to your Applications folder, you can run it normally — from the Finder, Launchpad, Spotlight, dock, or anything else.

We can mount or eject a dmg file by

# mount
hdiutil mount fastqc_v0.11.5.dmg
# copy its content
mkdir -p ~/FastQC
cp -r /Volumes/FastQC/FastQC.app/Contents/MacOS/* ~/FastQC/
# eject
hdiutil eject /Volumes/FastQC/

To create a dmg file (see command line or here and GUI)

hdiutil create -volname WhatYouWantTheDiskToBeNamed \
    -srcfolder /path/to/the/folder/you/want/to/create \
    -ov -format UDZO name.dmg

To convert a dmg file to iso

hdiutil convert imagefile.dmg -format UDTO -o imagefile.iso
mv imagefile.iso.cdr imagefile.iso

To install a dmg file from terminal, see this or this

MOUNTDIR=$(echo `hdiutil mount jdk-8u121-macosx-x64.dmg | tail -1 \
| awk '{$1=$2=""; print $0}'` | xargs -0 echo) \
&& sudo installer -pkg "${MOUNTDIR}/"*.pkg -target / \
&& sudo hdiutil detach "${MOUNTDIR}"

Explanation: The first command (hdiutil mount jdk-8u121-macosx-x64.dmg) will output

expected   CRC32 $628D96B6
/dev/disk2          	GUID_partition_scheme          	
/dev/disk2s1        	Apple_HFS                      	/Volumes/JDK 8 Update 121

We like to grab the string "/Volumes/JDK 8 Update 121". This can be achieved by getting the last line of the output and replace the first and 2nd fields with empties and then output the whole line.

Package manage software

http://apple.stackexchange.com/questions/32724/what-are-pros-and-cons-for-macports-fink-and-homebrew & http://apple.stackexchange.com/questions/64690/macports-vs-fink-vs-homebrew

MacPorts

Different versions of Mac OS X has a different macport binary (in .pkg format).

MacPorts Brings the Best Open Source Software to Your Mac

Homebrew

Homebrew installs packages to their own directory and then symlinks their files into /usr/local. Setting up macOS as an R data science rig in 2023

# Install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# It will ask around 3 times on your administrator password for a variety of questions.

Warning: /opt/homebrew/bin is not in your PATH.
  Instructions on how to configure your shell for Homebrew
  can be found in the 'Next steps' section below.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/USER/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh
# Search a package
brew search gedit

# install some package
brew install wget
brew install htop
brew install ruby # install a newer version of ruby & gem; overwrite the pre-installed one 
brew install cvs
brew install gedit # The print to file function works great. need to launch from terminal
                   # https://formulae.brew.sh/formula/gedit
which htop        # /usr/local/bin/htop

# Update brew
brew update  # Not add sudo
# Uninstall homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

brew cask. While Homebrew primarily deals with command line software, Homebrew Cask is used for installing desktop applications. It provides a friendly command-line interface (CLI) workflow for the administration of macOS applications distributed as binaries.

Applications installed via Homebrew Cask are typically placed in the /Applications directory and can be launched like any other Mac application. You can also open the application in Terminal: open -a Firefox where "-a" means to open an application.

brew search calibre
brew search kindlegen
brew search vlc
brew info calibre
brew install --cask calibre
brew uninstall --cask calibre

# https://www.code2bits.com/how-to-update-homebrew-cask-formula-on-macos/
brew update             # Fetch latest version of homebrew and formula.
brew list               # List all the installed formulae.
brew outdated           # Show formulae with an updated version available.
brew upgrade            # Upgrade all outdated and unpinned brews.
brew upgrade [formula]  # Upgrade only the specified brews (but do so even if they are pinned)
brew pin    [formulae]  # Pin the specified formulae (Prevents from being upgraded - 'brew upgrade').
brew info   [formulae]  # Display information about formula.
brew cleanup            # For all installed or specific formulae, remove any older versions from the cellar.

brew tap command.

How to uninstall / remove a Homebrew package including all its dependencies

Homebrew Cast extends Homebrew and brings its elegance, simplicity, and speed to macOS applications and large binaries alike. What is the difference between `brew` and `brew cask`?.

Fink

No binary installer for recent versions of OS X (good to me). You will need to install the proper Command Line Tools for Xcode for your system.

Rudix

# install
curl -s https://raw.githubusercontent.com/rudix-mac/rpm/2016.12.13/rudix.py | sudo python - install rudix
# install some package
sudo rudix install wget
sudo rudix install python-pip
# remove a package
sudo rudix remove python-pip
# uninstall
sudo rudix -R

Extract files (Unzip)

Unarchiver. Mentioned by Raspbian.

Remove __MACOSX directory and .DS_Store files in zip files

zip -d data.zip "__MACOSX/*"
zip -d data.zip "*/.DS_Store"

Preview/edit photos

To remove exif information, use ImageOptim program (open source). See an introduction here.

Exiftool is a command line tool available in Linux/Mac/Windows. See Remove GPS metadata from jpg files - exiftool.

Best Preview Features

https://youtu.be/X5iZTXAg8vs

Shape and filler

Find the icon next to "A" on the toolbar. Click the 'down' arrow and select the one with a red diagonal line. This will remove filler in the shape.

https://youtu.be/MOnHrtiH2HU?t=222

Markup toolbar

Combine images

3 Quick Ways to Combine Photos Into a Collage on macOS

Image editor

Note when I use the 'Preview' program, it will automatically save the changes without any warnings when I exit the program.

Pixea

Viewing only.

  • It has an option to show thumbnails (browse the contents of folders and archives w/o extracting them).
  • Including a Slideshow function.
  • But it is not suitable if we just want to open a few image files and toggle between them (GIMP works in this situation).

qView

website. Open source, cross-platform. But it does not do panning.

Paintbrush

https://paintbrush.sourceforge.io/

Works fine. It does prompt to save for any changes when I quit the program.

macSVG

https://macsvg.org/

Convert images to different formats

How to Convert PNG, TIFF, and JPEG Images to a Different Format on Your Mac

Photo collage

3 Quick Ways to Combine Photos Into a Collage on macOS

To stitch them horizontally, use the following (it works when I tested on Mac Ventura 13.5)

brew install imagemagick
convert +append 1.jpg 2.jpeg 3.jpg ~/Desktop/Result.jpg

To combine photos vertically, replace +append with -append.

Text editor

http://beebom.com/best-text-editors-for-mac/

For printing to pdf files with line numbers, I am using GEdit in Ubuntu VM. Some promising editors like BBEdit cannot even let me open rmd files.

Change the default text editor

Just right (or control) click a file of the type you want to change and: "Get Info" -> "Open with:" -> (Select your program) -> "Change All".

The above method can be used to change the default player too (iTune -> VLC).

If you use the open command in a terminal to open a text file, the default program will be used.

Replace nano editor

The default nano editor is too old (2.0.6). It is located at /usr/bin folder.

Using homebrew (brew install nano) we can update it to the latest version. The new nano is located at /usr/local/bin/ folder.

Note that echo $PATH shows /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Tex/texbin:/opt/X11/bin.

$ which nano
/usr/local/bin/nano
$ whereis nano
/usr/bin/nano
$ nano --version      # Still 2.0.6
# Close the terminal and open a new one
$ nano --version      # 4.2

Atom editor from Github

Complains: too frequent updates. It makes multiple instances on the right click menu in Finder on macOS (seems it is only a problem on Mac). See a report here. A solution is

rm -rf ~/Library/Caches/com.github.atom.ShipIt 
killall Finder

and then launch Finder manually.

Atom Flight Manual

  • The atom application requires no installation. So once it is downloaded (we actually download a zip file. After download has finished Safari browser will automatically decompress the zip file), we can drag it to the Application folder.
  • Open atom from a terminal.

Method 1 (GUI). Atom -> Install Shell Commands. Two symbolic links (atom and apm) will be created in /usr/local/bin to point to the currently opened Atom application.

Method 2 (Manual):

ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom
  • When you open the Atom the first time, it will split the screen into two panes: on the LHS it has a 'Welcome' and on the RHS it has a 'Welcome Guide'. You can choose to close any one of them by View -> Panes -> Close Pane. You may reopen the Welcome Guide by Help -> Welcome Guide.
  • You can hide the directory on the left hand side by View -> Toggle Tree View.
  • Command Palette: Press Cmd+Shift+P.
  • Settings: Atom -> Preferences.
  • Open a file: Cmd+o. Save a file: Cmd+s.
  • If a file is modified and not saved yet, the changes are saved to a cache. Even we close Atom, the changes are there. The original file is still intact.
  • Open a directory as a project. Open a folder will add a tree view to the editor where you can browse all the files. You can toggle the tree view on the side of the window by Cmd+\.
  • Jump to a specific line: Ctrl+g.
  • Find and replace: Cmd+f. To search the whole project, Cmd+Shift+f.
  • Folding: Alt+Cmd+[ and Alt+Cmd+]
  • Panes splitting: Cmd+K Up/Down/Left/Right
  • Preview a markdown file (toggle): Ctrl+Shift+M
  • R syntax highlight
$ apm install language-r
Installing language-r to /Users/USERNAME/.atom/packages ✓
# Re-start Atom to enable it

Printing. No way!

Visual Studio Code

VS code is based on Electron and Atom shell archive. Repeatedly "trying to add a new helper tool" on each restart for same application(s).

Macdown- markdown editor

If I use macDown to open a text file, macDown will still assume the file is a markdown file and give a preview on the right panel.

Sublime

http://www.sublimetext.com/

How do I open new files in a new tab?

TextMate

http://lifehacker.com/5817833/the-best-programming-text-editor-for-mac

For some reason when I open an old file, TextMate does not open it on a new tab; it opened the file in a new window??

BBEdit

5 年過去了,知名文字檔編輯軟體 BBEdit 回歸 Mac App Store

gedit

http://macappstore.org/gedit/ Does not work. I got the same error.

Jekyll

http://idratherbewriting.com/documentation-theme-jekyll/mydoc_install_jekyll_on_mac.html

Text to speech

Dictionary

Expand Your Mac’s Dictionary App by Adding Additional Languages

I add 'Simplified Chinese - English' dictionary and move it to the top. With the change, when I right click a word and choose 'Look Up' in a browser, the 'Simplified Chinese -English' will be shown up on top.

Videos

How to Trim Videos with Quick Look in macOS Mojave

imovie

Final Cut Pro

Java

Installing OpenJDK 11 on macOS Mojave. The instruction works for Java 12.

ls /Library/Java/JavaVirtualMachines/ # empty but the folder does exist
sudo mv jdk-12.0.1.jdk /Library/Java/JavaVirtualMachines/
java -version
javac -version
cat > hello.java <<EOF
class HelloWorld {
     public static void main(String[] args) {
         System.out.println("Hello World!");
     }
}
EOF
javac hello.java
java HelloWorld

Printer

To print a test page: Mac -> System Preferences > Printers and Scanners. Double click a printer, go to the menu on top and select Print -> Print Test Page.

When installing an office printer (\\nciprint\5W012CAN5560, Canon iR-ADV C5550/5560 UFR II), mac asks for the driver (1. Generic PostScript Printer 2. Generic PCL Printer 3. Select Software). If I choose Generic PostScript Printer, the test page shows the driver name "Generic.ppd" and version 1.0. When I download the driver from Canon website and add the printer using the new driver, the test print page shows driver name CNPZUIRAC5550ZU.ppd.

PDF

Disable autosave

Open System Preferences, Go to "General", Enable "Ask to keep changes when closing documents"

Markup toolbar

How to Circle or Highlight Items with Preview on Mac (video).

Preview Cant Open Multiple PDF in same Window

https://apple.stackexchange.com/a/303731 System Preferences > (Select) Dock > (Go down to 5th option) Prefer open tabs when opening documents: > (Select from option menu) Always.

How to Set All Mac Apps to Prefer Tabs with New Document and Windows

Print to PDF from the print dialog

In the Print dialog, look for the “PDF” button in the lower left corner, click on that pull-down menu, and select “Save as PDF”. Click “Save” in the save dialogue box, and save the file to whatever location you want.

Command line to print a file to pdf

# Suppose we have an R file. We like to print it to PDF with line numbers.
$ cat -n tmp.R > tmp.txt
$ cupsfilter tmp.txt > tmp.pdf

# OK. But how to control the font size? How to deal with indentation for line wrapping. Landscape orientation.
  • text2pdf
  • Use pandoc to convert it to docx (so we can control font size) and convert it again to PDF.

Convert a pptx to pdf

The 'Zoom' function is kind of slow to response with Office 2016. There is no this problem with converted PDF file.

  • Use 'Save As...'
  • Don't use print to PDF. The quality will reduced.

Delete/add/reorder page pages using Preview

http://osxdaily.com/2010/01/20/delete-pages-in-a-pdf-document/

There is no need to save the document. It will be saved automatically.

For some reason, after I join pdf files and export the merged pdf, the exported file contains only 1 page.

A more reliable way is to use a built-in command line program 'join.py' (works on OS X El Capitan)

# Use Cmd + c to copy PDF files relative paths from /home/$USER/Downloads directory

cd /User/$USER/Downloads/
"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" \
  -o FILE.pdf \
  file1.pdf file2.pdf /PATH/TO/A/WHOLE/DIR/*.pdf

Print multiple pages per sheet

"Preview" does not have this option. Use Adobe Reader.

Merge/combine several PDF files

How to Use Mojave’s Quick Actions to Quickly Combine PDFs on the Mac

Crop pdf files

Preview. See a demonstration on youtube. This is very good and the crop experience is similar to briss.

  1. View → Thumbnails
  2. Select all pages by Cmd+a. Use Cmd+click to unselect any pages.
  3. Click the Show Markup Toolbar button from the RHS of the toolbar and click the Rectangular Selection button or directly click on Tools → Rectangular Selection
  4. Use mouse to select an area on the first page (or on a specific page). A rectangular area will show up on ALL pages.
  5. Adjust the width/height as you want from the 1st page (or from the specific page).
  6. Close the document and the changes will be automatically saved.

Note that this method cannot save the cropped PDF file permanently. A better way is to use briss. After we install Java runtime library (see #Java here), we can run briss from a terminal

java -jar briss-0.9.jar

Undo cropping of pdf files

How do I uncrop a PDF in Preview? Zoom out so you can have what would be the whole page in view. Use the selection tool to select an area at least as big as the original page. Recrop the image to the new selection, and voilà!

Edit (eg highlight) by Preview

Search woe in Preview

It seems enclosing the phrase in quotation marks does not work. But clicking the magnifying glass icon in the search field and selecting “Exact Phrase” from the drop-down menu.

Preview Keyboard shortcuts

  • Hide sidebar: CMD + Option +1
  • Show sidebar: CMD + Option +2
  • Show Table of Contents: CMD + Option +3

Kill Preview

Using the command line: killall Preview

Open Preview

It seems Preview will remember closed documents after close and re-open.

The volume can't be ejected because it's currently in use

How to fix.

sudo lsof | grep /Volumes/Elements
sudo killall mds
diskutil unmount /Volumes/Elements

Icon/symbol next to opened documents under 'Window' menu

https://developer.apple.com/design/human-interface-guidelines/macos/menus/menu-anatomy/

  • Checkmark: the active document
  • Diamond: document that is currently minimized in the Dock.

Disk

Trash can

See its icon in the Dock.

Using the trash folder

Alternative to WinDirStat

https://alternativeto.net/software/windirstat/?license=free&platform=mac

  • ncdu
brew install ncdu
  • Disk Inventory X. It shows the sizes of files and folders in a special graphical way called "treemaps". The filename is DIX1.0Universal.dmg. It froze my Mac:(
  • QDirStat based on Qt. No binary for macOS
  • DaisyDisk $10.

system taking too much space

It takes over 327GB on my macbook pro. I run sudo mdutil -E /, change spotlight search categories to only 'Applications', 'Mail & Messages' and reboot the computer. Now the system is taking only 83GB (more acceptable). Some cleanup software does little help and ncdu command broke during scanning the root directory.

Outlook took too much space

Message Attachments in Outlook 2016 for Mac

I found out the issue when Druva inSync needs to sync 3.8GB data. Further investigation shows it is backing up lots of files under ~/Library in Home Folder. ncdu shows the folder "~/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/Message Attachments" took 9.3GB space.

Increase space

How to Increase Your MacBook’s Storage

Clean Drive from Parallels

https://kb.parallels.com/en/124591

Browsers

Google Chrome browser

Read articles

Google app for iOS can now read articles aloud with a tap.

For Android users which was powered by Google Assistant, simply asking “Hey Google, read this article (page)” would pull the content of the page into a new interface that plays it word-by-word.

Fix issues with "Hey Google" on a mobile device

Safari

Read out loud

How to Use Spoken Content to Make Your Mac Read Out Loud to You

Developer

Macs (unlike Linux) don’t come with a package manager, but there are a couple of popular package managers you can install. See SciPy.

Install Xcode

http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/

Note:

xcode-select --install

The installed tools (like ar, gcc, g++, git, libtool, make, nm, otool, svn, et al) are located in /Library/Developer/CommandLineTools/usr/bin/ directory. If the command is run again, you will get a message

xcode-select: error: command line tools are already installed, use "Software update" to install updates 

To check the Xcode version (if you have installed a full Xcode)

$ xcodebuild -version  # if you have the full Xcode installed
Xcode 8.2.1
Build version 8C1002  # if you only have the command line tool installed
$ xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer 
directory '/Library/Developer/CommandLineTools' is a command line tool instance

To check whether Xcode has been installed

$ xcode-select -p
/Library/Developer/CommandLineTools             # if you have installed the command line tool only
# or
/Applications/Xcode.app/Contents/Developer  # if you have the full Xcode package installed
# or
xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one
(or see `man xcode-select`)

To accept the XCode license through command line, follow the post Debugging macOS Kernel using VirtualBox:

$ sudo xcodebuild -license accept # it seems not working. A dialog is still popped up.

The df command shows installing the command line developer tools takes about 600MB space.

git

The "git" command requires the command line developer tools. Would you like to install? I got this message when I open RStudio.

Uninstall Xcode

http://osxdaily.com/2012/02/20/uninstall-xcode/

Header file location

  • /usr/include (does not exist on my 10.12 Sierra)
  • /usr/local/include (some are over there; e.g. from "sudo make install" command)
  • /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/ (if you have installed a full Xcode)

I get the following error

In file included from init.c:1:
/Library/Frameworks/R.framework/Resources/include/R.h:55:11: fatal error: 'stdlib.h' file not found
# include <stdlib.h> /* Not used by R itself, but widely assumed in packages */
          ^~~~~~~~~~
1 error generated.
make: *** [init.o] Error 1
ERROR: compilation failed for package ‘later’

when I install some package. The stdlib.h file is missing from /usr/local/include. However, a simple C code compiles fine.

#include <stdio.h>
#include <stdlib.h>

int main ()
{
  char str[10] = "3.14";
  printf("The value is %f\n",atof(str));
  return 0;
}

See this post (R-SIG-Mac) 'math.h' file not found

sudo installer -pkg \
  /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg \
  -target /

However, I don't have "Packages" directory.

See Where is my “stdio.h” in Mac? & Simply installing Xcode will not install all of the command line developer tools. Try

  • Run "sudo ln -sf /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /usr/include". Get a message "Operation not permitted". See this post Unix “ln -s” command not permitted in OSX El Capitan Beta3
  • Run "xcode-select --install". Get a message "Can't install the software because it is not currently available from the Software Update server."

Search within R-SIG-Mac Archives.

System Integrity Protection/SIP

Lib location

  • /usr/lib
  • /usr/local/lib
  • /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib/ (if you have installed a full Xcode)

ldd on Mac

otool -L  <exec>

openssl

Method 1: brew

brew doctor
brew update
brew upgrade
brew install openssl  # the opposite operation is 'uninstall'
cd /usr/local/include
ln -s ../opt/openssl/include/openssl .

Method 2: compile yourself

Python packages

http://www.scipy.org/install.html

Install macOS on a PC

http://www.makeuseof.com/tag/how-to-install-mac-os-x-on-a-pc-without-using-a-mac/ (7/17/2017)

KVM

Docker: macOS in Docker

UTM

How to Run Windows on Your Mac for Free with UTM

VirtualBox

Touchpad

The direction of scrolling up and down in guest machine is opposite to the host machine.

Keyboard shortcuts (macOS + Windows keyboard)

Since there is no Command key on Windows keyboards, we need to modify preferences.

Copy and paste: go to preferences -> keyboard -> Modifier keys. Change 'Option' key to 'Command' key and 'Command' key to 'Option' key. Since the 'Option' key is 'Alt' on Windows keyboards, the layout will be very similar to using Mac keyboards. This is consistent with Logitech K780 multi-device keyboard where 'Alt' key shares with the 'Command' key.

Do not use Ctrl to replace Command; you will not able to use the Ctrl key in nano and you are missing Ctrl + a to move mouse to HOME in Terminals. NOTE: iTerm2 is a good replacement for macOS's built-in Terminal program; HOME/END works.

Keyboard shortcuts (Windows OS + mac keyboard)

  • Left CMD is used by VirtualBox to switch to full screen (at least on VirtualBox)
  • Right CMD = Windows key
  • fn + delete = DEL/Backspace key

Guest additions

VirtualBox doesn't have guest additions for OSX. http://askubuntu.com/questions/372982/virtualbox-4-3-guest-additions-on-osx-guest

In order to share files between the host and guest machine, we need to 1. add 'host-only' network adapter to the guest machine and 2. enable 'Remote Login' by going to the System Preferences -> Sharing.

For example, from the host machine, I can use the following on the host machine to access the guest machine

$ ssh [email protected]

However, it is unsuccessfully to do access the host machine from the guest machine??

$ ssh [email protected]

Smart card reader

If USB is enabled in the guest machine, the Smart Card reader will not be available on the host machine. That is, we cannot use the smart card in Mac. So it is necessary to uncheck the USB from the USB setting in the guest machine.

Screen resolution

https://forums.virtualbox.org/viewtopic.php?f=22&t=54030 works.

$ VBoxManage setextradata "vm_name" VBoxInternal2/EfiGopMode 4

The number '3' corresponds to a resolution of 1280x1024 (5:4) and '4' corresponds to 1440x900 (8:5). On lenovo laptop (1600 x 900, 16:9), the height will fill the screen but there are little black spaces on both sides. See Display resolution and aspect ratio.

Note that I need to enable Full Screen for the guest machine b/c the desktop is too large.

El Capitan (10.11)

It works on my VirtualBox 5.1.14 and Macbook Pro 2015.

Note: if I skip the following commands, the macOS booting will keep re-run again and again.

VBoxManage modifyvm macElcapitan --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1   

Con: The image downloaded there is already a virtual machine image format.

If I try to use the iso file downloaded from internet, I saw an error "Missing Bluetooth Controller Transport" (https://gist.github.com/frdmn/de12c894a385bc8e6bff).

Sierra (10.12)

  1. Enable Picture-in-picture. It works on Safari and Chrome browsers. Right click on a video and then immediately right click again. It will show an option "picture in picture" in the right-click menu. This is cool but it seems there is no way to control the video except play/pause.
    • Another choice is Pennywise which keep all the keyboard shortcuts the original website provided. By default it has a NAVBAR (Left, Right and URL) at the top. We can toggle it by using Cmd/Ctrl + Shift + L.
    • Another choice is Google chrome browser. See How to use Chrome picture in picture mode.
  2. The official image (e.g. Install macOS Sierra.app) we downloaded from Apple Store is saved under /Applications folder.
  3. We can follow the instruction https://github.com/geerlingguy/macos-virtualbox-vm to convert the app folder into an iso file. The prepare-iso.sh script seems to always put the iso file onto the Desktop folder; i.e. output folder and name is not taken.
  4. When we want to create a virtual machine in VirtualBox
    • video memory change from 16GB to 128MB
    • increase memory to 4096MB
    • turn off audio
VBoxManage modifyvm "{vmname}" --cpuidset 00000001 000306a9 00020800 80000201 178bfbff

Another instruction is to run (this seems to be necessary even we uses 'import Appliance' method)

VBoxManage modifyvm "Sierra10.14" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

After booting, select the preferred language and (before click the 'Continue' button) go to Utilities > Disk Utility. Select the VirtualBox disk (VBOX HARDDISK Media)and choose Erase to format it as a Mac OS Extended (Journaled) drive. Installing macOS took about 15 minutes on my Dell T3600 Desktop running Ubuntu/Mint.

After a successful login, the 'df -h' command shows macOS uses 8.6 GB space.

Unfortunately, the Mac guest machine cannot install guest additions.

I get a 'Guru meditation' error when I test the iso on an old non-mac machine (intel core 2 duo CPU).

Note there is an error (IOConsoleUsers: gIOScreenLockState 3, hs 0, bs 0, now 0, sm 0x0) to install Sierra 10.12.4 as a guest machine. See https://benlimmer.com/2017/04/23/macos-sierra-virtualbox-10-12-4/.

High Sierra (10.13)

How to Download macOS High Sierra From macOS Mojave

Mojave (10.14)

On VB 5.2.x.

# cd "C:\Program Files\Oracle\VirtualBox\"
VBoxManage modifyvm "macMojave" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Change Settings. Select USB and check 3.0 USB. This is to enable mouse and keyboard support in the virtual machine.

After the first reboot, I need to remove the iso file. But it dropped to Shell after I boot up. It's more complicated. See the 3rd link above.

On Step 8, it complains "cd System\Library\CoreServices\". Change to use fs1 instead of fs2 fixes a problem.

I am setting up a new user (brb/arraytools). Note the password must be at least 4 characters.

It shows 12 GB was used when I first boot up the machine.

The "TheTechBlogger_APFSEfi.iso" should be kept there.

Catalina 10.15

Windows 如何透過 VirtualBox 安裝 macOS Catalina 虛擬機? 5 個步驟輕鬆完成

Create an ISO from the Sierra install app obtained from the Mac app store

https://klue.github.io/blog/2017/04/macos_kernel_debugging_vbox/

How to Make a MacOS Big Sur ISO File

How to Make a MacOS Big Sur ISO File

How to Run Your Mac’s Boot Camp Partition as a Virtual Machine

https://www.howtogeek.com/315083/how-to-run-your-macs-boot-camp-partition-as-a-virtual-machine/

Run Windows Apps

How to Run Windows Apps on Your Mac Without Running Windows

Remote connection (ssh)

Use Settings -> General -> Sharing -> Select Remote Login. How to Access Your Mac From Anywhere With Remote Login

To uses a command line to enable it, see

ssh key

Remote/Virtual machine: go to system preferences -> sharing and enable remote login. Suppose the user name is 'brb' and the hostname is 'brbs-MacBook-Pro.local'.

Host machine:

ssh-keygen -t rsa -f ~/.ssh/virtmac  # press 'Enter' 3 times
cat ~/.ssh/virtmac.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"
ssh -i ~/.ssh/virtmac [email protected]

When I run testings, I need to restore the virtual machine to its initial status. I can use this method in order to avoid the message "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" when I use the 'ssh' command.

Remote Desktop Connection (screen sharing) to Mac

On Mac, go to system preferences -> System Preferences -> Sharing -> Screen Sharing. It will show the vnc address of the Mac computer.

On my Ubuntu, see AppleRemoteDesktop

  • The built-in program Remmina Remote Desktop Client does not work. After clicking the 'connect' button & entering username/password, the screen flashed and disappeared.
  • RealVNC. I download the tarball (VNC Connect 6.0.3, Generic x64, default). Extract it to the Download folder and run vncviewer program. Yes, I can connect to Mac. But since the Mac has a very high resolution, I need to adjust the resolution setting in my connection. To do that: close the connection, right click a connection icon (created from last connection), choose Properties. In 'Options' tab, select Scaling -> Scale to fit window.
    • After connection, a toolbar will appear on the top of screen. It has a series of icons: Full screen mode, No scaling, Ctrl Alt Del, Info, Properties, Disconnect.
    • Even Mac screen lid is closed, VNC still works.
    • The connection speed is not ideal. You can see the screen refresh slowly.
  • Vinagre. It has to be installed from Ubuntu Software. Unfortunately it does not even allow me to enter a long password:(

Remote Desktop Connection from Mac

When I try to use the Screen Sharing (1.7) program in Mac to connect to Ubuntu 16.04 (type 'vnc://192.168.1.188'), I get an error 'The software on the remote computer appears to be incompatible with this version of Screen Sharing.'

Failscreensharing.png

Another remote desktop program is called Remote Desktop Connection for iMac. It appears to be used to connect to a Windows-based computer.

Passwords

Keepass

MacPass

Passkeys

How to Use Passkeys on Your iPhone, iPad, and Mac

Keychain Access

https://en.wikipedia.org/wiki/Keychain_(software)

Copy keychains to another Mac

If you need to update your keychain password on Mac

https://support.apple.com/guide/keychain-access/if-you-need-to-update-your-keychain-password-kyca2429/mac

How to Edit Saved Passwords on Mac with Keychain Access

How to Edit Saved Passwords on Mac with Keychain Access

PIV card

  • Open Keychain Access. It should show up "PIV-USER NAME-A" on the first item.
  • Change browsers (Chrome -> Safari). Firefox does not help.
  • Empty Cache in Chrome
  • Incognito mode (not help)
  • Reboot
  • Change PIC card reader (new one uses less power)

FileVault

After I change my password on cloud, I need to run Self-Service -> FileFault -> Repair and sync my password. Search: How to Change or Reset Your Password (Mac)

Encrypted emails

Unable to read encrypted emails.

Go to Preferences > Account > Advanced > Security.

  • Digital signing Certificate: XXXX-S
  • Encryption Certificate: XXX-E
  • Certificate authentication Authentication: XXX-S

Rebooting computer helps.

To check PIV card is inserted: open the 'Keychain Access' app.

macOS wants to use the "login" keychain

It asks me to enter my keychain password where I have my PIV card inserted. I need to enter my PIN not password.

I need to enter my PIN (PIV card is connected) for wifi to connect to office network.

Scopedbookmarkagent wants to use keychain

I need to enter my PIN (PIV card is connected) for wifi to connect to office network.

Mac Keeps Asking for Keychain “Local Items” Password

Tips

Got a New Mac? Do This First!

  • http://www.makeuseof.com/tag/new-mac-setup/
  • My list:
    • Settings. Trackpad (Tap to click). Displays (increase font size & night shift). Desktop & Dock (position on screen - left, Default web browser - Chrome). Appearance - dark.
    • Webex, Teams, Zoom. Enable blur background.
    • Adobe Acrobat
    • Activity Monitor
    • Chrome as default
    • iTerm2. It'll prompt to install command line developer tools.
    • R, RStudio, Rig
    • Visual Studio Code
    • Sublime Text
    • p4merge
    • Quicktime player
    • qView
    • Docker
    • GIMP
    • draw.io
    • Amphetamine
    • Paintbrush
    • Meld
    • The Unarchiver
  • Files and folders on my new Mac
    • Default folders are: Desktop, Documents, Downloads, Library, Movies, Music, Pictures, Public, .config
    • Files: .bash_history, .bash_sessions
  • Files, folders
    • ~/.ssh
    • ~/.bashrc, ~/.bash_profile
    • ~/.Rprofile
    • ~/.gitconfig
    • ~/.nanorc
    • ~/.profile
    • ~/.tmux.conf
  • Chrome extension
    • UBlock origin
    • Play on Kodi
    • ColorZilla
    • GoFullPage

Best Mac tips

The 50 best Mac tips, tricks and timesavers

Update date and time using command line

sudo ntpdate -u time.apple.com
sudo ntpdate -u ntp1.nih.gov

Forget a wifi network

Ad hoc network

How to Create a Secure Ad Hoc Network in macOS

List DNS servers

How do I check what DNS server I'm using (on Mac OS X)

$ scutil --dns | grep 'nameserver\[[0-9]*\]'

To change the DNS settings, follow

Flush DNS cache

/etc/hosts

To modify it, use sudo nano /etc/hosts

How to Keep an iPad From Dropping Wi-Fi Signals

Renew the iPad's DHCP lease.

Change the channel on your wireless channel (pick the channel has the lowest signals).

Force to reboot

iPad Freezes or Stops Responding, Fix. Press and hold both Power button & Home button.

Spinning rainbow wheel

app Store

  • Need a credit card information. The 'None' option is not available. Some tricks.
  • Cannot log in my account. Activity clock just keeps spinning and spinning
  • If macOS has been downloaded, the 'Download' button will be changed to 'Open' button in 'App Store' application.
  • If my macOS is already Sierra, we don't need to sign into 'App Store' in order to download a newer version Sierra image.

Upgrading to macOS Sierra (nee OSX) for R users

http://www.win-vector.com/blog/2017/01/upgrading-to-macos-sierra-nee-osx-for-r-users/

Access the Root Directory

http://osxdaily.com/2013/01/17/access-root-directory-mac-os-x/

Disable update notification

http://news.softpedia.com/news/how-to-disable-os-x-update-notifications-493961.shtml

How to check a Mac’s OS upgrade history

How to check a Mac’s OS upgrade history in System Profiler

How to download macOS update using the terminal

https://www.howtogeek.com/347920/how-to-download-macos-updates-using-the-terminal/

Console/All Messages

This is like the system log application in Linux/

Does not sleep when the lid is closed

$ syslog | grep 'Wake reason' | grep 'Mar 22'
...  processWakeReason Wake reason: Host (0x01)
...  Wake reason: ?
...  processWakeReason Wake reason: Host (0x01)
...  Wake reason: RTC (Alarm)
...  processWakeReason Wake reason: Host (0x01)
...  Wake reason: EC.LidOpen (User)

$ pmset -g assertions
2018-03-22 19:45:03 -0400 
Assertion status system-wide:
   BackgroundTask                 0
   ApplePushServiceTask           0
   UserIsActive                   1
   PreventUserIdleDisplaySleep    0
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     1
   NetworkClientActive            0
Listed by owning process:
   pid 120(hidd): [0x00050da000090379] 00:16:13 UserIsActive named: "com.apple.iohideventsystem.queue.tickle" 
	Timeout will fire in 1189 secs Action=TimeoutActionRelease
   pid 2903(RStudio): [0x0004b27a000124c2] 08:02:10 PreventUserIdleSystemSleep named: "R Computation" 
   pid 2903(RStudio): [0x0004b27a000124ba] 08:02:10 PreventUserIdleSystemSleep named: "R Computation" 
No kernel assertions.
Idle sleep preventers: IODisplayWrangler
  • It seems mac wakes up every 2 hours according to the syslog output. This issue is indeed caused by the discoveryd process.
  • It may be useful to run ping from another machine to see if Mac is still connected to the internet (cannot check if it is live)
  • Since when I wake up the machine the next morning, the internet is not connected, it may be useful to send emails in a regular time interval to see how long the machine still is connected to the internet.
  • Battery life went down from 98% to 88% the next day morning even I put the machine to sleep in the afternoon before I left.
  • Turn Off in Power management "Wake up by Wifi"
  • iMac randomly wakes up from sleep. In my case, I see Rstudio and hidd processes show 'Yes'.

Prevent ssh from sleep

http://osxdaily.com/2011/03/21/temporarily-prevent-a-mac-from-sleeping/

pmset noidle

This method does not prevent Mac from displaying screensaver & locking the screen. But it seems to fix the problem of broken pipe in ssh connection.

A better way is to modify .ssh/config file. See Way to prevent ssh connection timeout.

How to Configure a Proxy Server

https://www.howtogeek.com/293444/how-to-configure-a-proxy-server-on-a-mac/

Open a chm file

iChm program works fine. Chmox is too old (power pc) and not works.

CHM Reader from Mac App Store is not different from iChm.

Record sound

Use 'QuickTime player'.

The build-in microphone is located inside the left speaker. The default recording sound is too weak. Go to System Preferences -> Sound. Select 'Input' tab and increase the 'input volume' from the smallest to the loudest. See Control access to your microphone on Mac.

If we want to use an external mic, make sure the headphone connector has 4 sections.

Record video

How to Record Video on Mac: 4 Methods

Bluetooth device is not auto connected

https://apple.stackexchange.com/a/354319

Bluetooth codec

How to Force macOS to Use the aptX or AAC Codecs for Bluetooth Headphones

XXX can't be opened because it is from an unidentified developer

Cannot be opened because the developer cannot be verified

Cannot be opened because the developer cannot be verified. Control-click on the selected application and then, from the Shortcut menu, select Open.

/private/var/folders

https://discussions.apple.com/thread/1933443?start=0&tstart=0

If SeqTools was downloaded through a browser, then when we launch it the R script folder in <run_variantannose.sh> becomes something like /private/var/folders/1h/kcm8vkdx6nl00z5wjm5bqlw00000gp/T/AppTranslocation/051E078E-7C2D-4C6C-90FF-F651985EC9C0/d/SeqTools.app/Contents/MacOS/SeqTools/code

Extreme NAC Assessment Agent

https://isdp.nih.gov/isdp/version.action?prodid=220

'Please enter the host name or IP address of the Extreme NAC Assessment Agent server' 137.187.64.22.

Which Processes Can You Safely Quit in Activity Monitor on a Mac

Which Processes Can You Safely Quit in Activity Monitor on a Mac?

Activity Monitor doesn’t show columns

Column sizing is just buggy, the other columns are way over on the right. https://www.reddit.com/r/MacOS/comments/d8e1ow/help_activity_monitor_doesnt_show_columns/

Command line to find the IP address

ipconfig getifaddr en0 # it will return XXX.XXX.XX.XXX

Or use ifconfig to show all of the interfaces and their IPs.

The following command works on macOS 14 Sonoma.

ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' 

Uninstall inSync

https://www.insynchq.com/uninstall

AirDrop to share a website

Only Safari comes with the "Share" button (Chrome does not).

Use AirDrop to share files between Macs and iOS devices

How to Add an AirDrop Icon to Your macOS Dock

AirDrop uses wifi to transfer files. If wifi is not on, the Airdrop window will ask you to turn on wi-fi.

To use Airdrop, both iOS and Mac needs to change their settings.

  • iOS: Settings -> General -> Airdrop. Choose "Everyone" (default is "Receiving Off").
  • Mac: in Airdrop change "Allow me to be discovered by: No One" to "Allow me to be discovered by: Contacts only" or "Everyone".
  • Mac: Find -> go to the folder containing the file to be sent. Right click and choose 'Share' -> 'AirDrop'. Click XXX's iPad on Mac. Now click "Accept" on iPad in order to receive files. The AirDrop on iOS will ask what app to open the file. I can choose "Files" -> "iCloud Drive" -> Downloads.

File:Airdrop.png

How to Transfer Files From PC to iPhone and iPad (And Vice Versa)

  • https://snapdrop.net/
    • It is better to use Safari browser if we want the file to be saved on the iPad (the file goes to the iCloud Drive's 'Downloads' dir on my iPad).
    • If I use the chrome browser on iPad, it is not clear where the file is saved if the file is not a common type like pdf, txt, image, etc. For pptx, it just open the file in chrome. it seems I cannot save the file.
  • Airdroid works fine. The received files can be found by clicking the little clock icon on top right corner. The received files are not available in the "Files" app.
  • How to Transfer Files From PC to iPhone and iPad (And Vice Versa), FileApp

Share Files Between Mac & Windows Computers

Share Files Between iOS and Mac

What Is Airdrop? How to Share Files Between iOS and Mac

Digital color meter

Discover the DigitalColor Meter tool on your Mac Very useful when you want to know the color's RGB value from any dot on your screen.

Notes folder

$ ls ~/Library/Group\ Containers/group.com.apple.notes/
Library			NoteStore.sqlite	NoteStore.sqlite-shm	NoteStore.sqlite-wal

The data can be synchronized through iCloud. How Do I Sync My iPhone Notes With Mac Or PC?.

cron

Git GUI Client

gitk

It still works. I can use it to see changes of a specific file gitk [filename].

brew update
brew upgrade
brew install git # needed only if we haven't had git yet
brew install git-gui

Github Desktop

Looks good. It is OK to bypass to login a Github account in the installation process.

Fork

https://git-fork.com/

Good. It supports tabs. It automatically saves the opened tabs. But it is not open source.

SourceTree

sourcetree. See also Happy Git and Gihub for the useR from Jenny Bryan.

Unfortunately it requires a Bitbucket account in order to finish its installation.

Useful Apps

The Ultimate List of Mac Menu Bar Apps

Amphetamine: keeps your Mac awake (not sleep)

Caffeine is too old. KeepingYouAwake is a small menu bar utility that is inspired by Caffeine from Lighthead Software. The app is a small wrapper around Apple's caffeinate command line utility.

See a review of Amphetamine and one from lifehacker.

Lungo is another one (paid) and it requires macOS 10.13.

How to Keep Your Mac From Sleeping: 5 Methods That Work

Caffeinate

Take a break

Five free apps to help remind you to take a break.

  • Time Out looks cool. Some features like put the app in the menu bar are available for supporters:(
  • Break Timer, memory leak?
  • Stretchly

Quartz

In a new macbook computer, when I drew a plot in R from a terminal, it launched a window with the title "Quartz 2[*]" with menu items R, Edit, Quartz & Window. See also quartz().

XQuartz

X11 forwarding on OS X (macOS), SSH X11 Forwarding and Mac OS X Sierra

I have found out the -X cannot forward X11. I need to use -Y option. Note that

ssh -Y XXX.XXX.X.XX
nautilus & 
  • BiplotML loading error. It depends on the "rgl" package which requires XQuartz. Install it by brew install --cask xquartz will fix the error.
Error: package or namespace load failed for ‘shapes’:
 .onLoad failed in loadNamespace() for 'rgl', details:
  call: rgl.init(initValue, onlyNULL)
  error: OpenGL is not available in this build
Error: package ‘shapes’ could not be loaded
In addition: Warning messages:
1: 	Loading rgl's DLL failed. 
	This build of rgl depends on XQuartz, which failed to load.
 See the discussion in https://stackoverflow.com/a/66127391/2554330 
2: Trying without OpenGL... 

My installed apps

  • iTerm2
  • RStudio, R
  • Amphetamine
  • Anaconda-Navigator
  • Firefox
  • Flux
  • Lightshot Screenshot
  • Meld
  • Paintbrush
  • Stretchly
  • The Unarchiver
  • VirtualBox
  • VLC
  • Xcode
  • SourceTree
  • Atom
  • Visual Studio Code
  • Pennywise. Cross-platform application to open any website or media in a floating window .
  • XQuartz (R does not need it; R uses Quartz for plotting).
    • However when I try to install tinytex package, it complains unable to load shared object '/Library/Frame/R.framework/Resources/modules//R_X11.so'. It seems to be related to missing XQuartz. See the discussion here. Run X11 in Mac OS X with XQuartz.
    • Another case is when I try to use svg() to save an image. It shows "Unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so'".
    • Another case is edit() won't work with data frame.
    • You will need to log out and log back in to make XQuartz your default X11 server.
  • Stopwatch & Timer
  • Qt Creator
  • Chargeberry

Missing Linux commands

wget

Method 1: Rudix

curl -O https://raw.githubusercontent.com/rudix-mac/rpm/2016.12.13/rudix.py
python rudix.py install rudix
sudo rudix install wget
which wget
# /usr/local/bin/wget

$ wget https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
--2017-02-26 08:41:09--  https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.192.133, 151.101.128.133, 151.101.0.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.192.133|:443... connected.
ERROR: cannot verify raw.githubusercontent.com's certificate, issued by ‘CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’:
  Unable to locally verify the issuer's authority.
To connect to raw.githubusercontent.com insecurely, use `--no-check-certificate'.
$ wget https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh --no-check-certificate
--2017-02-26 08:41:26--  https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.192.133, 151.101.128.133, 151.101.0.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.192.133|:443... connected.
WARNING: cannot verify raw.githubusercontent.com's certificate, issued by ‘CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’:
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 200 OK
Length: 8502 (8.3K) [text/plain]
Saving to: ‘install_rnaseq.sh’

install_rnaseq.sh                        100%[===============================================================================>]   8.30K  --.-KB/s    in 0.001s  

2017-02-26 08:41:26 (15.7 MB/s) - ‘install_rnaseq.sh’ saved [8502/8502]

Method 2: homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install wget --with-libressl

Method 3: Build from source (require Xcode, works on my OS X 10.12 Sierra w/ Xcode 8.2.1)

xcode-select --install
cd ~/Downloads

curl -O https://www.openssl.org/source/openssl-1.0.2h.tar.gz
tar xzvf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
./configure darwin64-x86_64-cc 
make
sudo make install

curl -O http://ftp.gnu.org/gnu/wget/wget-1.18.tar.gz # version 1.19 won't work at the 'make' step
tar -zxvf wget-1.18.tar.gz
cd wget-1.15/
./configure –with-ssl=openssl –with-libssl-prefix=/usr/local/ssl
make
sudo make install

For some reason, when I use wget to download files from https server, I will get a message: ERROR: cannot verify site certificate. Unable to locally verify the issuer’s authority. See

watch

http://stackoverflow.com/questions/9574089/osx-bash-watch-command

while :; do clear; your_command; sleep 2; done

glances command

glances

Command Reference, Load

Color code: Blue=careful, Violet=alert, Red=critical

Use Glances to Monitor Remote Linux in Web Server Mode

  • glances -w # run Glances in web server mode. The port number is shown on the terminal. It is not working if I use the server mode glances -s.
  • n: hide network status
  • Use mouse left click to sort processes by CPU, MEM, ..

top command

To sort by CPU

top -u

To sort by Memory

top -o mem

htop

http://unix.stackexchange.com/questions/98253/how-do-i-install-htop-inside-mac-os-x

It seems the result is not accurate. For example when the fan is working (esets_daemon is running), htop does not show much CPU from eset_daemon but Activity Monitor shows esets_daemon is on the top cpu usage list.

gotop

https://github.com/cjbassi/gotop

md5sum

It is called md5 instead of md5sum in Linux.

For SHA-1 and SHA-256 use

shasum filename
# OR
shasum -a 1 filename

shasum -a 256 filename

echo "add4614b6fe3bb8e7dddcaab0ea97c476fbd4ffe288f2a4912cb06f1a47dcfa0 *ubuntu-18.04.3-desktop-amd64.iso" | shasum -a 256 --check

tar

If we run the following command

tar xzvf filename.tar.gz -C directory 2> error.log

we will get a non-empty file in <error.log> even the extraction is successful.

Therefore it is better to use the following way

tar xzvf filename.tar.gz -C directory
if [ $? -eq 0 ]; then
    echo OK
else
    echo FAIL
fi

(2019-10-15) If I create a tarball on Mac and extract it on Linux, I'll get a strange message tar: Ignoring unknown extended header keyword 'SCHILY.dev' . Linux / OS X tar incompatibility – tarballs created on OS X give errors when untarred in Linux. The reason is macOS uses BSD tar and Linux uses GNU tar. So one solution is to run brew install gnu-tar. After that, run nano ~/.bashrc and add the gnubin directory to your PATH by following its terminal instruction. Run source ~/.bashrc and man tar will show we are using GNU-tar.

Diff tools

  • Diff Tools on macOS
  • FileMerge - part of XCode from Apple. Too un-intuitive compared to WinMerge on Windows or Meld on Linux:(
  • DiffMerge. Still not intuitive.
  • P4Merge free. It works. The application theme by default is light and can be changed to dark. One complain is the Preferences window is too long (without a scrollbar).
  • Meld for OSX - BEST free!
    • Version control
    • Dark theme issue in OS. It is very difficult to look at the interface when mac is in a dark them. One trick is to switch to a light scheme in mac (Preferences > General). Open Meld application. The background in meld will be white. Now we can switch to the dark them in mac in order to get everything else right.
    • Meldss.png
    • How to launch it from command line?. (2020-04-13) I create a sh file as the instruction but it still cannot do 'meld File1 File2'.
    • Command line solution, cask with meld 3.21.0-r2 (latest from https://github.com/yousseb/meld/releases 2 days ago)
      brew cask install meld # /usr/local/bin/meld
      meld File1 File2  # it works!
  • KDiff3: old (2014)
  • git diff will give a colored output on your terminal
    • Still a command line based
    • The compared files do not need to be in the local git directory
    • Green means the 1st file has more contents
    • Red means the 2nd file has less contents
  • Beyond Compare (commercial)
  • Araxis Merge (commercial)
  • DeltaWalker (commercial)
  • Kaleidoscope (commercial)

zcat

macOS always adds .Z to the .gz filename. A more portable solution is to use gunzip -c such as gunzip -c XXX.gz.

See zcat on OS X is running in POSIX mode and will always append .Z to all filenames.

R

failed to load cairo DLL

I got an error when I use svg() command.

 svg("~/Downloads/3dPiePlot.svg")
Warning messages:
1: In svg("~/Downloads/3dPiePlot.svg") :
  unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so':
  dlopen(/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so, 6): Library not loaded: /opt/X11/lib/libXrender.1.dylib
  Referenced from: /Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so
  Reason: image not found
2: In svg("~/Downloads/3dPiePlot.svg") : failed to load cairo DLL

http://r.789695.n4.nabble.com/Cairo-package-error-quot-unable-to-load-quot-td4694453.html

you don't have X11 installed and it no longer ships with OS X 10.9 - you need to get it from

http://xquartz.macosforge.org

At the end of installation, it will ask you to log out and log in again to make xquartz a default X11 server.

Tex/Latex

Download failure

BasictexErr.png

The error seems to be related to a new release (6/7/2017). The download link for basicTex is http://tug.org/cgi-bin/mactex-download/BasicTeX.pkg. It downloaded the file mactex-basictex-20161009.pkg. But the new release is mactex-basictex-20170607.pkg. The download works fine on 6/8/2017.

http://ctan.org/pkg/mactex-basic website is working fine but the downloaded file name is <BasicTex.pkg> so it is not clear about the release date.

tlmgr error

$ tlmgr update --self
tlmgr: The Tex Live versions supported by the repository
http://ctan.sharelatex.com/tex-archive/systems/texlive/tlnet
  (2016-2016)
do not include the version of the local installation
  (2017).

Install a new package through tlmgr

When I try to knitr an R markdown file in RStudio, an error was popped up complaining about missing 'framed.sty' file. The solution is to install the framed package on macOS or texlive-latex-extra package on Ubuntu/Debian.

sudo tlmgr update --self
sudo tlmgr install framed

Miktex on Mac

https://miktex.org/howto/install-miktex-mac

LaTeXiT

Microsoft Outlook

Customize views

  • Sidebar (from the outside Menu bar): View > Sidebar
  • Organize (from the inside menu or blue Ribbon): Focused Inbox, Message Preview.
  • Remove Focused and Other: By Conversations -> uncheck "Turn on focused inbox". Or go to the "Organize" menu to uncheck "Focused Inbox".

Import a calendar into Outlook

Add ics file to outlook 2011 (Mac) as new calendar. Drag and drop.

Outlook search is incomplete

Issue on Mojave. Users can should OWA https://outlook.office365.com instead.

Temp folder

  • On my Outlook (365 subscription), it is /private/var/folders/2q/slryb0rx4tj97t66v7l6pwvr_z6g3s/T/com.microsoft.Outlook/Outlook\ Temp/. It is obtained by Open an attachment and then select & copy a file.
  • When I install R packages, the binary packages are downloaded to /var/folders/2q/slryb0rx4tj97t66v7l6pwvr_z6g3s/T//RtmpnqOp8D/downloaded_packages. In fact, /var is soft link to /private/var.

Save an email

The file format is *.eml.

Automatic replies in Outlook

What’s New in Outlook 365 for Mac’s Fall 2020 Update

What’s New in Outlook 365 for Mac’s Fall 2020 Update

Apple Server

OS Server

Apple Silicon

Apple Silicon + Big Sur + RStudio + R Field Report

Unified memory

What Is Unified Memory and How Much Do You Need?

Hackintosh

OpenCore

How to Triple Boot Your Hackintosh with Windows and Linux

http://lifehacker.com/5698205/how-to-triple-boot-your-hackintosh-with-windows-and-linux

How To Install macOS Sierra Hackintosh On PC

http://www.redmondpie.com/how-to-install-macos-sierra-hackintosh-on-pc-guide/

Building a GTX 1080 Ti-powered Hackintosh: Installing macOS Sierra step-by-step

https://9to5mac.com/2017/04/28/building-a-gtx-1080-ti-powered-hackintosh-installing-macos-sierra-step-by-step-video/

iOS

iPad Pro 10.5 vs iPad 9.7 (2017)

Screen shut off automatically

Settings -> Display & Brightness -> Auto-Lock. If you select 'Never', the screen will never turn it off by itself.

install ipa file

Accessibility, display, black and white

How to Stop Apps from Using Cellular Data

How to Stop Apps from Using Cellular Data on iPhone & iPad

Multitasking

How to Use Multitasking and Text Editing Gestures on iPadOS

Shortcuts/automation

How to Trigger an Action at Sunrise or Sunset on iPhone

How to Use Multiple Windows of An App

How to Use Multiple Windows of An App on Your iPad

Share an internet/hotspot

How to Use Instant Hotspot on Your iPhone, iPad, or Mac

Firefox Focus

Feel quite fast on my iPad. The 'setting' (gear symbol) on the top right hand side cannot be seen unless we click 'Erase' first. On the setting, we can change the search engine, Send usage data, etc.

But the regular Firefox has an option called "Tracking Protection" which is doing the same thing.

Download files in safari

How to Download Files from Safari on iPhone & iPad

File manager

The 6 Best File Manager Apps for iPhone and iPad

Documents by Readdle is a file manager with an integrated web browser, which makes it easy to download and transfer YouTube videos. See How to Download and Save YouTube Videos on iPhone.

App storage

Reduce Pocket app size. For Pocket, I open the app, click Profile -> Setting -> Clear Downloaded Files.

FE file explorer

No ads. Support sftp. Android & iOS are available. https://www.skyjos.com/fileexplorer/

The Fastest File Transfer Methods Between PCs and Mobile Devices

https://www.makeuseof.com/tag/x-fastest-ways-transfer-file-pc-mobile-device/

Split screen

MiniKeePass

Dropbox -> KeePass file -> "..." -> Export -> Open in -> Copy to MiniKeePass.

Not maintained after 2020. KeePassium seems to work fine initially.

Voice recorder

Live transcribe

How to Use Live Captions on Your Mac to Transcribe Audio

Take a screenshot

  1. Press and hold the Sleep/Wake (on/off) button on the top of your iPad.
  2. Quickly click the Home button at the bottom of the screen.
  3. Release both buttons.

When you successfully trigger a screen shot, you'll see a white flash and, if audio is on, hear the camera shutter sound.

Where to find screenshots: Open Photos, then go to Albums > Screenshots.

How to Take a Full-Page Screenshot of a Website on an iPhone or iPad. The full screenshot works on Safari, but not Chrome.

HDR photo

How to Shoot in HDR on Your iPhone

The best use cases for HDR photography are landscapes, objects in direct sunlight, and low-light or backlit scenes.

Burst photos

How to Convert Burst Photos to GIF on iPhone or iPad

How to Take Better Fireworks Photos

https://lifehacker.com/how-to-take-better-fireworks-photos-with-your-iphone-1827324154

Live photos

How to Make Videos Into Live Photos on iPhone

Procreate

https://www.makeuseof.com/tag/procreate-for-ipad-one-of-the-most-beautiful-and-powerful-art-apps-for-ios-available-today/

Garden apps

GoodNotes

http://www.goodnotes.com/

Note taking

Replace desktop?

  • How to download pdf files?
  • How to search on pdf files?

AirDrop

Use AirDrop on your iPhone, iPad, or iPod touch

AirPlay, mirror screen

Shell/terminal

iSH - An iOS Linux Shell for Your iPhone or iPad

AirDroid: wifi transfer files

AirDroid works on iOS. It has frequent updates and gets good reviews. Another popular android app "Portal" does not get updates and does not have a good review on iOS.

Turn off passcode

https://appsliced.co/ask/how-do-i-disable-the-passcode-lock-on-my-ipad

Under Settings -> Touch ID &N Passcode

Turn off auto-lock

http://www.solveyourtech.com/disable-auto-lock-ipad-2/

Under Settings -> Display & Brightness

Reducing eye strain

https://www.makeuseof.com/tag/reduce-eye-strain-iphone/

iCloud

6 Nifty Uses for Spare iCloud Storage

Music

Novel Effect Make Story Magic

Chrome keyboard shortcuts

22 Chrome for iPad Keyboard Shortcuts

Games

Rubik cubes

The Best Apps for Solving a Rubik's Cube

VLC

How to Watch MKV & AVI Video on iPad or iPhone Free with VLC

VPN

The 5 Best Free VPNs for the iPhone

ssh

Twitter

The Best Twitter Apps for Every Plat

Check the privacy policies

How to Check the Privacy Policies of Your Installed iPhone Apps

local network privacy policy in iOS 14

spyware

How to Remove Spyware on an iPhone

Emergency Contacts on Your iPhone

How to Set Up Emergency Contacts on Your iPhone

iPad

Air is laminated

Apple 10.9" iPad (10th Gen). Keep in mind that the screen on the Air is laminated, while this is not. You will feel (and hear) a small gap between the screen and the pencil, which might get a bit annoying if you'll be using it a lot that way.

Selling Your iPad

Selling or Giving Away Your iPad? Here Are 7 Things You Should Do First