Mac 环境配置

安装 oh-my-zsh

后续的环境配置是基于 zsh 的,所以先安装 oh-my-zsh ,可以自行配置自己喜欢的主题。

export REMOTE=https://gitee.com/imirror/ohmyzsh.git
sh -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ohmyzsh/ohmyzsh/tools/install.sh)"

安装之后,在根目录会出现两个隐藏文件,一个 .oh-my-zsh 文件夹,一个 .zshrc 文件,我们把 .oh-my-zsh 文件夹改成不是隐藏文件夹,然后把它移到 Applications/sh 中,具体目录结构是 Applications/sh/oh-my-zsh
然后我们修改 .zshrc 文件,让其指向移动之后的 oh-my-zsh 路径(具体的路径去自己的文件夹复制)

export ZSH="/Users/gladysdrea/Applications/sh/oh-my-zsh"

我们可以在 sh 文件夹新建一个 script.sh 文件,(具体目录结构为:Applications/sh/script.sh)用来添加配置的环境变量,这样文件内容看着也整洁。我们只需要在 .oh-my-zsh 中进行指向就可以了

source $ZSH/oh-my-zsh.sh
source /Users/gladysdrea/Applications/sh/script.sh

具体的修改之后的 .oh-my-zsh 文件如下:

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/gladysdrea/Applications/sh/oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# Caution: this setting can cause issues with multiline prompts (zsh 5.7.1 and newer seem to work)
# See https://github.com/ohmyzsh/ohmyzsh/issues/5765
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

source $ZSH/oh-my-zsh.sh
source /Users/gladysdrea/Applications/sh/script.sh
# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

接下来,我们可以在 script.sh 中编写几个别名,方便使用

alias ll='ls -l'
alias update='source ~/.zshrc'
alias path_variables='open /Users/gladysdrea/Applications/sh/script.sh'
alias zsh_profile='open ~/.zshrc'

安装 Node

接下来就可以安装 Node 了,我们采用 .tar.gz 形式,这种形式的方便我们开发中切换版本,下载需要的版本的压缩包,解压之后,我们放在 Applications/Node 文件夹中,需要几个版本的就下载之后都放这个文件夹中。

配置 Node 的环境变量

script.sh文件 (后边的路径还是复制自己的文件夹路径)

NODE_HOME=/Users/gladysdrea/Applications/Node/node-v14.20.0/bin

然后,我们在 Node 文件夹下新建一个 respository 文件夹,具体目录结构为:Applications/Node/respository,用来放我们 npm 安装的东西

配置 npm 安装路径

然后执行一下命令,配置 npm 安装路径

npm config set prefix "/Users/gladysdrea/Applications/Node/respository/node_global"
npm config set cache "/Users/gladysdrea/Applications/Node/respository/node_cache"

安装全局的 Vue ,WebPack, Hexo 等

之后,我们就可以安装全局的 Vue ,WebPack, Hexo 等
最后,我们还需要在 script.sh 文件中去配置一下,完整的配置如下:

alias ll='ls -l'
alias update='source ~/.zshrc'
alias path_variables='open /Users/gladysdrea/Applications/sh/script.sh'
alias zsh_profile='open ~/.zshrc'
NODE_HOME=/Users/gladysdrea/Applications/Node/node-v14.20.0/bin
NODE_GLOBAL=/Users/gladysdrea/Applications/Node/respository/node_global/bin


PATH=$PATH:$NODE_HOME:$NODE_GLOBAL
export PATH

以上,Mac 环境配置就完成了。仅此作为每次配置环境变量的笔记记录

最后额外记录 Mac 生成 ssh 命令:

ssh-keygen -t ed25519 -C '[email protected]' 

猜你喜欢

转载自blog.csdn.net/gladysdrea/article/details/129422628