macOS 通过CLI命令行查看、打开和关闭 WiFi

在终端中通过命令行打开或关闭 WiFi ,以及查看当前的开关状态。
可应用到自动化脚本中。

  • 先查看 Wi-Fi 的 Device 名称:
    networksetup -listnetworkserviceorder
    一般是 en0,或是 en1

  • 查询 WiFi 的开关状态
    networksetup -getairportpower en0

macOS 免费好用的 GIF 录制工具

(推荐)GIF Brewery 3 功能强大、易用:
1,除了选择屏幕区域录制,还能选择某个 App 的窗口进行录制,厉害之处就是此窗口之上叠加的别的窗口并不会被录制进去。
2,视频转 Gif; 多个 Gif 合并;
3,可以缩放分辨率,裁剪画面;
4,可以筛选画面帧;
5,支持图层,可以叠加 Gif、图片和文字;
6,修改色彩数量;
7,当然基本的播放速度、每秒帧数、循环方式也可以设置。
8,还能编辑现有的 Gif(和视频转Gif是同一种操作方式)
9,也可以当个简单的录屏软件,可以保存为 .mp4 格式

macOS 如何双击即可运行 .sh 脚本文件

一句话说明:
首先设置 .sh 文件的默认打开方式为 Terminal.app,然后通过 chmod +x myscript.sh 命令为脚本文件添加可执行权限。

以下是详细步骤:

此步骤只要操作一次即可。如果已经设置,可跳过。

Homebrew 更新自身和软件包

更新自身 brewcask: brew update

更新软件包
brew list,显示已安装的软件包
brew outdated,检查过时的软件包(是否有新版本)
brew upgrade,升级所有可以升级的软件包
brew upgrade xxx 升级指定的软件包
brew cleanup,清理不需要的版本极其安装包缓存

Homebrew 修改和复原仓库源

本文内容复制自 https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/ , 版权归原作者所有。

# 以下针对 mac OS 系统上的 Homebrew
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git
git -C "$(brew --repo homebrew/cask-versions)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-versions.git

# 以下针对 Linux 系统上的 Linuxbrew
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/linuxbrew-core.git

# 更换后测试工作是否正常
brew update
# 以下针对 mac OS 系统上的 Homebrew
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://github.com/Homebrew/homebrew-cask-fonts.git
git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://github.com/Homebrew/homebrew-cask-drivers.git
git -C "$(brew --repo homebrew/cask-versions)" remote set-url origin https://github.com/Homebrew/homebrew-cask-versions.git

# 以下针对 Linux 系统上的 Linuxbrew
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/linuxbrew-core.git

# 更换后测试工作是否正常
brew update

参考

安装 Python virtualenv

virtualenv 是一款 Python 虚拟运行环境管理工具。

这里介绍使用 pip 来安装 virtualenv,

如果所安装的 Python 没有自带 pip,可以参考这篇文章pip 的安装

pip install virtualenv

若系统同时安装了 Python2 和 Python 3(非默认版本),想在 Pthon 3环境下使用 virtualenv,