网站怎么看好与不好网站建设软件 免费
- 作者: 五速梦信息网
- 时间: 2026年03月21日 07:20
当前位置: 首页 > news >正文
网站怎么看好与不好,网站建设软件 免费,高端室内设计,手机网站 phpGit 官网也提到了MacBook 可以使用 Homebrew 安装 Git#xff0c;所以在此使用 Homebrew 安装。 1、安装 Homebrew 执行安装脚本 在 Terminal 中执行如下命令#xff1a; /bin/bash -c \((curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.…Git 官网也提到了MacBook 可以使用 Homebrew 安装 Git所以在此使用 Homebrew 安装。 1、安装 Homebrew 执行安装脚本 在 Terminal 中执行如下命令 /bin/bash -c \)(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)其实就是**执行作者写的一个脚本文件 install.sh。**这个脚本很方便已经配置好了镜像源如果上述命令执行成功就无需再配置镜像源。 安装的完整过程如下 larrylalarryladeMacBook-Air ~ % /bin/bash -c $(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)Checking for sudo access (which may request your password)… Password:You are using macOS 15.1.We do not provide support for this pre-release version. 因为系统版本可能会遇到一些未知问题 The following new directories will be created: /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/FrameworksThe Xcode Command Line Tools will be installed.安装提示Mac下镜像飞速安装Homebrew教程请收藏https://brew.idayer.com/打个小广告 欢迎使用[快系列]教程必出精品安装有保障- [快系列]stable-diffusion-webui: https://brew.idayer.com/install/stable-diffusion-webui
[快系列]nvm快速安装教程: https://brew.idayer.com/install/nvm-for-nodejs安装遇到问题请添加讨论群寻求Homebre的安装帮助。当然也非常欢迎大家加群聊天摸鱼讨论mac、软件、摄影扫码关注公众号湖中剑回复brew加群。█████████████████████████████████████ █████████████████████████████████████ ████ ▄▄▄▄▄ █▀█ █▄▀▄ ▄ ▄▄██ ▄▄▄▄▄ ████ ████ █ █ █▀▀▀█ ▀█▀▀▀▀▄▀█ █ █ ████ ████ █▄▄▄█ █▀ █▀▀█▄▀ █▀▄ █ █▄▄▄█ ████ ████▄▄▄▄▄▄▄█▄▀ ▀▄█▄▀ █▄▀ █▄▄▄▄▄▄▄████ ████ ▀▄▄▄▄▀▄▀▄▄█▀▀█ █ ▀ ▀▄█▄▀████ ████ ▀█▄▀▀▄ █▄█▀█ ▄██ █ ▀ ▄▄██▀█████ ████ █ █▄ ▄ ▄█▄ ▀ ██ ▀ ▀▀▀▄ █▀████ ████ ██▄██▄▀ █ ▄█▀ ▄▄▀▀ ▀ █▄█▄▀█████ ████ ▄ ▀▄▄▄▀█▄ ▄▀ ▀ ▀█▀ ▀▀ █▀████ ████ █ ▀▀▀▄█▄█▄█▀█▀▄ █▀▀▄▄█▄▄▄▄▀█████ ████▄██▄▄█▄█▀▀▀█▄█▄ ▀▄▀█ ▄▄▄ ▀ ████ ████ ▄▄▄▄▄ █▄▀ ▄█▄ ▄▀ █▄█ ▄▀█████ ████ █ █ █ ▀▄▄ ▀▄ ▀███ ▄▄▄▄ ▄▀ ████ ████ █▄▄▄█ █ ▄▄▀ ██▄▀▄▀▄ ▀▄ ▄ █████ ████▄▄▄▄▄▄▄█▄▄█▄▄████▄█████▄▄█▄██████ █████████████████████████████████████ █████████████████████████████████████请按回车键RETURN继续安装按其他任意按键取消安装/usr/bin/sudo /usr/bin/install -d -o root -g wheel -m 0755 /opt/homebrew/usr/bin/sudo /bin/mkdir -p /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks/usr/bin/sudo /bin/chmod ugrwx /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks/usr/bin/sudo /bin/chmod go-w /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions/usr/bin/sudo /usr/sbin/chown larryla /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks/usr/bin/sudo /usr/bin/chgrp admin /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks/usr/bin/sudo /usr/sbin/chown -R larryla:admin /opt/homebrew/usr/bin/sudo /bin/mkdir -p /Users/larryla/Library/Caches/Homebrew/usr/bin/sudo /bin/chmod grwx /Users/larryla/Library/Caches/Homebrew/usr/bin/sudo /usr/sbin/chown -R larryla /Users/larryla/Library/Caches/HomebrewSearching online for the Command Line Tools/usr/bin/sudo /usr/bin/touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progressInstalling Command Line Tools for Xcode-16.2/usr/bin/sudo /usr/sbin/softwareupdate -i Command\ Line\ Tools\ for\ Xcode-16.2 Software Update ToolFinding available softwareDownloading Command Line Tools for Xcode Downloaded Command Line Tools for Xcode Installing Command Line Tools for Xcode Done with Command Line Tools for Xcode Done./usr/bin/sudo /usr/bin/xcode-select –switch /Library/Developer/CommandLineTools Password: Sorry, try again. Password:/usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress Downloading and installing Homebrew… remote: Enumerating objects: 288347, done. remote: Counting objects: 100% (44⁄44), done. remote: Compressing objects: 100% (44⁄44), done. remote: Total 288347 (delta 0), reused 44 (delta 0), pack-reused 288303 Receiving objects: 100% (288347⁄288347), 90.04 MiB | 6.20 MiB/s, done. Resolving deltas: 100% (206656⁄206656), done. From https://mirrors.ustc.edu.cn/brew* [new branch] SMillerDev-patch-1 - origin/SMillerDev-patch-1* [new branch] cleaner-factory - origin/cleaner-factory* [new branch] dependabot/bundler/Library/Homebrew/rubocop-1.65.1 - origin/dependabot/bundler/Library/Homebrew/rubocop-1.65.1* [new branch] depends-on-order-cop-blank-lines - origin/depends-on-order-cop-blank-lines* [new branch] deprecate-old-style-cmds - origin/deprecate-old-style-cmds* [new branch] info-analytics-timeout - origin/info-analytics-timeout* [new branch] load-installed-casks - origin/load-installed-casks* [new branch] load-internal-cask-json-v3 - origin/load-internal-cask-json-v3* [new branch] make-brew-typecheck-work-with-taps - origin/make-brew-typecheck-work-with-taps* [new branch] master - origin/master* [new branch] tmpdir-sandbox - origin/tmpdir-sandbox* [new branch] use-cask-tab-to-better-identify-installed-casks - origin/use-cask-tab-to-better-identify-installed-casks* [new tag] 0.1 - 0.1* [new tag] 0.2 - 0.2* [new tag] 0.3 - 0.3* [new tag] 0.4 - 0.4* [new tag] 0.5 - 0.5* [new tag] 0.6 - 0.6* [new tag] 0.7 - 0.7* [new tag] 0.7.1 - 0.7.1……* [new tag] 4.4.11 - 4.4.11* [new tag] 4.4.12 - 4.4.12* [new tag] 4.4.13 - 4.4.13* [new tag] 4.4.2 - 4.4.2* [new tag] 4.4.3 - 4.4.3* [new tag] 4.4.4 - 4.4.4* [new tag] 4.4.5 - 4.4.5* [new tag] 4.4.6 - 4.4.6* [new tag] 4.4.7 - 4.4.7* [new tag] 4.4.8 - 4.4.8* [new tag] 4.4.9 - 4.4.9 remote: Enumerating objects: 55, done. remote: Counting objects: 100% (33⁄33), done. remote: Total 55 (delta 33), reused 33 (delta 33), pack-reused 22 Unpacking objects: 100% (55⁄55), 9.08 KiB | 216.00 KiB/s, done. From https://mirrors.ustc.edu.cn/brew* [new tag] 4.0.29 - 4.0.29* [new tag] 4.1.9 - 4.1.9* [new tag] 4.2.14 - 4.2.14* [new tag] 4.3.10 - 4.3.10 HEAD is now at e330f371f8 Merge pull request #19002 from Homebrew/dependabot/bundler/Library/Homebrew/regexp_parser-2.10.0Tapping homebrew/services remote: Enumerating objects: 3796, done. remote: Total 3796 (delta 0), reused 0 (delta 0), pack-reused 3796 Receiving objects: 100% (3796⁄3796), 1.11 MiB | 1.49 MiB/s, done. Resolving deltas: 100% (1858⁄1858), done. From https://mirrors.ustc.edu.cn/homebrew-services* [new branch] master - origin/master HEAD is now at 6df0008 Merge pull request #854 from Homebrew/dependabot/bundler/bigdecimal-3.1.9 HOMEBREW_BREW_GIT_REMOTE set: using https://mirrors.ustc.edu.cn/brew.git as the Homebrew/brew Git remote.Updating Homebrew…Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/bottles-portable-ruby/portable-ruby-3.3.6.arm64_big_sur.bottle.tar.gz ################################################################################################################################################################### 100.0%Pouring portable-ruby-3.3.6.arm64_big_sur.bottle.tar.gzNext steps: 自动配置环境变量 执行成功重要信息!!!重要信息!!!重要信息!!! 如果遇到 command not found brew请执行下面脚本完成安装或者直接重新打开终端: eval $(/opt/homebrew/bin/brew shellenv) 恭喜安装成功
验证命令 brew help
请收藏谨防失联: https://brew.idayer.com 如果有幸帮助到你可以考虑请我喝杯咖啡~☕ 喝咖啡https://brew.idayer.com/reward/如上所示提示安装成功。 配置环境变量 依次执行如下命令 echo eval \((/opt/homebrew/bin/brew shellenv) ~/.zprofileeval \)(/opt/homebrew/bin/brew shellenv)Homebrew 环境变量会被配置到文件 .zprofile 中 检查 Homebrew 是否安装成功 执行命令 larrylalarryladeMacBook-Air ~ % brew help Example usage:brew search TEXT|/REGEX/brew info [FORMULA|CASK…]brew install FORMULA|CASK…brew updatebrew upgrade [FORMULA|CASK…]brew uninstall FORMULA|CASK…brew list [FORMULA|CASK…]Troubleshooting:brew configbrew doctorbrew install –verbose –debug FORMULA|CASKContributing:brew create URL [–no-fetch]brew edit [FORMULA|CASK…]Further help:brew commandsbrew help [COMMAND]man brewhttps://docs.brew.sh如上所示显示帮助信息说明 Homebrew 安装成功。 2、安装 Git 我原本是想使用 Homebrew 安装 Git 的结果在安装 Homebrew 的过程中弹出来一个对话框提示我安装“Command Line Developer Tools”。 Command Line Developer Tools 是 macOS 提供的一组工具用于命令行开发包含了编译器clang、版本控制工具git、构建工具make和调试工具等。它们是开发者进行软件开发的基础工具可以独立于完整的 Xcode 安装只需占用较少的存储空间。 看到有 Git我就直接同意安装了 安装完成后检查 Git 是否成功安装 larrylalarryladeMacBook-Air ~ % git -v git version 2.39.5 (Apple Git-154)安装成功。 查看 git 位置 larrylalarryladeMacBook-Air ~ % which git /usr/bin/git/usr/bin/这是一个常见的系统目录存放系统级的可执行文件即命令和程序。这个目录包含了 macOS 系统和很多系统级工具的可执行文件比如 git、ls、curl 等。 使用Homebrew安装Git 为什么还要使用 Homebrew 安装一遍 Git后文有解释。 安装 执行命令brew install git 完整过程如下 larrylalarryladeMacBook-Air ~ % brew install gitDownloading https://mirrors.ustc.edu.cn/homebrew-bottles/api/formula.jws.jso ######################################################################### 100.0%Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/api/cask.jws.json ######################################################################### 100.0%Fetching dependencies for git: libunistring, gettext and pcre2Fetching libunistringDownloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/libunistrin ######################################################################### 100.0%Fetching gettextDownloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/gettext-0.2 ######################################################################### 100.0%Fetching pcre2Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/pcre2-10.44 ######################################################################### 100.0%Fetching gitDownloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/git-2.47.1. ######################################################################### 100.0%Installing dependencies for git: libunistring, gettext and pcre2Installing git dependency: libunistringPouring libunistring-1.3.arm64_sequoia.bottle.tar.gz/opt/homebrew/Cellar/libunistring/1.3: 59 files, 5.4MBInstalling git dependency: gettextPouring gettext-0.23.arm64_sequoia.bottle.tar.gz/opt/homebrew/Cellar/gettext/0.23: 2,052 files, 22.4MBInstalling git dependency: pcre2Pouring pcre2-10.44.arm64_sequoia.bottle.tar.gz/opt/homebrew/Cellar/pcre2/10.44: 237 files, 6.3MBInstalling gitPouring git-2.47.1.arm64_sequoia.bottle.tar.gzCaveats The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the git-gui formula. Subversion interoperability (git-svn) is now in the git-svn formula.zsh completions and functions have been installed to:/opt/homebrew/share/zsh/site-functionsSummary/opt/homebrew/Cellar/git/2.47.1: 1,685 files, 54.4MBRunning brew cleanup git… Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see man brew).Caveatsgit The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the git-gui formula. Subversion interoperability (git-svn) is now in the git-svn formula.zsh completions and functions have been installed to:/opt/homebrew/share/zsh/site-functions如下图所示安装成功版本是 2.47.1安装在了 /opt/homebrew/Cellar/git/2.47.1 目录下 配置环境变量 查看 Git 版本发现依旧是之前在安装 Command Line Developer Tools 时安装的版本 larrylalarryladeMacBook-Air ~ % git -v git version 2.39.5 (Apple Git-154)这是因为没有为 Homebrew 安装版本 2.47.1 配置环境变量。 笔者的 MacBook Air 用的是 zsh shell所以需要配置 .zshrc 文件文件中包括了之前已经配置的 Maven 和 JDK
JDK 和 Maven 配置
JAVA_HOME/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home M2_HOME/Users/larryla/softwares/developer/apache-maven-3.9.9 PATH\(JAVA_HOME/bin:\)M2_HOME/bin:\(PATH CLASSPATH\)JAVA_HOME/lib/tools.jar:\(JAVA_HOME/lib/dt.jar# Git 配置 GIT_HOME/opt/homebrew/Cellar/git/2.47.1 PATH\)GIT_HOME/bin:\(PATH# 导出环境变量 export JAVA_HOME export PATH export CLASSPATH export M2_HOME export GIT_HOME再次检查 Git 版本这次就是使用 Homebrew 安装的 Git 了 larrylalarryladeMacBook-Air ~ % git -v git version 2.47.1查看 Git 位置 larrylalarryladeMacBook-Air ~ % which git /opt/homebrew/Cellar/git/2.47.1/bin/gitHomebrew 安装 Git 的路径 苹果 M 系列芯片/opt/homebrew/Cellar/git/版本号Intel 芯片/usr/local/bin/git 3、为MacBook配置GitHub的SSH 1、验证笔记本是否已有 ssh keys larrylalarryladeMacBook-Air ~ % ls -al ~/.ssh ls: /Users/larryla/.ssh: No such file or directory可以看到本机器还没有。 2、生成 ssh keys 在 Terminal 执行如下命令 ssh-keygen -t rsa -b 4096 -C 1649063532qq.com引号内为 GitHub 账号关联的邮箱可以在 GitHub 上的 Settings - Emails 处查看 生成过程如下中间会提示你设置密码为了便利不用设置密码一路回车 larrylalarryladeMacBook-Air ~ % ssh-keygen -t rsa -b 4096 -C 1649063532qq.com Generating public/private rsa key pair. Enter file in which to save the key (/Users/larryla/.ssh/id_rsa): Created directory /Users/larryla/.ssh. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/larryla/.ssh/id_rsa Your public key has been saved in /Users/larryla/.ssh/id_rsa.pub The key fingerprint is: SHA256:h4hMW90V9Nv5..........7kG75JQKpmJ0 16......2qq.com The keys randomart image is: ---[RSA 4096]---- | ..o*| | . . .oo| | . . . .o o*| | o . .o *| | .So.o *.o| | o E. * o.o| | . o.| | . | | | ----[SHA256]-----3、将 SSH Key 添加到 ssh-agenteval \)(ssh-agent -s) larrylalarryladeMacBook-Air ~ % eval \((ssh-agent -s) Agent pid 93133 larrylalarryladeMacBook-Air ~ % ssh-add ~/.ssh/id_rsa Identity added: /Users/larryla/.ssh/id_rsa (1649063532qq.com)4、打开i d_rsa.pub 文件复制文件内容到 GitHub ls -al ~/.sshcat ~/.ssh/id_rsa.pub将从ssh-rsa开头一直到邮箱结束的字符串都复制上。 打开 GitHub找到 SSH and GPG keys 选择 New SSH key 取名粘贴 5、验证SSH连接是否建立成功。输出过程中可能会要求输入 yes 或 no输入 yes 后回车即可 larrylalarryladeMacBook-Air ~ % ssh -T gitgithub.com The authenticity of host github.com (20.2xx.xxx.xx6) cant be established. ED25519 key fingerprint is SHA256:DiY3wvv...........zPMSvHdkr4UvCOqU. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added github.com (ED25519) to the list of known hosts. Hi Acura-bit! Youve successfully authenticated, but GitHub does not provide shell access.4、IntelliJ IDEA配置全局Git 背景每次新建项目或打开项目都会使用默认的配置 .m2 的那个能不能一次性配置好答案是可以的。 如下图所示关闭所有项目 File - Close Project 后进入下面的界面找到左下角的设置按钮。 设置 Maven 的安装路径、settings.xml 文件路径、本地仓库路径 接下来把跟 Maven 相关的也设置好 现在配置 Git。找到 Version Control - Git 如下图所示配置好 Homebrew 安装的 Git 路径Test 一下成功。注意不要勾选框。 附 一、在安装 Command Line Developer Tools 时已经安装了 Git为啥还要用 Homebrew 安装 Git 呢 在 macOS 上安装 Command Line Developer Tools 时确实会自带 Git以及其他开发工具如 clang 和 make 等。但是有时你可能会希望使用 Homebrew 来重新安装或升级 Git原因主要有以下几点 1、版本更新 macOS 系统自带的 Git 版本可能不是最新的。虽然 Command Line Developer Tools 中的 Git 版本会随着 Xcode 或命令行工具的更新而更新但它可能没有最新的功能或修复。使用 Homebrew 安装 Git 可以更方便地安装最新版本的 Git并且可以通过 brew upgrade 命令轻松更新到最新版本。 2、不同的版本管理需求 使用 Homebrew 安装 Git 允许我们拥有一个与系统自带的 Git 版本隔离的版本。例如你可能需要某个特定版本的 Git例如 2.x 或更高版本而 macOS 自带的 Git 可能较旧或不符合你的需求。Homebrew 安装的 Git 不会干扰系统自带的 Git可以通过路径优先级来控制使用哪个版本。 3、独立管理 Homebrew 安装的 Git 可以完全由 Homebrew 来管理这意味着可以通过 Homebrew 安装、升级、卸载 Git所有操作都非常方便。我们不必依赖系统更新来获取 Git 的最新版本。如果使用的是系统自带的 Git/usr/bin/git它通常是由 macOS 管理的更新时不一定能够随时满足你的需求。而通过 Homebrew 安装 Git你可以完全控制版本。 4、 在某些情况下使用系统自带的 Git 可能会导致与其他工具或库的冲突。例如有时其他开发工具如某些 IDE 或脚本可能依赖于 Homebrew 安装的 Git 版本。如果你通过 Homebrew 安装 Git它的路径通常在 /opt/homebrew/bin/gitApple Silicon或 /usr/local/bin/gitIntel Mac中这些路径在 Homebrew 管理下与系统路径区分开来减少了冲突的可能性。 5、Homebrew 允许你通过简单的命令如 brew install git 和 brew upgrade git来管理 Git 的版本避免手动下载和安装。如果系统自带的 Git 版本出现问题使用 Homebrew 安装的 Git 可以更容易进行修复或替代。 简单来说就是Homebrew 可以方便的管理 Git如升级、卸载等。 二、环境变量命令 (1) echo eval \)(/opt/homebrew/bin/brew shellenv) ~/.zprofile 这个命令的作用是将 Homebrew 的环境变量配置添加到你的 ~/.zprofile 文件中。 /opt/homebrew/bin/brew这是 Homebrew 在 Apple Silicon MacM1 或 M2 芯片上的默认安装路径。对于 Intel 架构的 Mac路径通常是 /usr/local/bin/brew。brew shellenv这个命令会打印出需要设置的环境变量例如 PATH、HOMEBREW_PREFIX 等以确保 Homebrew 正常工作。eval \((/opt/homebrew/bin/brew shellenv)这条命令执行了 brew shellenv 输出的命令将它们加载到当前 shell 环境中。 ~/.zprofile 将这些设置追加到你的 ~/.zprofile 文件中确保在每次启动 shell 时这些环境变量都能够自动加载。~/.zprofile 文件通常会在使用 zsh 作为 shell 时加载。 (2) eval \)(/opt/homebrew/bin/brew shellenv) 这条命令会立即在当前的 shell 会话中执行 brew shellenv 输出的命令从而设置 Homebrew 所需的环境变量。这是一个临时的设置它只会影响当前终端会话直到你关闭终端窗口。 这两条命令的作用是什么 持久化设置第一条命令将 Homebrew 的环境变量设置添加到 ~/.zprofile 中这样每次启动新终端时Homebrew 的环境变量会自动加载。即时生效第二条命令立即在当前 shell 会话中设置环境变量确保你可以立刻使用 Homebrew。 三、.zprofile 和 .zshrc 有啥区别为啥把 JDK、Maven、Git 的环境变量配置在 .zshrc 文件中而把 Homebrew 环境变量配置在 .zprofile 文件中 .zprofile 和 .zshrc 都是 Zsh 配置文件用于设置 shell 环境中的变量和行为。它们之间有一些细微的区别主要体现在它们的加载时机和作用上。 .zprofile 作用这个文件主要用于设置登录 shelllogin shell的环境变量和配置。加载时机只会在登录 shell 启动时加载。用途通常用来配置系统范围的环境变量像是 PATH、HOMEBREW_PREFIX、MAVEN_HOME 等它们通常只需要在登录时设置一次。 .zshrc 作用这个文件用于设置交互式非登录 shell 的配置。它通常用于设置命令别名、自动补全、提示符、shell 功能等它是每次启动一个新的 shell 实例时都需要加载的。加载时机每次打开一个新的终端窗口即使是子 shell时都会加载不管是登录 shell 还是非登录 shell.zshrc 都会被加载。用途通常用来配置与 shell 环境互动相关的内容如别名、函数、命令补全等方便每次打开终端时都能自动生效。
为什么把 Maven 配置在 .zshrc 中而把 Homebrew 配置在 .zprofile 中 Maven 配置在 .zshrc 中 原因Maven 的配置通常包括设置环境变量如 MAVEN_HOME 和将 mvn 命令路径添加到 PATH 中。这些配置主要影响 shell 会话例如执行 Maven 命令时。.zshrc 是每次打开新 shell 时都会加载的因此将 Maven 配置在 .zshrc 中意味着每次启动一个新的终端窗口时都会设置好 Maven 的相关环境变量确保你能够在新的 shell 会话中直接使用 mvn 命令。 Homebrew 配置在 .zprofile 中 原因Homebrew 主要影响的是登录 shell例如你在终端登录时或者通过 SSH 登录时Homebrew 需要确保你能够正常使用 brew 命令。配置 Homebrew 的环境变量如 PATH通常只需要在登录时执行一次。.zprofile 只在登录时加载一次因此将 Homebrew 的环境变量例如通过 brew shellenv 配置的内容放入 .zprofile 中只会在登录时一次性配置好避免在每次打开终端时都重复设置。
简单来说就是Homebrew 只需要在登陆时设置一次而 Maven、Git 等需要在每个新打开的窗口都设置一次。 四、登录 shell vs 非登录 shell vs 交互式 shell 登录 shellLogin Shell 这是你首次打开终端时启动的 shell或者通过 SSH 登录时启动的 shell。登录 shell 会加载 .zprofile或在 Bash 中是 .bash_profile等文件。这个 shell 会在你登录时初始化环境并且加载登录 shell 特有的配置。 交互式 shellInteractive Shell 交互式 shell 是指可以与用户交互、等待用户输入命令的 shell比如你执行 ls、pwd 等命令的环境。交互式 shell 会加载 .zshrc或在 Bash 中是 .bashrc文件通常用于配置命令别名、补全等交互式功能。 非登录 shellNon-login Shell 非登录 shell 是在你已经有一个登录 shell 会话的情况下通过运行某些命令如 zsh 或 bash启动的新的 shell 会话。非登录 shell 会加载 .zshrc或 .bashrc但不会加载 .zprofile 或 .bash_profile。
终端启动时的 shell 既是登录 shell 也是交互式 shell当你打开一个新的终端窗口时这个 shell 是一个登录 shell因为它是用户登录后启动的并且是交互式 shell因为它等待用户输入命令。因此它会加载 .zprofile 和 .zshrc 两个文件。 参考 MacBook 安装 Homebrewhttps://zhuanlan.zhihu.com/p/90508170MacBook 安装 Homebrewhttps://blog.csdn.net/weixin_45277161/article/details/134719230?spm1001.2014.3001.5501MacBook 配置 GitHub SSHhttps://www.cnblogs.com/sinceForever/p/17954613MacBook 配置 GitHub SSHhttps://juejin.cn/post/6993506356279902244https://blog.csdn.net/weixin_45277161/article/details/134709441
- 上一篇: 网站怎么静态化建站交流
- 下一篇: 网站怎么可以做视频播放做网站视频存储
