Mac使用备忘


置顶 2年前 1499次点击 来自 其他

Homebrew常用命令

brew -v 查询HomeBrew版本
brew -h brew帮助
brew update 更新Homebrew
brew install <pkg_name> 安装任意软件
brew uninstall <pkg_name> 卸载任意软件
brew search <pkg_name> 查询任意包
brew list 列出已安装的软件列表
brew list git 列出已安装软件git的文件目录
brew info <pkg_name> 查看任意包内容信息
brew upgrade <pkg_name> 更新任意包
brew cleanup <pkg_name> 删除具体旧软件
brew cleanup 删除所有旧软件
brew outdated 已安装的包是否需要更新
brew deps 已安装的包是否需要更新

修改Mac Terminal默认python版本

1. 查询本地安装python版本

ls -l /usr/local/bin/python*

2. 新建软链接

ln -s -f /usr/local/bin/python3.7 /usr/local/bin/python

使用SCP带密码传输

1.安装shhpass

git clone git://github.com/kevinburke/sshpass.git
cd sshpass
./configure
make && make install

2.使用sshpass

sshpass -p "password" scp -r user@example.com:/some/remote/path /some/local/path

Pip 换国内源解决 HTTPSConnectionPool(host=‘files.pythonhosted.org‘, port=443): Read timed out

国内镜像:

方法1:设置pip全局设置镜像源(推荐)

> pip3 config --global set global.index-url https://mirrors.aliyun.com/pypi/simple/
> pip3 config --global set install.trusted-host mirrors.aliyun.com

方法2:每次安装都指定源

pip3 install SQLAlchemy -i https://pypi.doubanio.com/simple

Mac下显示告警

WARNING: The directory '/Users/macbook/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.

添加 -H 参数

> sudo -H pip3 config --global set global.index-url https://mirrors.aliyun.com/pypi/simple/
> sudo -H pip3 config --global set install.trusted-host mirrors.aliyun.com

卸载JAVA8

sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Java/JavaVirtualMachines/

usr/local/bin下没有pipenv软链

携带参数安装pipenv即可解决上述问题

sudo -H pip install -U pipenv

Homebrew的国内安装脚本

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

M1 Homebrew : Command failed with exit 128:git

M1 brew安装错误 Command failed with exit 128:git 配置

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core

nodejs设置淘宝镜像

$ npm config set registry https://registry.npmmirror.com

多版本node切换

版本16切换至18

node -v
brew install node@18
brew unlink node@16
brew link --overwrite --force node@18

Homebrew 安装 docker

brew install docker --cask
docker version

恢复系统默认的 hosts 文件

sudo -s

回车

cat <<EOF > /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
EOF

重置权限

sudo chown root:wheel /etc/hosts; sudo chmod 644 /etc/hosts

Made with in Shangrao,China By Devler.

Copyright © Devler 2012 - 2022

赣ICP备19009883号-1