macOS
命令列表
- open:open files and directories
- xattr: display and manipulate extended attributes
- xcode-select: Manages the active developer directory for Xcode and BSD tools.
open
open files and directories
功能:
- 打开目录:用finder打开
- 打开文件:用默认的应用打开
- 打开URL:用默认的浏览器打开
- 打开应用:用指定的应用打开
- 指定应用的路径
- 指定应用的bundle id
bash
# 1. 打开目录:用finder打开
$ open $dir_name
# 2. 打开文件:用默认的应用打开
$ open $file_name
$ open $dir_name -a $app_name
# 3. 打开URL:用默认的浏览器打开
open http://www.apple.com/
# 4. 打开应用:用指定的应用打开
# 1. 指定应用的路径
$ open $dir_name -a /Applications/Visual\ Studio\ Code.app
# 2. 指定应用的bundle id
$ open -b com.apple.TextEdit $file_name
xattr
bash
# notarized or signed 认证或签名
$ xattr -r -d com.apple.quarantine ${App Path}
xcode-select
bash
# 安装工具链
$ xcode-select install
实用脚本
bash
# `cdf`: 转跳到 finder 打开的目录 (fish脚本)
function cdf
set finder_current_dir $(osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)')
cd $finder_current_dir
end
Deprecated(以前用、现在不怎么用)
oh-my-zsh macos plugin
开启:.zshrc
文件
bash
plugins=(... macos)
常用命令:
Command | Description |
---|---|
pfd | Return the path of the frontmost Finder window |
pfs | Return the current Finder selection |
ofd | Open the current directory in a Finder window |
cdf | cd to the current Finder directory |
man-preview | Open man pages in Preview app |