Mac 環(huán)境配置

安裝 oh-my-zsh

后續(xù)的環(huán)境配置是基于 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)"

安裝之后,在根目錄會出現(xiàn)兩個隱藏文件,一個 .oh-my-zsh 文件夾,一個 .zshrc 文件,我們把 .oh-my-zsh 文件夾改成不是隱藏文件夾,然后把它移到 Applications/sh 中,具體目錄結(jié)構(gòu)是 Applications/sh/oh-my-zsh
然后我們修改 .zshrc 文件,讓其指向移動之后的 oh-my-zsh 路徑(具體的路徑去自己的文件夾復(fù)制)

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

我們可以在 sh 文件夾新建一個 script.sh 文件,(具體目錄結(jié)構(gòu)為:Applications/sh/script.sh)用來添加配置的環(huán)境變量,這樣文件內(nèi)容看著也整潔。我們只需要在 .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 形式,這種形式的方便我們開發(fā)中切換版本,下載需要的版本的壓縮包,解壓之后,我們放在 Applications/Node 文件夾中,需要幾個版本的就下載之后都放這個文件夾中。

配置 Node 的環(huán)境變量

script.sh文件 (后邊的路徑還是復(fù)制自己的文件夾路徑)

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

然后,我們在 Node 文件夾下新建一個 respository 文件夾,具體目錄結(jié)構(gòu)為:Applications/Node/respository,用來放我們 npm 安裝的東西

配置 npm 安裝路徑

然后執(zhí)行一下命令,配置 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 環(huán)境配置就完成了。僅此作為每次配置環(huán)境變量的筆記記錄

最后額外記錄 Mac 生成 ssh 命令:

ssh-keygen -t ed25519 -C 'Gladysdrea@gmail.com' 
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容