aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-05-14 16:58:53 +0800
committertypebrook <typebrook@gmail.com>2020-05-14 17:01:18 +0800
commit8124b6fd049d1b7fa19113fd0b117827ef6a00d8 (patch)
tree4731dc33234029aa68261db14e354ccce3e054d5
parentb4135ce0875e5cd5bfbb60897f73adefa57ee081 (diff)
Refactor code
-rwxr-xr-xgist11
1 files changed, 4 insertions, 7 deletions
diff --git a/gist b/gist
index fc06889..8471f00 100755
--- a/gist
+++ b/gist
@@ -274,9 +274,9 @@ _validate_config() {
274_apply_config() { 274_apply_config() {
275 _validate_config "$@" || return 1 275 _validate_config "$@" || return 1
276 276
277 [[ -z $folder || ! -w $(dirname "$folder") ]] && folder=~/gist 277 [[ -z $folder || ! -w $(dirname "$folder") ]] && folder=~/gist; mkdir -p $folder
278 mkdir -p $folder
279 INDEX=$folder/index; [[ -e $INDEX ]] || touch $INDEX 278 INDEX=$folder/index; [[ -e $INDEX ]] || touch $INDEX
279 getConfiguredClient
280} 280}
281 281
282# extract trailing hashtags from description 282# extract trailing hashtags from description
@@ -621,8 +621,7 @@ _show_detail() {
621 echo -e created_at: $created_at 621 echo -e created_at: $created_at
622 echo -e updated_at: $updated_at 622 echo -e updated_at: $updated_at
623 echo -e files: 623 echo -e files:
624 echo $file_array | tr ',' '\n' | tr '@' ' ' \ 624 tr ',' '\n' <<<${file_array//@/ } | column -t | sed -e 's/^/ /'
625 | column -t | sed -e 's/^/ /'
626 done 625 done
627} 626}
628 627
@@ -752,8 +751,7 @@ _edit_gist() {
752 751
753# Print helper message 752# Print helper message
754usage() { 753usage() {
755 sed -E -n -e '/^#/ !q; 1,/^# --/ d; s/^# //p' "$0" \ 754 sed -Ene "/^#/ !q; 1,/^# --/ d; s/^# //p; s/^( *|Usage: )gist/\1$NAME/" "$0"
756 | sed -Ee "s/^( *|Usage: )gist/\1$NAME/"
757} 755}
758 756
759# 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
@@ -855,7 +853,6 @@ _access_last_index() {
855} 853}
856 854
857_apply_config "$@" || exit 1 855_apply_config "$@" || exit 1
858getConfiguredClient || exit 1
859if [[ $init ]]; then _fetch_gists; exit 0; fi 856if [[ $init ]]; then _fetch_gists; exit 0; fi
860case "$1" in 857case "$1" in
861 "") 858 "")