侧边栏壁纸
博主头像
蚌埠住了捏博主等级

快乐,健康,自由,强大

  • 累计撰写 33 篇文章
  • 累计创建 10 个标签
  • 累计收到 17 条评论

目 录CONTENT

文章目录

Mac终端环境安装备忘录

蚌埠住了捏
2023-03-19 / 0 评论 / 1 点赞 / 418 阅读 / 706 字

有一个不辣眼睛、便捷的终端很重要!

拿到一台新的Mac,按如下顺序操作。

Homebrew

推荐。国内安装首选镜像源,极速安装且环境变量自动配置完成。

# 镜像源安装
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

# 安装后配置镜像源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
brew update

国外安装直接用官方的。

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

iTerm2

推荐。直接google搜,下载安装包双击运行

或者brew cask。brew是下载源码解压然后./configure && make install, 并且会自动配置好环境变量。brew cask主要用于有GUI的软件,下载已经编译好的应用包(.dmg/.pkg)。

# 安装cask
brew install caskroom/cask/brew-cask
brew cask install iterm2

oh-my-zsh

官网一行搞定

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 切换默认shell为zsh
chsh -s /bin/zsh

主题dracula

zsh主题配置

官网dracula安装教程

截屏2023-03-19 13.01.18.png

# download
git clone https://github.com/dracula/zsh.git

# Move dracula.zsh-theme file to oh-my-zsh's theme folder: oh-my-zsh/themes/dracula.zsh-theme.
cp $DRACULA_PATH/dracula.zsh-theme ~/.oh-my-zsh/themes/dracula.zsh-theme

# Move /lib to oh-my-zsh's theme folder: oh-my-zsh/themes/lib.
cp -r $DRACULA_PATH/lib ~/.oh-my-zsh/themes/lib

# Go to your `~/.zshrc` file and set `ZSH_THEME="dracula"`.
# '/ZSH_THEME'查找一下字符串,然后修改配置。!wq保存退出
vim ~/.zshrc

iTerm2主题配置

官网教程

# download
git clone https://github.com/dracula/iterm.git

设置主题:

  1. iTerm2 > Preferences > Profiles > Colors Tab
  2. Open the Color Presets… drop-down in the bottom right corner
  3. Select Import… from the list
  4. Select the Dracula.itermcolors file
  5. Select the Dracula from Color Presets…

vim主题语法高亮

# 打开或新建vim配置文件
vim ~/.vimrc

# 添加语法高亮命令,保存退出:wq
syntax on

这样以后用vim就不辣眼睛了,效果图如下

截屏2023-03-19 13.26.08.png

命令行插件

命令行高亮插件

zsh-syntax-highlighting,命令正确绿色,命令错误红色。

# 下载
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

# 配置到配置文件~/.zshrc
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

小坑

Note the source command must be at the end of ~/.zshrc.

命令提示插件

zsh-autosuggestions,根据历史提示命令行输入,作用有限。

# 下载到~/.zsh/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions

# 编辑配置文件
vim ~/.zshrc

# 在末尾添加如下命令
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

重启生效

更多:iterm2, oh-my-zsh官方文档

参考链接

macOS安装brew教程从入门到入土

利用iTerm2+oh-my-zsh+Dracula主题打造我的Mac终端利器

1

评论区