Phil's Dev Note

MacOS

MacOS

快捷键

同时重命名多个文件

  • 拆字法打字

System

  • ++space++ 预览文件
  • ++command+space++ 打开聚焦
  • ++ctrl+arrow-up++ mission control
  • ++command+control+q++ 锁屏

Folder

  • ++command+bracket-left++ 返回上一级
  • ++command+bracket-right++ 前往下一级

Apps

  • ++command+q++ 退出应用程序

把鼠标移动到 另一个显示器屏幕底部,然后继续往下推一点(类似“顶到屏幕边缘”再往下挤的动作)。

几秒钟后,Dock 就会跳到你鼠标所在的那个显示器。

Typing

  • ++fn+backspace++ 在 mac 中等于 ++del++
  • ++command+control+space++ emoji
  • ++shift+option+b++ 颜文字
  • ++tab++ 使用声调打字

Safari

  • ++command+t++ 打开一个新的标签页,快速开始新的浏览任务
  • ++command+arrow-up++ 移动到网页左上角,快速回到页面顶部
  • ++command+arrow-down++ 移动到网页左下角,快速跳转到页面底部
  • ++command+l++ 跳转到地址栏
  • ++control+tab++ / ++command+shift+bracket-right++ 切换到下一个标签页
  • ++shift+command+backslash++ 显示所有网页标签页
  • ++control+command+2++ 打开或关闭阅读列表边栏
  • ++shift+command+d++ 将当前页面加入阅读列表
  • ++option+click++ 点击链接文件时同时按住 ++option++ 键即可直接下载

iTerm2

  • ++command+d++ 在当前标签页中创建垂直分屏

  • ++command+arrow-left++ / ++command+arrow-right++ 在不同标签页之间切换

  • ++option+command+arrow-left++ / ++option+command+arrow-right++ 在同一标签页的分屏面板之间切换

  • ++command+r++ / ++ctrl+l++ 清屏

  • ++ctrl+u++ 清除当前行

  • ++ctrl+d++ 删除当前光标的字符

  • ++ctrl+h++ 删除光标之前的字符

  • ++ctrl+w++ 删除光标之前的单词

  • ++ctrl+k++ 删除到文本末尾

  • ++ctrl+t++ 交换光标处文本

  • ++ctrl+a++ 光标移动到行首

  • ++ctrl+e++ 光标移动到行末

假设你在终端中输入了以下命令,但发现路径和参数都有误:

cat /var/log/system.log | grep "ERROR" | tail -n 100 > /tmp/output.txt

现在你想把它改成:

cat /var/log/app.log | grep "WARN" | tail -n 50 > /tmp/warn.txt

操作步骤:

  1. ++ctrl+a++ — 光标跳到行首
  2. ++ctrl+f++ 或方向键向右移动到 /var/log/ 之后,输入 app,然后用 ++ctrl+d++ 逐个删除 system 的字符
  3. 继续向右移动到 "ERROR",用 ++ctrl+w++ 删除 "ERROR"(光标在 " 后时按 ++ctrl+w++ 删除整个单词),然后输入 "WARN"
  4. 移动到 100,用 ++ctrl+u++ 清除整行重新输入(或用 ++ctrl+w++ 逐段删除后修改为 50
  5. ++ctrl+e++ 跳到行末,用 ++ctrl+h++ 删除 t,再输入 warn
  6. 按回车执行,然后用 ++ctrl+l++ 清屏查看结果

💡 技巧:对于这种大幅修改,也可以直接按 ++ctrl+u++ 清空当前行后重新输入,或使用 ++ctrl+r++ 清屏后重新键入命令。

系统设置

  • 三指拖移:设置 - 辅助功能 - 指针控制 - 触控板选项 - 拖移样式
  • 触控板轻点:设置 - 触控板 - 轻点来点按
open Finder in terminal
open .

开发配置

软件已损坏?怎么解决

信任开发者
sudo spctl --master-disable
放行 picgo
xattr -cr /Applications/xxx.app

科学上网

下载clash-verge-rev,安装后配置好代理,然后就可以开始安装 homebrew 了

homebrew

首先需要配置好 vpn

安装 homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
系统会跳出三个指令让你执行,类似于
echo >> /Users/philfan/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/philfan/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
验证安装
brew help
wget 安装
brew install wget

python

安装 uv
brew install uv
验证安装
uv --version
安装 miniconda
brew install miniconda
验证安装
conda -V

node

安装 node
brew install node
验证安装
node -v

编程软件

安装
brew install --cask codex
brew install --cask claude-code
brew install gemini-cli

paragon:NTFS 读写

在使用硬盘传数据的时候,老是报错误代码 -50,搜了一下才发现 mac 原生是不支持 NTFS 文件系统的

NTFS(New Technology File System)是由微软开发的一种文件系统,最早在 Windows NT 操作系统中引入。它是 Windows 系统的默认文件系统,用于存储和检索硬盘上的数据。

官网地址

Microsoft NTFS for Mac | Paragon Software

搜了一下发现希捷的官网有一个免费的版本

Paragon 驱动程序 | Seagate 中国

WPS

zju 有企业账号,SSO 登陆输入 ZJU,验证登陆即可

qq 音乐歌单导入 apple music

  1. 获取 qq 音乐的歌单 id
  2. 通过 id 获取歌单曲目
  3. 通过 Tune My Music 向 apple music 导入歌单曲目

参考文章:将 QQ 音乐的歌单导入 apple music - 知乎

Apple Script

  • 系统自带的“脚本编辑器”
  • vscode 中code runner插件

参考资料 AppleScript 入门:探索 macOS 自动化 - 少数派 kevin-funderburg/AppleScripts: My collection of AppleScripts I've developed or acquired over the years.

conda 环境

Miniconda — Anaconda documentation miniconda 下载 m1/m2 MAC OS m2 安装和卸载 miniconda - 知乎 安装

# 文件名是自己下载的 sh 文件,-p 后面填安装路径
# -b 表示将环境变量自动写入到~/.bash 文件中
sh Miniconda3-latest-MacOSX-arm64.sh -b -p ~/miniconda3

前往安装地址,打开终端

source /bin/activate

执行

conda init zsh #zsh 执行这个命令
或者
conda init bash #bash 执行这个命令
加入路径
vim ~/.zshrc
export PATH=/yourpath/anaconda3/bin:$PATH
source ~/.zshrc

注意:上面的”/yourpath”要替换成你自己的 Anaconda 安装目录。 按 esc 退出编辑模式,保存文件并退出(输入”:wq”回车)

换 conda 源

THU

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
# 搜索时显示通道地址
conda config --set show_channel_urls yes

ustc 源

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes

换 pip 源

解决方案:将配置好国内源的pip.conf文件,放在 ~/Library/Application Support/pip 中。

可能有的新用户发现自己的文件夹中没有 pip 文件夹,不慌,新建就行!

command + 空格            #  打开聚焦搜索
输入 ~/Library/Application Support       # 找到 Application Support 文件夹

Application Support这个文件夹里面建一个 pip 文件夹; 在新建的 pip 文件夹下建一个pip.conf文件。

pip.conf文件中输入以下内容,保存并退出。

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn

卸载

(1)使用 Anaconda-Clean 包删除所有与 conda 相关的文件和目录

conda activate your_conda_env_name
conda install anaconda-clean
anaconda-clean --yes # 避免被提示删除每个文件
#注:如果这一步之行不成功,可以直接跳过

(2)删除整个目录(直接删掉安装文件就可)

rm -rf ~/miniconda3

(3)删除将 conda 路径添加到 PATH 环境变量的行(或者注释掉)

注:其实只执行第二步就可,后边这两步为了再次安装时,环境冲突,所以删干净

vi ~/.bashrc
# -> Search for conda and delete the lines containing it
# -> If you're not sure if the line belongs to conda, comment it instead of deleting it just to be safe
source ~/.bashrc
vi ~/.zshrc
# -> Search for conda and delete the lines containing it
# -> If you're not sure if the line belongs to conda, comment it instead of deleting it just to be safe
source ~/.zshrc

(4)删除配置文件

rm -rf ~/.condarc
#注:自己找一下~/.conda 开头的文件,删掉

On this page