From 8b36cca8eab49a79164adb5c615cd6870fdb5652 Mon Sep 17 00:00:00 2001 From: John Jian Date: Fri, 18 Oct 2024 10:16:09 +0800 Subject: [PATCH] Replace markdown "shell" with "console" --- README.md | 8 +++--- _drafts/2018-06-24-install-ruby-with-rbenv.md | 14 +++++----- ...19-install-express-nginx-docker-compose.md | 12 ++++---- _drafts/2020-03-18-terraform.md | 4 +-- _drafts/2020-11-20-kubernetes.md | 28 +++++++++---------- _drafts/2021-02-24-helm.md | 2 +- _drafts/2023-07-31-rust.md | 4 +-- _posts/2018-06-24-git.md | 24 ++++++++-------- _posts/2018-07-19-docker.md | 6 ++-- _posts/2020-03-09-install-iterm2-oh-my-zsh.md | 8 +++--- ...20-05-05-terraform-deploy-static-to-cos.md | 10 +++---- _posts/2021-02-26-anaconda.md | 14 +++++----- 12 files changed, 67 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 1e7d2d4..d1e47fe 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## 安装 Ruby -```shell +```console $ rbenv install 3.3.3 $ rbenv global 3.3.3 $ rbenv versions @@ -10,7 +10,7 @@ $ rbenv versions ## 安装第三方库 -```shell +```console $ gem update --system $ gem install bundler $ bundle update @@ -18,14 +18,14 @@ $ bundle update ## 启动 -```shell +```console $ jekyll serve # $ bundle exec jekyll serve ``` ## 生成语法高亮样式 -```shell +```console $ rougify help style $ rougify style github > assets/css/highlight-github.css ``` diff --git a/_drafts/2018-06-24-install-ruby-with-rbenv.md b/_drafts/2018-06-24-install-ruby-with-rbenv.md index 275e964..9396771 100644 --- a/_drafts/2018-06-24-install-ruby-with-rbenv.md +++ b/_drafts/2018-06-24-install-ruby-with-rbenv.md @@ -13,14 +13,14 @@ color: "#fff" 先安装依赖包 -```shell +```console $ sudo apt-get update $ sudo apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev ``` 接着安装 rbenv,如果是 macos,推荐使用 Homebrew 安装。 -```shell +```console $ brew install rbenv $ echo 'export PATH="$PATH:$HOME/.rbenv/bin"' >> ~/.zshrc $ echo 'eval "$(rbenv init -)"' >> ~/.zshrc @@ -31,26 +31,26 @@ $ source ~/.zshrc Restart your shell so that PATH changes take effect. Verify that rbenv is properly set up using this rbenv-doctor script 重新打开 Shell,使 PATH 生效。用 `type rbenv` 或者下面语句来检验 rbenv 是否已经设置好了。 -```shell +```console $ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash ``` ### Install ruby-build as an rbenv plugin(安装插件 ruby-build) -```shell +```console $ mkdir -p "$(rbenv root)"/plugins $ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build ``` ### Install Ruby -```shell +```console $ rbenv install --verbose 2.7.2 ``` 如果无法直接在线安装,可以[安装下载好的 Ruby 文件](https://stackoverflow.com/questions/35589469/install-ruby-using-rbenvs-downloaded-file/35589999#35589999)。 -```shell +```console $ mkdir ~/.rbenv/cache $ cp ~/Downloads/ruby-2.7.2.tar.bz2 ~/.rbenv/cache/ $ env RUBY_BUILD_MIRROR_URL=file:///home/$(whoami)/.rbenv/cache/ruby-2.7.2.tar.bz2 @@ -58,7 +58,7 @@ $ env RUBY_BUILD_MIRROR_URL=file:///home/$(whoami)/.rbenv/cache/ruby-2.7.2.tar.b ### Set default Ruby(设置默认的 Ruby 版本) -```shell +```console $ rbenv global 2.7.2 $ rbenv versions ``` diff --git a/_drafts/2018-07-19-install-express-nginx-docker-compose.md b/_drafts/2018-07-19-install-express-nginx-docker-compose.md index d42bdef..54a6a1e 100644 --- a/_drafts/2018-07-19-install-express-nginx-docker-compose.md +++ b/_drafts/2018-07-19-install-express-nginx-docker-compose.md @@ -12,13 +12,13 @@ Compose is a tool for defining and running multi-container Docker applications. Run this command to download the latest version of Docker Compose: -```shell +```console $ sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose ``` Apply executable permissions to the binary: -```shell +```console $ sudo chmod +x /usr/local/bin/docker-compose ``` @@ -55,7 +55,7 @@ mongodb: 创建 VOLUMES 目录 -```shell +```console $ mkdir -p /home/vagrant/nginx/conf.d $ mkdir -p /home/vagrant/mongodb ``` @@ -79,7 +79,7 @@ server { 运行 docker-compose -```shell +```console $ docker-compose -f compose-nginx-nodejs-mongodb.yml up ``` @@ -87,7 +87,7 @@ $ docker-compose -f compose-nginx-nodejs-mongodb.yml up ## 常用命令 -```shell +```console $ docker volume ls $ docker volume prune $ docker volume inspect delivery_storage @@ -107,7 +107,7 @@ $ docker-compose exec fpm php artisan route:cache 您需要使用注册表名称和要将其推送到的存储库来标记您的映像。 例如,要将名为 my-image 的映像推送到 Docker Hub 注册表,您可以使用以下命令: -```shell +```console $ docker tag my-image:latest docker.io/my-username/my-image:latest $ docker push docker.io/my-username/my-image:latest ``` diff --git a/_drafts/2020-03-18-terraform.md b/_drafts/2020-03-18-terraform.md index 86566cd..6c7973c 100644 --- a/_drafts/2020-03-18-terraform.md +++ b/_drafts/2020-03-18-terraform.md @@ -16,13 +16,13 @@ HashiCorp 维护着广泛的官方提供商列表,并且还可以与社区开 首先,安装 HashiCorp Tap,它是我们所有 Homebrew 软件包的存储库。 -```shell +```console $ brew tap hashicorp/tap ``` 现在,使用 hashcorp/tap/terraform 安装 Terraform。 -```shell +```console $ brew install hashicorp/tap/terraform ``` diff --git a/_drafts/2020-11-20-kubernetes.md b/_drafts/2020-11-20-kubernetes.md index 511f395..b01f32b 100644 --- a/_drafts/2020-11-20-kubernetes.md +++ b/_drafts/2020-11-20-kubernetes.md @@ -7,21 +7,21 @@ Kubernetes 常用命令 ## Deployment(部署) -```shell +```console $ kubectl get deployments # List deployments(查看列表 deployments) $ kubectl get pods -o wide # let’s check if the number of Pods changed (查看列表 Pods) ``` ## Scale(扩展) -```shell +```console $ kubectl get rs # Show replicas $ kubectl scale deployments/kubernetes-bootcamp --replicas=4 # Scale up $ kubectl scale deployments/kubernetes-bootcamp --replicas=2 # Scale down $ kubectl describe deployments/kubernetes-bootcamp # The change was registered in the Deployment events log. ``` -```shell +```console {% raw %}$ export NODE_PORT="$(kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}')"{% endraw %} $ echo "NODE_PORT=$NODE_PORT" $ curl http://"$(minikube ip):$NODE_PORT" @@ -34,19 +34,19 @@ $ curl http://"$(minikube ip):$NODE_PORT" 回滚更新 让我们执行另一次更新,并尝试部署带有 v10 标记的映像: -```shell +```console $ kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=gcr.io/google-samples/kubernetes-bootcamp:v10 ``` 使用 get deployments 查看部署的状态: -```shell +```console $ kubectl get deployments ``` 请注意,输出并未列出所需的可用 Pod 数量。 运行 get pods 子命令以列出所有 Pod: -```shell +```console $ kubectl get pods ``` @@ -54,7 +54,7 @@ $ kubectl get pods 要更深入地了解问题,请运行 describe pods 子命令: -```shell +```console $ kubectl describe pods ``` @@ -62,7 +62,7 @@ $ kubectl describe pods 要将部署回滚到上一个工作版本,请使用 rollout undo 子命令: -```shell +```console $ kubectl rollout undo deployments/kubernetes-bootcamp ``` @@ -70,13 +70,13 @@ rollout undo 命令将部署恢复到之前的已知状态(映像的 v2)。 使用 get pods 子命令再次列出 Pod: -```shell +```console $ kubectl get pods ``` 四个 Pod 正在运行。 要检查部署在这些 Pod 上的映像,请使用describe pods 子命令: -```shell +```console $ kubectl describe pods ``` @@ -84,20 +84,20 @@ $ kubectl describe pods 请记住清理本地集群 -```shell +```console $ kubectl delete deployments/kubernetes-bootcamp services/kubernetes-bootcamp ``` ## 获取配置上下文,切换环境 -```shell +```console $ kubectl config --kubeconfig=$HOME/.kube/config get-contexts # 列出上下文环境 $ kubectl config --kubeconfig=$HOME/.kube/config use-context minikube # 使用上下文环境 ``` 比如,要切换到腾讯云 TKE -```shell +```console $ export KUBECONFIG=$KUBECONFIG:$HOME/cls-7ta42ut4-config # 先添加新的上下文环境 $ kubectl config --kubeconfig=$HOME/cls-7ta42ut4-config get-contexts @@ -108,7 +108,7 @@ $ kubectl config --kubeconfig=$HOME/cls-7ta42ut4-config use-context cls-7ta42ut4 Switched to context "cls-7ta42ut4-100000777545-context-default". ``` -```shell +```console $ kubectl get pods --field-selector=status.phase=Failed $ kubectl delete pods --field-selector=status.phase=Failed # 批量删除 ``` diff --git a/_drafts/2021-02-24-helm.md b/_drafts/2021-02-24-helm.md index d60f0c8..586abb0 100644 --- a/_drafts/2021-02-24-helm.md +++ b/_drafts/2021-02-24-helm.md @@ -21,6 +21,6 @@ Helm 是 Kubernetes 的包管理器,Kubernetes 是一个开源容器编排平 ## 安装 -```shell +```console $ brew install helm ``` diff --git a/_drafts/2023-07-31-rust.md b/_drafts/2023-07-31-rust.md index cedd45e..3d0224e 100644 --- a/_drafts/2023-07-31-rust.md +++ b/_drafts/2023-07-31-rust.md @@ -22,7 +22,7 @@ Often, cargo check is much faster than cargo build because it skips the step of 让我们回顾一下我们到目前为止对 Cargo 的了解: -```shell +```console $ cargo new # 创建一个项目。 $ cargo build # 构建一个项目。 $ cargo run # 一步构建和运行一个项目。 @@ -56,4 +56,4 @@ $ cargo build 直接使用 rustc 编写和运行“Hello, world!”程序 使用 Cargo 的约定创建和运行新项目 -这是构建更实质性的程序以习惯于阅读和编写 Rust 代码的好时机。因此,在第 2 章中,我们将构建一个猜谜游戏程序。如果您更愿意先了解 Rust 中常见的编程概念,请参阅第 3 章,然后再返回第 2 章。 \ No newline at end of file +这是构建更实质性的程序以习惯于阅读和编写 Rust 代码的好时机。因此,在第 2 章中,我们将构建一个猜谜游戏程序。如果您更愿意先了解 Rust 中常见的编程概念,请参阅第 3 章,然后再返回第 2 章。 diff --git a/_posts/2018-06-24-git.md b/_posts/2018-06-24-git.md index 9d375b6..5f37ea6 100644 --- a/_posts/2018-06-24-git.md +++ b/_posts/2018-06-24-git.md @@ -12,7 +12,7 @@ Git 是一个免费的开源分布式版本控制系统,旨在快速高效地 在 macOS 上推荐使用 [Homebrew]({% post_url 2020-03-09-install-iterm2-oh-my-zsh %}) 安装 Git。 -```shell +```console $ brew install git ``` @@ -25,13 +25,13 @@ $ brew install git 生成秘钥: -```shell +```console $ ssh-keygen -t rsa -b 4096 -C "your.name@gmail.com" ``` 复制生成的公钥,加入到 GitHub 上:Settings > Access > SSH and GPG keys -```shell +```console $ clip < ~/.ssh/id_rsa.pub # 在 Windows 上复制到剪切板 $ clipcopy ~/.ssh/id_rsa.pub # zsh ``` @@ -42,7 +42,7 @@ $ clipcopy ~/.ssh/id_rsa.pub # zsh 在本地电脑上,设置提交人的身份信息 -```shell +```console $ git config --global user.name "Your Name" $ git config --global user.email "your.name@gmail.com" ``` @@ -59,19 +59,19 @@ $ git config --global user.email "your.name@gmail.com" 然后拉取仓库到本地电脑 -```shell +```console $ git pull git@github.com:john/myapp.git ``` 接着设置远程的 origin 仓库地址 -```shell +```console $ git remote set-url origin git@github.com:john/myapp.git ``` 再从公共分支合并到自己的主分支,同样要设置远程的 upstream 仓库地址 -```shell +```console $ git remote add upstream git@github.com:nighon/myapp.git ``` @@ -79,7 +79,7 @@ $ git remote add upstream git@github.com:nighon/myapp.git 开发过程中,需要拉取并合并 nighon/master => john/master(本地) -```shell +```console $ git fetch upstream $ git checkout master $ git merge upstream/master @@ -87,7 +87,7 @@ $ git merge upstream/master 每次需要添加功能时,通常会新建一个分支。从 master 新建分支 -```shell +```console $ git checkout -b my-awesome-feature master # 或者是为修复问题而新建分支 (fix issue) @@ -105,7 +105,7 @@ $ git checkout -b fix-something-wrong master **每次开发完成功能分支后,把功能分支合并到主分支的步骤:** -```shell +```console # This moves your feature branch commits on top of the latest commits from main, # resulting in a linear and clean history. # 这会将您的功能分支提交移至主分支的最新提交之上,从而产生线性且干净的历史记录。 @@ -136,7 +136,7 @@ $ git push origin --delete feature-branch 以 `HEAD~` 为示范 commit id
以 `README.md` 为示范文件名 -```shell +```console $ git checkout HEAD~ -- README.md # 恢复文件 $ git clean -fd # 清除未包含的文件 $ git push origin +HEAD~:master # 强制推送(覆盖)远程分支 @@ -153,7 +153,7 @@ $ git commit -m "Your commit message" --no-verify # 跳过语法检查的钩 branch,tag 操作 -```shell +```console $ git tag rc-1 # 新建 tag, -a 'create release candidate 1' $ git push origin --all # 推送所有 branches $ git push origin --tags # 推送所有 tags diff --git a/_posts/2018-07-19-docker.md b/_posts/2018-07-19-docker.md index e3b6318..a2b69da 100644 --- a/_posts/2018-07-19-docker.md +++ b/_posts/2018-07-19-docker.md @@ -10,7 +10,7 @@ Docker 是一种工具,用于自动在轻量级容器中部署应用程序, 首先,[在 macOS 上安装 Docker Desktop](https://docs.docker.com/desktop/install/mac-install/#install-and-run-docker-desktop-on-mac)。 -```shell +```console $ brew install --cask docker # 安装 Docker Desktop $ brew install docker-compose # 安装 Docker Compose ``` @@ -28,7 +28,7 @@ Compose 适用于所有环境;生产、准备、开发、测试以及 CI 工 - 流式传输正在运行的服务的日志输出 - 在服务上运行一次性命令 -```shell +```console $ docker compose build app $ docker compose up -d $ docker compose down @@ -45,7 +45,7 @@ $ docker compose down ## 常用命令 -```shell +```console $ docker volume ls $ docker volume prune $ docker volume inspect delivery_storage diff --git a/_posts/2020-03-09-install-iterm2-oh-my-zsh.md b/_posts/2020-03-09-install-iterm2-oh-my-zsh.md index 0b5e90c..8399f85 100644 --- a/_posts/2020-03-09-install-iterm2-oh-my-zsh.md +++ b/_posts/2020-03-09-install-iterm2-oh-my-zsh.md @@ -11,7 +11,7 @@ bgcolor: "#cfc" Homebrew 是一个免费的开源软件包管理系统,可简化 macOS 上的软件安装。 -```shell +```console $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` @@ -19,7 +19,7 @@ $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/ iTerm2 是一款适用于 macOS 的免费开源终端模拟器,用来替代系统默认的 Terminal。 -```shell +```console $ brew install --cask iterm2 ``` @@ -28,7 +28,7 @@ $ brew install --cask iterm2 Zsh 是一种专为交互式使用而设计的 shell,同时它也是一种功能强大的脚本语言。
Oh My Zsh 是一个用于管理 Zsh 配置的开源框架。 -```shell +```console $ brew install zsh && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ``` @@ -36,7 +36,7 @@ $ brew install zsh && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmy ## 设置色彩和样式 -```shell +```console $ cd Downloads && curl -O https://raw.githubusercontent.com/MartinSeeler/iterm2-material-design/master/material-design-colors.itermcolors ``` diff --git a/_posts/2020-05-05-terraform-deploy-static-to-cos.md b/_posts/2020-05-05-terraform-deploy-static-to-cos.md index 4ee1df8..2186acf 100644 --- a/_posts/2020-05-05-terraform-deploy-static-to-cos.md +++ b/_posts/2020-05-05-terraform-deploy-static-to-cos.md @@ -23,13 +23,13 @@ HashiCorp 维护着广泛的官方提供商列表,并且还可以与社区开 首先,安装 HashiCorp Tap,它是我们所有 Homebrew 软件包的存储库。 -```shell +```console $ brew tap hashicorp/tap ``` 现在,使用 hashcorp/tap/terraform 安装 Terraform。 -```shell +```console $ brew install hashicorp/tap/terraform ``` @@ -52,7 +52,7 @@ availability_region = "ap-singapore" availability_zone = "ap-singapore-4" ``` -```shell +```console $ echo 'terraform.tfvars' >> .gitignore # 在版本库中忽略该文件 ``` @@ -204,7 +204,7 @@ resource "tencentcloud_cos_bucket_object" "example" { 创建 404.html 文件,提供更友好的 404 页面: -```shell +```console $ echo '404Page not found.' > 404.html ``` @@ -274,7 +274,7 @@ resource "tencentcloud_dnspod_record" "example" { ## 运行 Terraform -```shell +```console $ terraform init $ terraform plan $ terraform apply --auto-approve diff --git a/_posts/2021-02-26-anaconda.md b/_posts/2021-02-26-anaconda.md index 33795aa..be2f69d 100644 --- a/_posts/2021-02-26-anaconda.md +++ b/_posts/2021-02-26-anaconda.md @@ -13,20 +13,20 @@ Anaconda 因其易用性、全面的软件包选择以及有效管理依赖关 采用 [PyTorch 文档提供的命令行安装方法](https://pytorch.org/get-started/locally/#anaconda): -```shell +```console $ curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh $ sh Miniconda3-latest-MacOSX-arm64.sh ``` 或者用 Homebrew 安装。安装后,如果在 zsh 环境下报错 `conda not found`,先[运行初始化](https://gist.github.com/ryanorsinger/7d89ad58901b5590ec3e1f23d7b9f887?permalink_comment_id=3806602#gistcomment-3806602)。 -```shell +```console $ brew install --cask anaconda ``` ## 更新 -```shell +```console $ conda update --all $ conda update -n myenv conda $ conda update -n myenv --all @@ -34,7 +34,7 @@ $ conda update -n myenv --all ## 卸载 -```shell +```console $ rm -rf ~/miniconda3/ # 删除目录 $ rm -rf ~/.conda* # 删除配置文件 $ vim ~/.zshrc # 删除相关配置 @@ -42,7 +42,7 @@ $ vim ~/.zshrc # 删除相关配置 ## 管理环境 -```shell +```console $ conda create -n myenv python # 创建环境 -n, --name $ conda create -n myenv python=3.11 # 创建环境,并指定 Python 版本 $ conda create -n myenv --clone base # 复制 base 环境 @@ -52,7 +52,7 @@ $ conda create -n myenv --clone base # 复制 base 环境 创建环境后,所有的库都会安装到该环境目录下,包括 Python 和 Pip -```shell +```console $ conda create -n jupyter python $ conda activate jupyter $ (jupyter) which python # /Users/john/miniconda3/envs/web/bin/python @@ -63,6 +63,6 @@ $ (jupyter) which jupyterlab # /Users/john/miniconda3/envs/web/bin/jupyterlab ## 删除环境 -```shell +```console $ conda remove -n jupyter --all ```