bash-scripts
Create or update bash scripts following the conventions of the existing scripts in `~/git/linux/scripts/bin/`.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create or update bash scripts following the conventions of the existing scripts in `~/git/linux/scripts/bin/`.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
| name | bash-scripts |
| description | Create or update bash scripts following the conventions of the existing scripts in `~/git/linux/scripts/bin/`. |
| license | MIT |
Create bash scripts following the conventions of the existing scripts in ~/git/linux/scripts/bin/.
When the user mentions a script by name as a reference (e.g. "based on my script foo", "following script bar", "like script baz"), always locate and read that script first before writing anything:
which <script> to locate it via ${PATH} — this is the primary lookup since scripts are installed as executables in ${PATH}which, fall back to searching in ~/git/linux/scripts/bin/ (and subdirectories)Only fall back to the generic template below if the script is not found by either method.
|), stdin, and stdout.sh extension (they are executables in $PATH)input_file, dry_run, start_date)ARM_SUBSCRIPTION_ID, KUBECONFIG)"${variable}" — not $variable#!/bin/bash
arg1="${1}"
arg2="${2}"
# logic here
Shebang: use
#!/bin/bashfor portability.#!/usr/bin/env bashis also acceptable when bash portability across non-standard PATH environments is needed (e.g. macOS, cross-platform scripts).
foo as the canonical template)#!/bin/bash
this_script_path="$(realpath ${0})"
this_script_name="${this_script_path##*/}"
this_script_directory="${this_script_path%/*}"
PATH="${this_script_directory}:${PATH}"
show_usage() {
cat <<EOF
<One-line description of what the script does>
Options:
-h, --help Show this help
-n, --name <description> (default: <value>)
-dr, --dry-run Dry Run (default: false)
Examples:
${this_script_name} --name bar file
${this_script_name} file
${this_script_name} < file
sort file | ${this_script_name}
EOF
}
while [[ "${1}" =~ ^- && ! "${1}" == "--" ]]; do
case $1 in
-h | --help )
show_usage
exit 1
;;
-n | --name )
shift
name="${1}"
;;
-dr | --dry-run )
if [[ -n "${2}" && "${2}" =~ ^(true|false)$ ]]; then
dry_run="${2}"
shift
else
dry_run=true
fi
;;
- )
input_file="/dev/stdin"
;;
* )
echo "Invalid option: ${1}"
show_usage
exit 1
;;
esac
shift
done
if [[ "${1}" == '--' ]]; then shift; fi
# Positional args after options
if [[ -z "${input_file}" ]]; then
input_file="${1:-/dev/stdin}"
fi
# Defaults for optional flags
dry_run="${dry_run:-false}"
name="${name:-bar}"
# Script logic here
Always support reading from a file argument OR stdin:
input_file="${1:-/dev/stdin}"
while read -r line; do
echo "${line}"
done < "${input_file}"
Use ${var?} to fail fast with a clear error when a required variable is unset:
url="${1}"
openssl s_client -connect ${url?}:443 ...
Boolean flags, only in cases when the script will make changes, accept an optional true/false value, defaulting to true when the flag is present alone:
-dr | --dry-run )
if [[ -n "${2}" && "${2}" =~ ^(true|false)$ ]]; then
dry_run="${2}"
shift
else
dry_run=true
fi
;;
Add the script's own directory to $PATH so sibling scripts are callable by name:
this_script_directory="${this_script_path%/*}"
PATH="${this_script_directory}:${PATH}"
set -eUse set -e when the script has sequential steps that must all succeed:
#!/bin/bash
set -e
Skip it for scripts that handle errors explicitly or use pipelines.
Never print full secret values. Show only a prefix for confirmation:
echo "ARM_CLIENT_SECRET: ${ARM_CLIENT_SECRET:0:3}"
Always use long-form option names when available — --yes instead of -y, --verbose instead of -v, --output instead of -o. This applies to both scripts written here and CLI commands used as examples or references. Short forms (-y, -v) are only acceptable inside show_usage to document the short alias.
do/then on the same line as while/ifcase closing ;; aligned with the option pattern\ and 2-space indent per continuationEOFif/while blocksRead HANDOFF.md and continue from where we left off
Use when ending a session, completing a milestone, or stopping mid-task and context must be preserved for the next agent
Use when organizing raw content into slide-ready format, or when the user says "prepare slides", "structure this for a presentation", "brief for pptx".
Use when the user shares a URL or article and asks to extract key learnings, summarize topics, or generate a digest formatted for Google Chat, Slack, Discord, Telegram, or similar messaging tools. Accepts an optional format parameter.
Use when working with Kubernetes clusters, manifests, and related tasks.
Use when writing a CV, bio, LinkedIn post, or talk abstract for Silvio; when calibrating technical recommendations to Silvio's experience ("do I have experience with X?"); or when an introduction or speaker section is needed. Loads timeline, stack, credentials, and preferences on demand via the pointer table.