MacOS 工作环境配置

1. 工具 Alfred

2. 软件包管理工具 Homebrew

官网 https://brew.sh/

若无法安装,则使用替代源
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

3. Git 工具

3.1 安装

官网 https://git-scm.com/downloads

通过 Homebrew 安装 $ brew install git

3.2 配置账号

# 初次配置
% git config --global user.name yourName
% git config --global user.email xxx@163.com

# 查看配置
% git config --list 

生成密钥

$ ssh-keygen -t rsa -C xxx@163.com
# 按 3 个回车,密码为空

位置 ~/.ssh

% open ~/.ssh

添加 SSH 密钥 id_rsa.pub

3.3 常用命令

git status
git pull
git add .
git commit -m 'update'
git push

4. 工具 Sublime Text

地址 https://www.sublimetext.com/download

4.1 插件工具(Package Control)

4.2 左侧导航目录

Project -> Add Folder to Project...

5. 设置环境变量

5.1 命令行环境

从 macOS Catalina(版本10.15)开始,zsh (Z shell) 是所有新建用户帐户的默认 Shell

查看支持的命令行环境

% cat /etc/shells 
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

查看当前命令行环境

% echo $SHELL
/bin/zsh

5.2 环境变量

# 系统级别
/etc/profile
/etc/paths 
 
# 用户级别
~/.bash_profile 
~/.bash_login 
~/.profile 
~/.zshrc

.bash_profile 只对当前窗口有效
.zshrc 在电脑每次自启时都生效(永久有效)

% touch .zshrc
% open .zshrc
% source .zshrc 

7. 其他

7.1 设置磁盘访问权限

报错:Operation not permitted
偏好设置 -> 安全与隐私 -> 隐私
设置:完全磁盘访问权限
设置:文件和文件夹

命令方式

# 赋予文件夹及子目录权限
sudo chmod -R 777 dirName

7.2 安装 pkg 文件

示例:安装 Homebrew.pkg

touch .zshrc 
open -e ~/.zshrc

添加

BREW_HOME=/opt/homebrew/bin
export PATH=$BREW_HOME:$PATH

或者

vim ~/.bash_profile

:wq 保存退出
:q! 不保存退出

使配置生效 source ~/.bash_profile

【信息由网络或者个人提供,如有涉及版权请联系COOY资源网邮箱处理】

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容