综合帖

https://www.jianshu.com/p/d5d0915ea09c


工具

Git-osx-install

Git-osx-installhttps://sourceforge.net/projects/git-osx-installer/


Homebrew - Mac OSX 的包管理

# 安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

# 换国内源!!!
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

# 替换homebrew-cask.git:
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

如果提示没有homebrew-cask目录,就先执行brew cask 安装homebrew-cask框架

完成!!!

如果上面的安装方法非常慢,参考以下方法:

# 建议brew使用以下命令安装,安装过程中在安装homebrew-core时会失败,不理会,此时brew已安装成功
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

如果还是安装失败则手动安装:
mkdir /usr/local/Homebrew
下载zip回来,文件解压到上面这个目录:https://github.com/Homebrew/brew
git remote add origin https://mirrors.aliyun.com/homebrew/brew.git

下载zip回来,文件解压到上面这个目录:https://github.com/Homebrew/brew
git remote add origin https://mirrors.aliyun.com/homebrew/brew.git

接着安装homeberw-core和homeberw-cask
mkdir -p ./Library/Taps/homebrew
open ./Library/Taps/homebrew
下载zip文件解压:
https://github.com/Homebrew/homebrew-core
https://github.com/Homebrew/homebrew-cask
目录名为:homeberw-core、homeberw-cask

cd ./Library/Taps/homebrew/homebrew-core
git init
git remote add origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
git reset --hard origin/master

cd ../homebrew-cask
git init
git remote add origin https://mirrors.ustc.edu.cn/homebrew-cask.git
git reset --hard origin/master

cd ~

# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

完成!!!
此时可以使用brew update更新了。

参考:https://www.raydbg.com/2019/Homebrew-Update-Slow/


磁盘管理工具

https://www.jianshu.com/p/6a1f365617ad


开启与关闭SIP

1. 查看SIP状态
在终端中输入csrutil status,就可以看到是enabled还是disabled。

2. 关闭SIP
S1  重启MAC,按住cmd+R直到屏幕上出现苹果的标志和进度条,进入Recovery模式;
S2  在屏幕最上方的工具栏找到实用工具(左数第3个),打开终端,输入:csrutil disable;
S3  关掉终端,重启mac;
S4  重启以后可以在终端中查看状态确认。

3. 开启SIP
与关闭的步骤类似,只是在S2中输入csrutil enable即可。


Alfred插件

代码、翻译必备:https://blog.julysong.com/2018/07/05/Alfred-youdao/
搜索建议:https://github.com/AkikoZ/alfred-web-search-suggest
微信助手:https://github.com/TKkk-iOSer/wechat-alfred-workflow
插件仓库:https://github.com/wsgggws/alfred3-workflows


XCode

官方开发工具,同时也能解决很多环境问题


wget

brew install wget

有时遇到默认的下载链接速度十分坑爹,就 brew edit wget 修改下链接再装


iterm2

https://www.zhihu.com/question/27447370
https://www.raydbg.com/2019/My-Productivity-Mac-Configuration/

iTerm2 提供了一个 Python 包,通过它我们可以轻松编写控制 iTerm2 并扩展其行为的 Python 脚本。
https://iterm2.com/python-api/


SSH Shell

在App Store里有这款软件,不是免费的。有点像xshell,很好用。


Termius

https://www.termius.com/
跨平台ssh工具,好用!


Oh-my-zsh

Oh-my-zsh

wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

重新打开终端就好了。
卸载:uninstall_oh_my_zsh

终极 Shell——ZSH

zsh-autosuggestion
便捷的命令行建议及历史记录

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

# 修改配置
vim ~/.zshrc
在插件列表中启用插件(多个插件换行)
plugins=(zsh-autosuggestions)

source ~/.zshrc

autojump插件
zsh 和 autojump 的组合形成了 zsh 下最强悍的插件
Mac:brew install autojump
Linux:

wget https://github.com/downloads/joelthelion/autojump/autojump_v21.1.2.tar.gz
tar zxvf autojump_v21.1.2.tar.gz
cd autojump_v21.1.2
./install.sh

修改配置文件
vim ~/.zshrc加入以下这句

[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh

autossh

自动连接ssh,保持持久连接
https://github.com/FeeiCN/autossh

图床工具

https://github.com/Molunerfinn/PicGo/releases


技巧

使用pem文件登录Linux

sudo chmod 600 key.pem       #权限必须为600
ssh root@192.168.199.100 -p 22022 -i /Users/LeoLan/key.pem     #这样就可以登陆啦

ssh-add -k /Users/LeoLan/key.pem    #添加一下键文件
#添加键文件后,以后可以直接用ssh root@192.168.199.100 -p 22022 的方式登录

修改Launchpad(启动器)应用图标大小

# 还原默认设置
defaults write com.apple.dock springboard-rows Default
defaults write com.apple.dock springboard-columns Default
killall Dock

# 修改行数(这里是6行)
defaults write com.apple.dock springboard-rows -int 6
# 修改列数(这里是8列)
defaults write com.apple.dock springboard-columns -int 8
# 重启生效
killall Dock


tldr 命令帮助(比man简明清晰)

brew install tldr
使用:tldr [命令,如:tar]

各种文档预览功能

mac自带的预览只能预览图片、音视频、部分文档;通过组件增强预览功能;项目地址:https://github.com/sindresorhus/quick-look-plugins

brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json qlprettypatch quicklook-csv betterzipql qlimagesize webpquicklook suspicious-package quicklookase qlvideo

Python环境混乱

自带的python在框架目录:

System/Library/Frameworks/Python.framework

默认是python2,建议保留。

而自己安装的python2或python3可能在:

/Library/Frameworks/Python.framework   #官方pkg包安装
或
/usr/local/Cellar/python               #brew安装的

清理环境,只保留mac自带的python2

# pkg安装的处理方法(其中x.x为 Python 的版本号)
# 删除框架
sudo rm -rf /Library/Frameworks/Python.framework/Versions/x.x
# 删除应用目录
sudo rm -rf "/Applications/Python x.x"
# 删除软链接
cd /usr/local/bin/
ls -l /usr/local/bin | grep '../../../Library/Frameworks/Python.framework/Versions/x.x' | awk '{print $9}' | tr -d @ | xargs rm

#brew安装的处理方法
brew uninstall python2
brew uninstall python3
按提示执行一条命令清理赶紧。

为了便于管理,建议只用brew安装python3(python2自带就行);或者不安装,而是使用软件自带的,比如pycharm、Anaconda(https://www.anaconda.com/)等都自带有。


开机启动执行脚本

参考:
https://www.jishuwen.com/d/2cAv
打开链接搜索:Mac开机启动项

文章作者: Leo
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LeoLan的小站
环境搭建 mac常用工具
喜欢就支持一下吧