aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-05-13 23:01:51 +0800
committertypebrook <typebrook@gmail.com>2020-05-13 23:01:51 +0800
commit34c13cad32b5c61302587794a6b22364356fbc5e (patch)
tree8989a82037f115f2ab87d3b543fcf956345d79f5
parentd88a5e550f89aa49604473cf8820c434f9da3e17 (diff)
Change hint and helper message by script name
-rwxr-xr-xgist10
1 files changed, 6 insertions, 4 deletions
diff --git a/gist b/gist
index 11c79bf..108c785 100755
--- a/gist
+++ b/gist
@@ -57,6 +57,7 @@
57currentVersion="1.23.0" 57currentVersion="1.23.0"
58configuredClient="" 58configuredClient=""
59 59
60NAME=$(basename $0)
60GITHUB_API=https://api.github.com 61GITHUB_API=https://api.github.com
61CONFIG=~/.config/gist.conf; mkdir -p ~/.config 62CONFIG=~/.config/gist.conf; mkdir -p ~/.config
62 63
@@ -328,7 +329,7 @@ _index_pattern() {
328# If display=tag, print tags instead or url 329# If display=tag, print tags instead or url
329_show_list() { 330_show_list() {
330 if [[ ! -s $INDEX ]]; then 331 if [[ ! -s $INDEX ]]; then
331 echo 'Index file is empty, please run commands "gist fetch" or "gist create"' 332 echo "Index file is empty, please run commands "$NAME fetch" or "$NAME create""
332 return 0 333 return 0
333 fi 334 fi
334 335
@@ -365,7 +366,7 @@ _show_list() {
365 local mtime="$(mtime $INDEX | cut -d'.' -f1)" 366 local mtime="$(mtime $INDEX | cut -d'.' -f1)"
366 echo > /dev/tty 367 echo > /dev/tty
367 echo "Last updated at $mtime" > /dev/tty 368 echo "Last updated at $mtime" > /dev/tty
368 echo 'Run "gist fetch" to keep gists up to date, or "gist help" for more details' > /dev/tty 369 echo "Run \"$NAME fetch\" to keep gists up to date, or \"$NAME help\" for more details" > /dev/tty
369 fi 370 fi
370} 371}
371 372
@@ -749,7 +750,8 @@ _edit_gist() {
749 750
750# Print helper message 751# Print helper message
751usage() { 752usage() {
752 sed -E -n -e '/^#/ !q; 1,/^# --/ d; s/^# //p' "$0" 753 sed -E -n -e '/^#/ !q; 1,/^# --/ d; s/^# //p' "$0" \
754 | sed -Ee "s/^( ?|Usage: )gist/\1$NAME/"
753} 755}
754 756
755# Check remote urls of all repos match current protocol in configuration file 757# Check remote urls of all repos match current protocol in configuration file
@@ -803,7 +805,7 @@ _show_tags() {
803 805
804 echo 806 echo
805 if [[ ${#pinned_tags} == 0 ]]; then 807 if [[ ${#pinned_tags} == 0 ]]; then
806 echo 'Run "gist pin <tag1> <tag2>..." to pin/unpin tags' 808 echo "Run \"$NAME pin <tag1> <tag2>...\" to pin/unpin tags"
807 else 809 else
808 echo Pinned tags: "${pinned_tags[@]/#/#}" 810 echo Pinned tags: "${pinned_tags[@]/#/#}"
809 fi 811 fi