• 首页

  • 写作

  • 文章归档

  • 照片

  • 友情链接

  • 旅行

  • 读书

  • 日志

  • 随记

  • 人文历史

  • linux

  • 前端
b l o g
b l o g

admin

lzp

01月
01
mac

Mac 开发环境配置

发表于 2025-01-01 • 字数统计 3566 • 被 4 人看爆

Mac 开发环境配置 #docker #colima

  • 安装命令行开发者工具,在终端中 输入 git,触发命令行工具的安装,有魔法网络会快一些,如果没有,安装 xcode 似乎也可以,然后就有了 git,如果版本低了,就再安装 brew ,然后 升级 git
  • Install Homebrew, Mac 包管理工具,类似 Linux apt
    https://github.com/Homebrew/install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

注意:

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/lzw/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
  • 安装新版本 git
brew install git
  • 配置 git github ssh 公钥
rm -rf ~/.ssh/*
git config --global user.email "example@email.com"
git config --global user.name "userName"
git config --global --list

eval "$(ssh-agent -s)"
ssh-keygen -t rsa -b 4096 -C "example@email.com"
// 添加公钥到当前ssh-agent
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub
// 然后到GitHub粘贴公钥,然后测试
ssh -T git@github.com

注意: example@email.com 替换为邮箱 userName 替换为用户名

  • 安装 oh-my-zsh 工具:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • zsh更换字体:bira candy crcandy dogenpunk dst emotty
    选 crcandy
ZSH_THEME="crcandy"

进入 zsh 插件目录:

qy@QY [18:55:58] [~] 
-> % echo $ZSH_CUSTOM
/Users/qy/.oh-my-zsh/custom

qy@QY [19:09:14] [~] 
-> % cd /Users/qy/.oh-my-zsh/custom/plugins

进入 zsh 插件目录后,下载 插件 zsh-autosuggestion自动补全 和 zsh-syntax-highlighting语法高亮

git clone https://github.com/zsh-users/zsh-autosuggestions.git
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
  • 配置 zsh 插件
vim ~/.zshrc
plugins=(
    git
    z
    dotenv
    zsh-syntax-highlighting
    zsh-autosuggestions
)

git 是 oh-my-zsh 内置的插件
z 是 oh-my-zsh 内置的 目录跳转插件,详情:https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/z
dotenv oh-my-zsh 内置的环境变量插件,当你进入一个目录时,如果该目录中包含 .env , 那么会提示你是否加载该插件

dotenv 项目地址
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dotenv

  • Mac 安装docker docker-compose
brew install docker docker-compose
==> docker-compose
Compose is a Docker plugin. For Docker to find the plugin, add "cliPluginsExtraDirs" to ~/.docker/config.json:
  "cliPluginsExtraDirs": [
      "/opt/homebrew/lib/docker/cli-plugins"
  ]
vim ~/.docker/config.json

写入:

"cliPluginsExtraDirs": [
    "/opt/homebrew/lib/docker/cli-plugins"
]
  • Mac 安装 colima 为 docker 提供 Linux 虚拟机,或者说提供一套运行时
brew install colima
==> colima
zsh completions have been installed to:
  /opt/homebrew/share/zsh/site-functions

To start colima now and restart at login:
  brew services start colima
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/colima/bin/colima start -f

启动 colima :

colima start

Docker Pull 拉去镜像的简便方法

假如拉取原始镜像命令如下
docker pull whyour/qinglong:latest

仅需在原命令前缀加入加速镜像地址 例如:
docker pull dockerpull.com/whyour/qinglong:latest
  • colima 配置文件,修改镜像地址,加速大陆的访问速度:
    https://github.com/abiosoft/colima/issues/225
colima start --edit
docker:
  insecure-registries:
    - dockerpull.com
  registry-mirrors:
    - https://dockerpull.com
  • docker 测试:
qy@QY [18:55:48] [~] 
-> % docker run hello-world:latest 

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
  • 安装 vscode ,并把 code 映射为对应的路径
    cat .zshrc
alias code="/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"
分享到:
手写 Promise
js 中类与对象的一些重要概念
  • 文章目录
  • 站点概览
admin

! lzp

hello

Github Twitter QQ Email Telegram RSS
看爆 Top5
  • 历史与人文 视频链接 189次看爆
  • 2022日志随笔 175次看爆
  • 我的青海湖骑行 164次看爆
  • 读书随笔 124次看爆
  • rs2 设置教程 97次看爆

站点已萌萌哒运行 00 天 00 小时 00 分 00 秒(●'◡'●)ノ♥

Copyright © 2025 admin

由 Halo 强力驱动 · Theme by Sagiri · 站点地图