From 7064bf2f83f8377f0df49f43e6d6344686c34c7d Mon Sep 17 00:00:00 2001 From: typebrook Date: Sat, 18 Jan 2020 12:11:40 +0800 Subject: update --- scripts/gist | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 39816a5..6038282 100755 --- a/scripts/gist +++ b/scripts/gist @@ -179,14 +179,22 @@ _show_detail() { jq '.[] | {user: .user.login, created_at: .created_at, updated_at: .updated_at, body: .body}' } +_new_file() { + tmp_file=$(mktemp) + [[ -t 0 ]] && echo "Type a gist. to cancel, when done" + cat > $tmp_file + echo $tmp_file +} + # create a new gist with files # FIXME consider file not exist -> let user type? return 1? _create_gist() { + files="$@" + [[ -z "$files" ]] && _new_file | read files + echo files: $files echo -n 'description: ' read DESC - - echo $@ | tr " " "\n" |\ - while read file; do + for file in $files; do FILE=$(basename $file) jq --arg FILE "$FILE" '. as $content | { ($FILE): {content: $content} }' -Rs $file done |\ -- cgit v1.2.3-70-g09d2