常用Terminal脚本

使用jq解析sfdx cli output

安装参考:https://command-not-found.com/jq
示例:

#!/bin/bash

# get started -> bash scripts/shell/limits-check.sh

# ref: https://www.baeldung.com/linux/jq-command-json
# ref: https://stedolan.github.io/jq/manual/

# sfdx force:limits:api:display

queryAPILimits() {
    echo "start to query the api exeeded the daily limits..."
    local result=$(sfdx force:limits:api:display --json | jq -r '.result[] | select(.remaining == 0 and .max != 0) | .name, .max')
    echo "API -> Max"
    printf "%s -> %d\n" $result
}

# list the api exeeded the daily limits
queryAPILimits

使用history查看历史shell记录

# all shell history
history
# filter git related shell command
history | grep git
# filter gpg related shell command
history | grep gpg
# the same as git log -> count commit times by author
git log | grep yan.xu

效果预览:
在这里插入图片描述

创建txt文件

echo "使用苹果自带的录屏软件,快捷键:cmd + shift + 5" > readme.txt

使用cat在terminal中显示文件内容

cat <file_path>
# i.e check readme file
cat README.md

效果预览:
在这里插入图片描述

使用pwd查看当前文件路径

pwd

效果预览:
在这里插入图片描述

使用treer查看目录结构

# 全局安装
npm install -g treer
# 忽略某些文件或文件夹
treer -i "node_modules"
# 保存目录结构到文件
treer -e "test.txt"
# 示例: 将文件目录结构排除node_modules后,保存到tree.md
treer -e "tree.md" -i "node_modules"

使用Terminal打开VS Code

# to open the entire folder/directory
code .
# to open a specific file
# 语法
code <file_name>
code index.html
# create an empty SFDX project in your local machine
sfdx force:project:create --projectname Hi-CircleCI
# cd into the newly created project folder
cd Hi-CircleCI
# create a folder named “manifest”
mkdir manifest
# type the following command to open the project in VS Code
code .

如果无法使用code .打开文件夹,参考以下步骤:在这里插入图片描述

复制并移动文件

# 语法
cp <source> <destination>
# 示例
cp server.key ~/Documents/VS\ Code/CircleCI/Hi-CircleCI/buildfiles

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值