Skip to content
Go back

My Mac

Updated:  at  12:55

On this page

Homebrew

brew list

安装

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

卸载

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

换源

zsh 终端下:

git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

brew update
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zshrc
source ~/.zshrc

常用命令

软件

/Applications && ls

launchctl

launchctl 将根据 plist 文件的信息来启动任务

plist 目录

plist 文件

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <!-- Label唯一的标识 -->
        <key>Label</key>
        <string>com.demo.plist</string>
        <!-- 指定要运行的脚本 -->
        <key>ProgramArguments</key>
        <array>
            <string>/Users/demo/run.sh</string>
        </array>
        <!-- 指定要运行的时间 -->
        <key>StartCalendarInterval</key>
        <dict>
            <key>Minute</key>
            <integer>00</integer>
            <key>Hour</key>
            <integer>22</integer>
        </dict>
        <!-- 标准输出文件 -->
        <key>StandardOutPath</key>
        <string>/Users/demo/run.log</string>
        <!-- 标准错误输出文件,错误日志 -->
        <key>StandardErrorPath</key>
        <string>/Users/demo/run.err</string>
    </dict>
</plist>

常用命令

1.显示当前的启动脚本
launchctl list
# 查看任务列表, 使用 grep '任务部分名字' 过滤
launchctl list | grep 'com.demo'
2.开机时自动启动Apache服务器
launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
3.设置开机启动并立即启动改服务
launchctl load -w   **.pist
4. 设置开机启动但不立即启动服务
launchctl load **.pist
5. 停止正在运行的启动脚本
launchctl unload [path/to/script]
6. 再加上-w选项即可去除开机启动
launchctl unload -w [path/to/script]
7. 开始任务
launchctl start com.demo.plist
8. 结束任务
launchctl stop com.demo.plist

mysql

brew services start mysql
brew services stop mysql
brew services restart mysql

references

https://ss64.com/osx/launchctl.html

软件提示已损坏,需要移到废纸篓的解决方法

sudo spctl --master-disable
xattr -r -d com.apple.quarantine <path>

<path> 是你下载的应用程序的路径,一般在/Applications/应用程序名字

查看隐藏文件

Command+Shift+. 可以显示隐藏文件、文件夹,再按一次,恢复隐藏


Suggest Changes

Previous Post
WebAssembly
Next Post
Linux Basic Command

Most Related Posts

  • Linux Basic Command

    Updated:  at  00:20

    Linux Basic Command

  • WSL 基本使用

    Published:  at  12:40

    WSL (Windows Subsystem for Linux) 的基本安装、配置、使用方法以及常见问题的解决方案。

  • My Linux

    Updated:  at  11:31

    my linux

  • codec in js

    Published:  at  17:00

    codec in js

  • My Windows

    Updated:  at  18:48

    my windows