0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ChatGPT への口頭試問(シェルスクリプトからヘルプメッセージを生成)

Last updated at Posted at 2025-05-05

こんにちは。
シェルスクリプトを基にして、使用方法説明(ヘルプメッセージ)を作るよう ChatGPT へ依頼し、概ね良好な回答を得ました。

ChatGPT への質問

文字色を指定する次のシェルスクリプトを基にして、ヘルプメッセージを作ってください。

#!/bin/sh

text_style_f() {
  ESC=$(printf '\e')
  printf "${ESC}[%dm" "$1"
}

text_color_f() {
  style="$(text_style_f $1)"
  NORMALFACE="$(text_style_f 0)"
  printf "$style%d$NORMALFACE" "$1"
}

for i in $(seq 30 37); do text_color_f "$i "; done; echo
for i in $(seq 90 97); do text_color_f "$i "; done; echo

ChatGPT からの回答

了解しました!

Usage:
  $PROGNAME [options]
Description:
  This script displays ANSI color codes for foreground text colors in the terminal.
  It prints numbers 30–37 (standard foreground colors) and 90–97 (bright foreground colors),
  each rendered in its corresponding color using ANSI escape sequences.
  The output helps users visualize and choose appropriate ANSI color codes
  for customizing terminal prompts, scripts, or UI elements.
Options:
  -h|--help    Print this usage and exit.
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?