# macOS Setup ## Apps ### What I use #### Command-line Tools - [ ] https://iterm2.com/ - [ ] https://ohmyz.sh/ - [ ] https://brew.sh/ - [ ] fzf, a command-line fuzzy finder, https://github.com/junegunn/fzf - [ ] ripgrep, recursively searches directories for a regex pattern while respecting your gitignore, https://github.com/BurntSushi/ripgrep - [ ] rga, like ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc., https://github.com/phiresky/ripgrep-all - [ ] fd, an alternative to 'find', https://github.com/sharkdp/fd - [ ] exa, a modern replacement for ‘ls’, https://github.com/eza-community/eza - [ ] tldr, collaborative cheatsheets for console commands, https://github.com/tldr-pages/tldr - [ ] dive, a tool for exploring each layer in a docker image, https://github.com/wagoodman/dive - [ ] bat, A cat(1) clone with wings, https://github.com/sharkdp/bat - [ ] hyperfine, A command-line benchmarking tool, https://github.com/sharkdp/hyperfine #### General - [ ] https://www.alfredapp.com/ - [ ] https://rectangleapp.com/ - [ ] https://freemacsoft.net/appcleaner/ - [ ] https://pilotmoon.com/scrollreverser/ - [ ] https://github.com/Ji4n1ng/OpenInTerminal - [ ] Screenshot - https://shottr.cc/ - [ ] https://apps.apple.com/us/app/amphetamine/id937984704 - [ ] https://github.com/jordanbaird/Ice or https://github.com/dwarvesf/hidden - [ ] https://obsproject.com/ #### Backend Development - [ ] https://github.com/derailed/k9s ### Other Recommendations - [ ] https://github.com/gao-sun/eul - [ ] https://github.com/MonitorControl/MonitorControl#readme - [ ] Equalizer - https://eqmac.app/ - [ ] https://apps.apple.com/us/app/otp-manager/id928941247 - [ ] https://hyper.is/ - [ ] Calculator - https://numi.app/ - [ ] Dropzone 4 - https://aptonic.com/ - [ ] Screenshot - https://cleanshot.com/ - [ ] Alt Tab - https://alt-tab-macos.netlify.app/ - [ ] Raindrop.io - https://raindrop.io/ ## Productivity Notes ### Shortcut for Screenshot `Command + Control + Shift + 4` to snap, at the same time copy. Read more [here](https://www.ias.edu/itg/content/keyboard-shortcuts-capture-screen-shot-mac-os-x). ### Make app switcher displays on both multiple screens ```shell defaults write com.apple.Dock appswitcher-all-displays -bool true killall Dock ``` Ref: https://superuser.com/a/1625752 ### Temporarily disable Gatekeeper to allow third party app installs that are not allowed by Apple ```shell sudo spctl –-master-disable # disable sudo spctl --master-enable # re-enable ``` Ref: https://osxdaily.com/2015/05/04/disable-gatekeeper-command-line-mac-osx/ ### Open project in Xcode from command line At the directory where your `xcworkspace` or `xcodeproj` is, run the following command. ```shell xed . ``` Ref: https://stackoverflow.com/a/52739630/5366727 ### Open project in IntelliJ from command line In IntelliJ, go to `Tools > Create Commandline Launcher` for one-time setup. At the directory where your Java project is, run the following command. ```shell idea . ``` Ref: https://stackoverflow.com/a/49819015/5366727 ### Known Issue: k9s cannot resolve host name through VPN When connected to VPN, k9s might not be able to resolve private host names. This happens when k9s is installed via Homebrew, where Cgo is disabled by default. To overcome this, we can compile and install k9s from source using `go install`. Ref: https://github.com/derailed/k9s/issues/780 ### Docker Setup #### Colima as Docker Daemon In case Docker Desktop cannot be used (e.g. due to licence limitation), can consider using [Colima](https://github.com/abiosoft/colima) to replace Docker Daemon, then Docker CLI can still be used. Sample command to start Colima ```sh colima start --cpu 4 --memory 8 --disk 100 ``` #### Install Docker `buildx` for Colima See official doc [here](https://github.com/abiosoft/colima/blob/main/docs/FAQ.md#docker-buildx-plugin-is-missing) or discussion [colima#273](https://github.com/abiosoft/colima/discussions/273) ```sh brew install docker-buildx mkdir -p ~/.docker/cli-plugins ln -s $(which docker-buildx) ~/.docker/cli-plugins/docker-buildx colima restart docker buildx version ``` #### Adding insecure registries to Colima See official docs [here](https://github.com/abiosoft/colima/blob/main/docs/FAQ.md#how-to-customize-docker-config-eg-add-insecure-registries). #### Using Dive with Colima See https://github.com/wagoodman/dive/issues/462#issuecomment-1751187322 ```sh export DOCKER_HOST=$(docker context inspect -f '{{ .Endpoints.docker.Host }}') ``` ### How to inspect files in a container image without running it See https://stackoverflow.com/a/53481010 ```sh # Create docker create --name="tmp_$$" image:tag docker export tmp_$$ > output.tar tar -xvf output.tar # Clean up docker stop tmp_$$ docker rm tmp_$$ docker ps -a ``` ### MySQL: MySQL 9 fails to start There is a known issue at [Homebrew#5539](https://github.com/orgs/Homebrew/discussions/5539Reinstall) where the introduction of MySQL 9 causing the database fails to start. When troubleshooting, try the steps mentioned in `brew info mysql` ``` Upgrading from MySQL <8.4 to MySQL >9.0 requires running MySQL 8.4 first: - brew services stop mysql - brew install mysql@8.4 - brew services start mysql@8.4 - brew services stop mysql@8.4 - brew services start mysql ``` ### MySQL: Reset password to empty string ``` mysqladmin -u root -p'password' password '' ``` Ref: https://serverfault.com/questions/103412/how-to-change-my-mysql-root-password-back-to-empty ### MapStruct: Delegate IDE build/run actions to Maven in IntelliJ Sometimes local build in IntelliJ does not work when a Java project has MapStruct. Consider doing the following: 1. Navigate to: `File > Settings > Build, Execution, Deployment > Build Tools > Maven > Runner` 1. Check the option: `Delegate IDE build/run actions to Maven` 1. Apply the changes and restart IntelliJ IDEA if necessary. Ref: https://github.com/mapstruct/mapstruct/issues/2802 ### Protobuf: Cannot compile on Apple Silicon machines On Apple Silicon machines, when building the application using Maven command, we always needed to specify `-Dos.arch=x86_64` otherwise the Protobuf could not be successfully compiled. An alternative is to specify the Protobuf version in the Maven plugin configuration. ```xml ${protoc.version} ``` Ref: https://github.com/os72/protoc-jar-maven-plugin/issues/129