📜  设置代码命令 mac (1)

📅  最后修改于: 2023-12-03 15:41:44.078000             🧑  作者: Mango

设置代码命令 macOS

在 macOS 上,有很多可以设置代码的命令。这些命令可以帮助程序员更有效率地编写和测试代码。本文将介绍几个十分常用的设置代码命令。

Homebrew

Homebrew 是 macOS 上的包管理器,它可以帮助我们安装并管理各种包和软件。它的安装命令如下:

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

安装好 Homebrew 后,我们可以使用它来安装其他常用的软件,如 Git:

brew install git
Bash

Bash 是常用的命令行 Shell,它可以帮助我们在命令行下更高效地操作。在 macOS 中,Bash 已经默认安装。我们可以通过编辑 ~/.bash_profile 文件来设置 Bash 环境变量和命令别名等。例如,我们可以将常用的 ls 命令设置为别名 ll

alias ll='ls -alF'
Zsh

Zsh 是一款功能强大的 Shell,它具有更好的自动补全和历史记录功能,相比 Bash 更加高效和易用。我们可以使用 Homebrew 来安装 Zsh:

brew install zsh

安装好 Zsh 后,我们可以设置默认 Shell,并且添加一些常用插件,如自动补全和语法高亮:

# 设置默认 Shell
chsh -s /usr/local/bin/zsh

# 安装 Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 添加插件
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
Visual Studio Code

Visual Studio Code 是非常流行的代码编辑器,它支持各种编程语言和插件,可以帮助我们更快速地编写和测试代码。我们可以使用 Homebrew 来安装 Visual Studio Code:

brew cask install visual-studio-code

安装好 Visual Studio Code 后,我们可以设置和安装一些常用的插件,如 GitLens 和 Live Server:

# 设置默认 Shell
"terminal.external.osxExec": "/usr/local/bin/zsh"

# 安装 GitLens 插件
"git.defaultCloneDirectory": "~/Development"
"gitlens.advanced.messages": { "suppressShowKeyBindingsNotice": true }

# 安装 Live Server 插件
"liveServer.settings.donotVerifyTags": true
"liveServer.settings.ignoreFiles": [ "*.scss" ]

这些命令可以帮助程序员更好地在 macOS 上工作和编写代码。当然,还有很多其他的设置代码命令,程序员可以根据自己的需求和技能水平来选择和使用。