diff options
Diffstat (limited to 'scripts/gist')
-rwxr-xr-x | scripts/gist | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/scripts/gist b/scripts/gist index 55a021f..a4033e1 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -391,9 +391,7 @@ _goto_gist() { | |||
391 | 391 | ||
392 | if [[ ! -d $folder/$GIST_ID ]]; then | 392 | if [[ ! -d $folder/$GIST_ID ]]; then |
393 | echo 'Cloning gist as repo...' | 393 | echo 'Cloning gist as repo...' |
394 | git clone "git@github.com:$GIST_ID".git "$folder/$GIST_ID" | 394 | if git clone "git@github.com:$GIST_ID".git "$folder/$GIST_ID"; then |
395 | |||
396 | if $?; then | ||
397 | echo 'Repo is cloned' > /dev/tty | 395 | echo 'Repo is cloned' > /dev/tty |
398 | else | 396 | else |
399 | echo 'Failed to clone the gist' > /dev/tty | 397 | echo 'Failed to clone the gist' > /dev/tty |
@@ -467,6 +465,7 @@ _show_detail() { | |||
467 | 465 | ||
468 | # set filename/description/permission for a new gist | 466 | # set filename/description/permission for a new gist |
469 | _set_gist() { | 467 | _set_gist() { |
468 | files=() | ||
470 | public=True | 469 | public=True |
471 | while [[ -n "$*" ]]; do case $1 in | 470 | while [[ -n "$*" ]]; do case $1 in |
472 | -d | --desc) | 471 | -d | --desc) |
@@ -479,12 +478,11 @@ _set_gist() { | |||
479 | public=False | 478 | public=False |
480 | shift;; | 479 | shift;; |
481 | *) | 480 | *) |
482 | files="$1 $files" | 481 | files+=($1) |
483 | shift;; | 482 | shift;; |
484 | esac | 483 | esac |
485 | done | 484 | done |
486 | # FIXME user array instead | 485 | ls "${files[@]}" > /dev/null || return 1 |
487 | ls $files > /dev/null || return 1 | ||
488 | } | 486 | } |
489 | 487 | ||
490 | # Let user type the content of gist before setting filename | 488 | # Let user type the content of gist before setting filename |
@@ -514,13 +512,13 @@ print(json.dumps({'public': $public, 'files': files_json, 'description': descrip | |||
514 | # create a new gist with files | 512 | # create a new gist with files |
515 | _create_gist() { | 513 | _create_gist() { |
516 | _set_gist "$@" || return 1 | 514 | _set_gist "$@" || return 1 |
517 | [[ -z $files ]] && files=$(_new_file "$filename") | 515 | [[ -z $files ]] && files=(_new_file "$filename") |
518 | [[ -z $description ]] && read -r -p 'Type description: ' description < /dev/tty | 516 | [[ -z $description ]] && read -r -p 'Type description: ' description < /dev/tty |
519 | 517 | ||
520 | echo 'Creating a new gist...' | 518 | echo 'Creating a new gist...' |
521 | http_data=$(mktemp) | 519 | http_data=$(mktemp) |
522 | 520 | ||
523 | echo -e "$files\n$description" \ | 521 | echo -e "${files[*]}\n$description" \ |
524 | | _gist_body > "$http_data" \ | 522 | | _gist_body > "$http_data" \ |
525 | && http_method POST $GITHUB_API/gists \ | 523 | && http_method POST $GITHUB_API/gists \ |
526 | | sed -e '1 s/^/[/; $ s/$/]/' \ | 524 | | sed -e '1 s/^/[/; $ s/$/]/' \ |
@@ -529,7 +527,7 @@ _create_gist() { | |||
529 | | cut -d' ' -f2 | sed -E -e 's#.*/##' \ | 527 | | cut -d' ' -f2 | sed -E -e 's#.*/##' \ |
530 | | (xargs -I{} git clone git@github.com:{}.git $folder/{} &> /dev/null &) | 528 | | (xargs -I{} git clone git@github.com:{}.git $folder/{} &> /dev/null &) |
531 | 529 | ||
532 | if $?; then | 530 | if [[ $? -eq 0 ]]; then |
533 | echo 'Gist is created' | 531 | echo 'Gist is created' |
534 | hint=false _show_list | tail -1 | 532 | hint=false _show_list | tail -1 |
535 | else | 533 | else |