This article is launched on the wechat public account “AndroidTraveler”.

background

Most of the new graduates used Windows computers in college, so if they get an Apple computer for the first time, they may not be able to use it quickly. Based on this, here is a series of videos, through the actual demonstration so that people who have not used Apple computers can quickly get started.

positioning

Suitable for the following partners:

  1. Never used an Apple computer before
  2. I haven’t used Terminal on a MAC
  3. Android development doesn’t use commands to accomplish tasks
  4. Anyone interested in this video

Interpretation of the way

We’re going to do it in three different ways. Mind maps, videos, and this article. Each form has its own advantages and disadvantages, you can choose according to their own situation.

Mind mapping

video

At present, the video has been recorded and uploaded to station B.

The entire video should have been posted by 8 a.m. on August 20.

B station link: space.bilibili.com/221777031

The article

Part ONE: Basic MAC Settings

01 Touch pad Settings

Click system preferences to open the Settings panel, and click the touch pad to enter the Settings page.

Check and tap to tap, so that you can tap later without pressing hard.

Secondary tap (two-finger tap), the equivalent of a right click in Windows, opens the function menu.

Older versions of the launch three finger drag can be opened directly on the trackpad. High version through system preferences -> Accessibility -> Mouse and trackpad -> Trackpad options… Select three finger drag to start by checking enable drag. The computer version I demonstrated was 10.10.5

Whether to check the scrolling direction depends on personal use habits. You can open the web page and slide to see if it is in line with your own use habits to determine. To ensure consistency with Windows, deselect this parameter.

02 Shortcut Settings and application startup

Shortcut keys The path for setting shortcut keys is System Preferences > Keyboard > Shortcut Keys

The video demonstrates the input source (input method switch) shortcut and the Spotlight shortcut Settings.

The application can be launched in two ways:

The first is to open Launchpad directly and swipe through all installed apps or search through the top.

The second way is through Spotlight search.

03 Forcibly Exit the Unresponsive application

There are two ways to force an unresponsive application to exit:

The first is to click on the apple icon in the upper left corner and hit Force Exit… . Select the application you want to exit and click Force Exit.

The second way is to open the Activity Monitor by searching for it in Spotlight. Double-click the application you want to exit, and click Exit to force the exit.

04 Switching Languages

This is mainly due to the fact that our video explanation is in the Chinese environment.

How to switch to Chinese if you get an Apple computer that starts out in English.

Open System Preferences, click On Language & Region, Then hold and drag the Preferred Languages you want to switch to (simplified Chinese for the video demo) to the first location in the left pane to close the Settings panel and prompt you to restart your computer to apply all Settings.

In this case, if you don’t have any documents you are editing, you can just hit Reboot. To avoid data loss, click Do not restart. Then manually close the document-related application and restart it. Or if you find yourself using an application that doesn’t switch languages and you need to switch languages, you can restart it.

Part two: Linux commands

01

pwd

Print work directory

open

Open it graphically

cd

Change directory

Special directory description: ~ : host directory.. : Parent directory – : last directory. : current directory

The host directory is usually composed of **/Users/ user name /**

;

Semicolon (;) : Multiple commands can be executed.

Multiple commands are connected. The failure of the previous command does not affect the execution of the next command.

Go to folder shortcuts

Give me a path, and I’ll get there quickly.

Open Finder, then use the shortcut command+ Shift + G to go to the folder, enter the corresponding path to quickly navigate to the corresponding path.

Of course, click “Go” on the menu bar, you will also find the shortcut key to folder, you can also directly click.

02

touch

Create an empty file

mkdir

Create a file directory (folder) Add the -p option when creating a multilayer directory

ls

Lists all files (normal files and folders) in the current directory

Ls -a lists all files (including hidden files whose names start with a.)

Ls-l lists more detailed information

03

Rm Deletes folders or files

Rm File name Delete a common file rm -r directory file Delete a directory file

Be careful, it is generally not recoverable

Cp Copy file

Cp Location of the file to be copied Location of the file to be copied cp -r Location of the directory to be copied (no/end) Location of the file to be copied

Mv function 1: Move

Mv Location of the file to be cut Indicates the location to be cut

Function 2: Rename

Mv Original file name New file name

Tips: Automatic completion: TAB key

04 Terminal Shortcut Keys

In order to improve the efficiency of using commands in Terminal, this section mainly shares some shortcut keys.

Copy and paste Copy command+c paste command+ V

Position the cursor at the beginning of the line control+a

Position the cursor at the end of the line control+ E

Control +u clears everything from where the cursor is to the beginning of the line

Control +k clears everything between the cursor position and the end of the line

How to view up and down lookup of history command arrow keys

CLS control + l

The new Terminal command + n

05

Cat views the contents of the file and outputs them to the console

More Displays the contents of a file screen by screen.

So there are some keys that perform the next screen and the next line of view Enter/arrow, the next line of view space, the next screen of view Q exit

grep

Grep Name of the string to be queried

| pipe

The output on the left serves as the input on the right

06 Basic Use of VI

Vi: a text editor on the command line

Vi/VIM Three modes: command mode, input mode, and baseline command mode

Enter the vi command: The vi file name enters the command mode by default.

Command mode features: Except for some special keys, common keys such as W do not work.

To switch from command mode to input mode, press I on the keyboard.

Remember that the keys of the keyboard are clicked in English input method

Input mode features: Most of the keys are used as input, just like editing files.

To exit the input mode, press ESC and exit the command mode.

Command mode You can enter the baseline command mode by pressing two special buttons, each corresponding to different functions.

The first is to press the colon (:)

For example, if you want to display the line number, press set nu and then Enter to confirm. :set nonu Cancel display line number :w write, write :q quit, exit vi! Exclamation mark (!) : indicates that I know I’m going to lose some data but continue, as in q! Wq write and quit :wq write and quit

The second is the search function by pressing /

For example, if I want to find anR-related strings in a file, I can type /ANR and use the keyboard to quickly navigate to the next related string. Press N to go down to the next one, press N(Shift +n) to go up to the next one.

And of course there’s another way of looking in the opposite direction, which is to change theta to theta, right?

Like the scene above. If you want to look up, it’s input, right? ANR, and then quickly navigate to the next relevant string position via the keyboard. Press N to go up to the previous one, press N(Shift + N) to go down to the next one.

Under command mode, there are the following shortcut keys:

G/ Shift + G can quickly locate the end of the text gg can quickly locate the beginning of the text dd Delete a whole line of u undo the last operation

Under the command mode, there are some shortcut key operations, and enter the input mode after implementing the corresponding operations:

A/ Shift + A Quickly locate at the end of the line and enter input mode. I/ Shift + I Quickly locate at the beginning of the line and enter input mode. O Can be entered on the next line

Part three: Android in action

01 Setting environment Variables

Adb (Android Debug Bridge) this command is required to operate Android devices on our Macs.

Step 1: Open the configuration file

vi ~/.bash_profile

Step 2: Define a variable name save path. Variable name = file path

Step 3: Append the specific command to the PATH variable

Export PATH=$PATH: adds commands

The variable name path is obtained through the $symbol.

Which looks for the path to the command and does not print the path if the command does not exist

02 Log Filtering and search for historical commands

APP Crash log filtering

adb logcat | grep ‘AndroidRuntime’

History command lookup

The history the history | grep ‘keyword’ history | grep ‘git’

Control +c forces a running command to end

03 ADB Install APK

Adb install ADB shell Access the system of the mobile phone exit Exit the system of the mobile phone ADB push local location for saving files ADB pull Local location for saving files ADB Devices List all available connected devices adb -s device identifier install apK path to install

04 ADB Screenshot Record a video

screenshots

adb shell screencap -p /sdcard/screencap.png

Record video

adb shell screenrecord /sdcard/screenrecord.mp4

Licecap record Gif vysor projection phone

References:

Blog.csdn.net/gdutxiaoxu/…

05 adb Displays the path of the top-level interface

Path to display the top interface of the device:

adb shell dumpsys window w | grep \/ | grep name=

It can quickly locate the location of a specific page of a huge project, so that we can quickly find the corresponding interface

06 Add executable permissions to files

Chmod Modifies file permissions

Chmod u+x Add permission to the file

Caution When performing operations on a script file, ensure that you can understand the commands in the script file and ensure that the command does not damage the computer or cause other problems.

07 ANR analysis

adb shell

cd /data/anr

There is usually a testamp.txt file in which ANR analysis information is stored.

Of course I have encountered multiple files with similar prefixes before, this is part of the custom ROM that will crash ANR by the day storage. You can run ls -l to obtain the latest log. Because ANR usually happens right now and we locate it right away, so it’s looking for the latest file.

Okay, file with ANR information.

We entered through vi, and then entered the bottom line command mode by entering /. We entered the package name of our APK, hit enter to find the information of ANR, and entered N to find the next one, so as to analyze and solve the problem.