Mac
Common tasks
List Symbol names in object file
See what process is preventing disk ejection
Show SDK Path in macOS
Extract JAR into a Dir
Since JAR is essentially a zip file, you can use any zip/unzip commands with it.
Delete files from JAR without unzip
Copy the output of a command directly into clipboard
Note: In macOS, use pbcopy
; in Linux, use xclip
.
Useful Visual Studio Keyboard Shortcuts
Edit All in Scope
- keymap: first select one of the occurance in file, then
ctrl + cmd + g
to edit all in scope
- keymap: first select one of the occurance in file, then
clone caret up/down
- keymap:
alt + cmd + up/down
- keymap:
Useful Xcode Keyboard Shortcuts
Edit All in Scope
- keymap:
ctrl + command + E
- usage: it can be used to edit all in scope, or highlight all instances in scope for easy viewing.
- keymap:
Keyboard comibation utilizing Use Selection for Find
- keymap: select a variable, then
command + E
, thencommand + G
to go to next occurance,shift + command + G
to go to previous occurance. - Usage: it can be used to traverse all occurances in the current file.
- keymap: select a variable, then
To maximize coding workspace:
ctrl + command + F
to enter full screen, thenoption + command + T
to hide tool bar, thencomamnd + 0
to hide narvigator, thenoption + command + 0
to hide inspector, thenshift + command + y
to hide debug area.
To fold all code in current brace:
option + command + leftArrow
Move cursor in macOS terminal
ctrl
+e
will take you to the end of the line.ctrl
+a
will take you to the front of the line.option
+->
,option
+<-
,word movement in terminal <http://blog.macromates.com/2006/word-movement-in-terminal/>
_ctrl
+w
will delete a word and go back.ctrl
+q
/u
will delete to the front of the line.
Get macOS shell script to show colors in echo
Example: echo -e "\033[1;31m This is red text \033[0m"
How to reinstall macOS and setup for programming
Enter recovery mode
Press command + R
immediately after you clicked restart
button. You can release the keys the moment you see the apple logo.
Erase the Macintosh HD disk if needed
If you want a brand new macOS, you can go to disk utility to erase the contents on Macintosh HD.
Reinstall macOS
After clicking reinstall macOS, just follow the guides on the screen. (It usually takes you around 6 minutes to download macOS installer and 28 minutes to install) You will need to provide your apple ID and password for personalized setup.
Install Xcode
Got to App Store, install Xcode.
Install Homebrew
Follow the guides in the homepage of .
Install zsh
Run this in the terminal: brew install zsh zsh-completions
Install oh-my-zsh
Follow the guide of installing oh-my-zsh
Two important things to do
Uncomment 2nd line in
.zshrc
Add a line below the second line:
export PATH="/usr/local/bin:\${PATH}"
Open terminal preference, select Profiles
, choose Pro
as default profile.
Install tree
Install: brew install tree
Usage: tree
or tree -L 1
(1
at the end is listing depth.)
Install & Setup Git
- Install git:
- Define Git user:
- Setup keycache for avoiding input password every time you push using https:
- Setup ssh for git:
Refer:
On a Mac, it is important to remember to add .DS_Store
(a hidden OSX system file that’s put in folders) to your .gitignore files.
If you never want to include .DS_Store
files in your Git repo, you can configure your Git to globally exclude those files.
Install Python3
Download from official website. And click pkg to install. After that, pip install virtualenv
Install node.js
Download pkg and click to install. Very easy and convenient.
Install VMWare Fusion
Download click to install.
If you want to copy a vm, follow this (I had followed it once, and it does work. Choose the vm disk instead of copy the whole VMBundle and set the network setting to bridged otherwise port forwarding might not work.)
How to keep Mac AWAKE and LOCKED
- In System Preferences > Energy Saver, check the box for “Prevent computer from sleeping automatically when the display is off” (on laptops, this is under the Power Adapter tab)
- In System Preferences > Security & Privacy, check the box for “Require password after sleep or screen saver begins” and set the delay in the dropdown menu to “immediately”
Now, you can hit command-option-power
to turn off the display without sleeping the computer, and doing anything that turns on the display (like hitting a key or clicking a mouse button) will prompt you for your account password.
How to copy path in macOS without adding any services
Navigate to the file or folder you wish to copy the path for
Right-click (or Control+Click, or a Two-Finger click on Trackpads) on the file or folder in the Mac Finder
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
Once selected, the file or folders path is now in the clipboard, ready to be pasted anywhere
How to verify checksum
Refer: