---
title: "【OS Unix-like】MacOS开发与使用技巧"
author: "Perrin Yong"
author_profile: https://www.pystone.net/profile/
published_by: "Perrin Yong"
canonical: https://www.pystone.net/notes/macos-dev-usage-tips/
type: note
content_role: unspecified
visibility: public
id_stability: rename-stable
source_path: "10-计算机、信息技术与工程/03-软件工程与质量保障/CI-CD与质量保障/CI-CD工具链/【OS Unix-like】MacOS开发与使用技巧.md"
content_hash: 22e24a75ad1851957cb6c4cbad6b659b64e0bb6fc0cdd48b5077c09f58197c96
knowledge_version: 224c990773de.5fa8af6e39fa
site_commit: 224c990773de166d23a886306577dd90379529ce
notes_commit: 5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a
---
# 【OS Unix-like】MacOS开发与使用技巧

﻿# 【OS Unix-like】MacOS开发与使用技巧

> 创建时间：2021/7/5 0:06

* 快捷键
    * System
    * 通用 General
    * 截屏
    * Finder
    * 浏览器Safari
  * Shell命令
  * 美化
  * 开发环境配置
    * brew 配置
    * Java环境
    * Python环境
      * 使用brew
        * pip的使用
      * pyenv的使用
  * 实用工具
    * 效率之王Afred
    * 编辑器
    * brew软件管理
    * 开发工具
    * 自动化工具
    * 其他工具
  * app
  * 常用设置
  * 网络相关
    * 常用命令
      * ping
    * 共享
    * 远程访问
  * Ref

## 快捷键

设置方法：系统偏好->键盘->快捷键

cmd + space 聚焦搜索
cmd + space + ter 快速打开终端
cmd + tab 切换应用程序
cmd + ～ 切换应用程序内窗口

Shift-Command-5 屏幕截图与录制
四指向上滑动：Mission Control 多屏幕调度
点按并按住窗口左上角的全屏按钮：Split View分屏

Shift + Command + . 显示全部隐藏文件

cmd + up/down 上/下一层文件夹
enter 改名

![assets/0027 - 【OS Unix-like】MacOS开发与使用技巧__resource-003-37a38e2032bc.png](/media/020141bcca2b7a53fa83.png)

![assets/0027 - 【OS Unix-like】MacOS开发与使用技巧__resource-001-43949a7463a9.png](/media/faf9b5f14dca57ccc474.png)

### System

cmd + option + esc 强制退出程序
cmd + space 切换输入法

### 通用 General

cmd + H Hide the window
cmd + M Minimize the window
cmd + O Open files
cmd + s Save
cms + shift + s Save as
cmd + W Close
cmd + Q Quit

Return 重命名

### 截屏

cmd + shift + 3 截取整个屏幕
cmd + shift + 4 截取选择区域
cmd + shift + 4 + space 截取选择窗口

### Finder

cmd + sft + . 显示隐藏文件
option + cmd + i 查看多个文件或文件夹大小
右键目标文件 + option 复制目标文件的路径
cmd + [ / ] 前进或后退
cmd + up / down 进入上级目录 / 下级目录
option + up / down 定位到多文件列表顶部/底部
shift + cmd + g 路径进入文件夹
cmd + f 查询
cmd + N 新建文件夹
cmd + Delete 删除
cmd + shift + delete 清空回收站

cmd + c 复制
cmd + v 粘贴
cmd + option + v 粘贴后删除源文件（等效于Windows的ctrl + x, ctrl + v）

### 浏览器Safari

cmd + +/- 放大/缩小
cmd + T 新建选项卡
cmd + N 新建窗口
cmd + R 刷新
xmd + F 搜索
cmd + W关闭选项卡

## Shell命令

https://explainshell.com/

![assets/0027 - 【OS Unix-like】MacOS开发与使用技巧__resource-004-21f5009b8c5f.png](/media/574c131bc82289849f8f.png)

显示隐藏

```csharp
string str1 = String.Empty;
string str2 = String.Empty;

str2 = String.Intern(sb.ToString());

if((object)str1==(object)str2)
    Console.WriteLine(&quot;The strings are equal.&quot;);
else
    Console.WriteLine(&quot;The strings are not equal.&quot;);

```

## 美化

壁纸：
Desktoppr

## 开发环境配置

### brew 配置

```csharp
string str1 = String.Empty;
string str2 = String.Empty;

str2 = String.Intern(sb.ToString());

if((object)str1==(object)str2)
    Console.WriteLine(&quot;The strings are equal.&quot;);
else
    Console.WriteLine(&quot;The strings are not equal.&quot;);

```

### Java环境

https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096875

### Python环境

Mac上有自带的Python环境，其可执行程序在 `/usr/bin` 中，安装在 `/System/Library/Frameworks/Python.framework` 中。不要卸载、改变自带的Python环境，因为操作系统以及一些其他程序是依赖 `/usr/bin`中的python的。

#### 使用brew

https://www.cjavapy.com/article/928/
使用brew安装的python位置在 `/usr/local/Frameworks/Python.framework` 当中，二进制程序在 `/usr/local/bin` 目录下。

在`~/.bashrc` 中设置符号链接

```csharp
string str1 = String.Empty;
string str2 = String.Empty;

str2 = String.Intern(sb.ToString());

if((object)str1==(object)str2)
    Console.WriteLine(&quot;The strings are equal.&quot;);
else
    Console.WriteLine(&quot;The strings are not equal.&quot;);

```

##### pip的使用

pip实质上是一个python脚本，命令行运行pip，实际上是使用相应的python版本执行pip脚本。在pip脚本中规定好使用的python版本，即可为特定的 python版本安装模块。

```csharp
string str1 = String.Empty;
string str2 = String.Empty;

str2 = String.Intern(sb.ToString());

if((object)str1==(object)str2)
    Console.WriteLine(&quot;The strings are equal.&quot;);
else
    Console.WriteLine(&quot;The strings are not equal.&quot;);

```

使用时，链接到对应的pip文件，或者将pip文件的python版本修改即可。

#### pyenv的使用

https://opensource.com/article/19/5/python-3-default-mac
https://opensource.com/article/19/6/python-virtual-environments-mac
https://www.sqlsec.com/2019/12/pyenv.html

## 实用工具

iTerm2 + zsh + oh-my-zsh
https://iterm2.com/features.html
https://ohmyz.sh/
https://github.com/ohmyzsh/ohmyzsh
https://github.com/wting/autojump

### 效率之王Afred

Afred https://www.alfredapp.com/
https://github.com/zenorocha/alfred-workflows
https://www.zhihu.com/question/20656680

option+space

查找workflow：
wf XXX

  * 打开应用程序

简单查找文件：空格+FileName， 回车：打开，cmd+回车：打开所在位置
复杂操作文件：find是定位文件，open是定位并打开文件，in是在文件中进行全文检索

输入>即可直接运行shell命令。比如>cat *.py | grep print

简单搜索：直接输入你要查询的内容，回车即可打开默认浏览器进行搜索。

有道词典：https://raw.githubusercontent.com/Louiszhai/tool/master/workflow/youdao.alfredworkflow

![assets/0027 - 【OS Unix-like】MacOS开发与使用技巧__resource-005-6ac95e32f7f7.png](/media/fbc916e23180ee9027b7.png)

IP 查询：
![assets/0027 - 【OS Unix-like】MacOS开发与使用技巧__resource-006-424fff913012.jpg](/media/691d87ea893ac0f9ed60.jpg)

指定微信好友聊天：
![assets/0027 - 【OS Unix-like】MacOS开发与使用技巧__resource-007-01d4955ec13c.jpg](/media/a0800824108d2fb4a45c.jpg)

百度地图搜索：
![assets/0027 - 【OS Unix-like】MacOS开发与使用技巧__resource-008-ea81b629357a.jpg](/media/23e455e8cbb5760d5995.jpg)

豆瓣电影搜索：
![assets/0027 - 【OS Unix-like】MacOS开发与使用技巧__resource-009-417cd778ab7f.jpg](/media/00b2144379806d594b5a.jpg)

自定义搜索：

```csharp
string str1 = String.Empty;
string str2 = String.Empty;

str2 = String.Intern(sb.ToString());

if((object)str1==(object)str2)
    Console.WriteLine(&quot;The strings are equal.&quot;);
else
    Console.WriteLine(&quot;The strings are not equal.&quot;);

```

### 编辑器

主力编辑器：Atom

Intellij IDEA

Sublime Text
Open Sublime with terminal: https://ashleynolan.co.uk/blog/launching-sublime-from-the-terminal

### brew软件管理

Brew：https://brew.sh/

```csharp
string str1 = String.Empty;
string str2 = String.Empty;

str2 = String.Intern(sb.ToString());

if((object)str1==(object)str2)
    Console.WriteLine(&quot;The strings are equal.&quot;);
else
    Console.WriteLine(&quot;The strings are not equal.&quot;);

```

### 开发工具

Dash，离线api文档，搭配aflred食用体验更佳（后文有aflred）

### 自动化工具

简单：Automator：定制自动化流程，可以配合shell和apple script脚本

  * 从PDF文件中提取文本
  * 批量重命名一组照片

高级：Jenkins

### 其他工具

FTP登陆：Cyberduck代替了之前的FileZilla

## app

Go2Shell
1password，密码管理软件，多终端密码管理

## 常用设置

## 网络相关

### 常用命令

ifconfig: 查找本机IP地址和网络接口。
netstat: 使用-r来找到特定网络接口的默认网关。
ping: 用来测试本机之间的端对端的IP连接。
arp: 管理本地的ARP缓存。

#### ping

ICMP（Internet Control Message Protocol）
如果本地连接是同的并且目的主机也是在线上并且是可以达到的，你将会输出每个ICMP（Internet Control Message Protocol）回显请求来显示每个ICMP回显应答。

### 共享

![assets/0027 - 【OS Unix-like】MacOS开发与使用技巧__resource-002-ab9b71d9d1e0.png](/media/f922a9cabed1dde0a3b4.png)

  * 互联网共享 - 把以太网接口的网络共享成 Wi-Fi

### 远程访问

> 与防火墙无关

“系统偏好设置”->“共享”->“远程登录”。

> 可以指定哪些用户可以登录

ssh username@IPAddress

## Ref

https://www.zhihu.com/question/20873070
https://github.com/hzlzh/Best-App
https://www.zhihu.com/question/20656680
https://www.zhihu.com/question/20656680/answer/427583008
