CLI
-
How to get the CPU name
sysctl -a | grep machdep.cpu.brand_string
-
How to get system info
system_profiler SPSoftwareDataType SPHardwareDataType
-
Collection #1: https://switowski.com/blog/favorite-cli-tools
-
Collection #2: from here
bat
iscat
with syntax highlighting and line numbers- diff-so-fancy shows best-looking diffs you'll ever see
- fx is the best JSON viewer you'll ever use
- fzf is an insanely fast fuzzy search written in @golang
- exa is
ls
but with coloring - duff shows a better du summary
- htop is a modern
top
replacement - hexyl is a beautiful hex viewer
- @fig is next-gen autocompletion
-
restart from terminal
sudo shutdown -r now
-
sudo with no password
sudo visudo ... <username> ALL=(ALL) NOPASSWD:ALL
If one wants to just increase the time before re-entering the sudo password, add
Defaults timestamp_timeout=3
-
update command line tools
sudo xcode-select -s /Applications/Xcode_13.2.1.app sudo rm -rf /Library/Developer/CommandLineTools sudo xcode-select --install softwareupdate --all --install --force
Note: this leaves the popup open in the GUI...
-
Create a build agent like those on Github
https://github.com/actions/virtual-environments/issues/1783 https://github.com/actions/virtual-environments/blob/main/images/macos/templates/macOS-12.json
-
Check which process is listening to which port
sudo lsof -nP -i4TCP:$POST | grep LISTEN
-
Follow the end of a log (e.g. mongo)
tail -f /opt/homebrew/var/log/mongodb/mongo.log
-
access the keychain from cli. In the command $USER refer to the current user keychain source
# store environment variable security add-generic-password -a "$USER" -s 'name_of_your_key' -w 'passphrase' # retrieve key to environment variable security find-generic-password -a "$USER" -s 'name_of_your_key' -w # store it locally NAME_OF_YOUR_KEY=$(security find-generic-password -a "$USER" -s "name_of_your_key" -w) # or NAME_OF_YOUR_KEY=`security find-generic-password -a "$USER" -s 'name_of_your_key' -w`
-
Debug startup time in the terminal
Write all steps in the file
trace
PS4='+%D{%s.%9.}:%N:%i>' zsh -c -i -x exit > trace 2>&1
Make times differential
<trace awk -F: '{printf "+%.09f", $1 - t; t=$1; $1=""; print}'
-
Prevent word wrap:
tput rmam
-
Restore word wrap:
tput smam
-
Timing shell commands:
set -x
, disabling it:set +x
-
get process that has a port open
sudo lsof -nP -i4TCP:$PORT | grep LISTEN
-
force macOS to sync time:
sudo sntp -sS time.apple.com