aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-01-22 17:17:10 +0800
committertypebrook <typebrook@gmail.com>2020-01-22 17:17:10 +0800
commitcf074c00e1a7c5b5176986be5043a9b72a61f1c2 (patch)
tree2853dc682da3e1aa02ef7ec282c8789518373e24 /scripts
parente90f4db75ba47b87d84f510a50e37dcbae23540d (diff)
update
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gist7
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/gist b/scripts/gist
index 1fbceb2..853ab99 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -48,6 +48,7 @@
48# * show this help message 48# * show this help message
49# gist (help | h) 49# gist (help | h)
50 50
51# TODO add config to help message
51# TODO error handling, unit test 52# TODO error handling, unit test
52# TODO parallel branch works with json parsing on python 53# TODO parallel branch works with json parsing on python
53# TODO parallel branch works with wget and other stuff 54# TODO parallel branch works with wget and other stuff
@@ -227,7 +228,7 @@ _set_gist() {
227 228
228_new_file() { 229_new_file() {
229 [[ -t 0 ]] && echo "Type a gist. <Ctrl-C> to cancel, <Ctrl-D> when done" > /dev/tty 230 [[ -t 0 ]] && echo "Type a gist. <Ctrl-C> to cancel, <Ctrl-D> when done" > /dev/tty
230 local tmp_file=$(mktemp) 231 tmp_file=$(mktemp)
231 cat > $tmp_file 232 cat > $tmp_file
232 echo -e '\n' > /dev/tty 233 echo -e '\n' > /dev/tty
233 # FIXME when file content is from STDIN, read fails 234 # FIXME when file content is from STDIN, read fails
@@ -245,7 +246,7 @@ _create_gist() {
245 [[ -z "$description" ]] && echo -n 'Type description: ' && read description 246 [[ -z "$description" ]] && echo -n 'Type description: ' && read description
246 247
247 for file in $files; do 248 for file in $files; do
248 local FILE=$(basename $file) 249 FILE=$(basename $file)
249 jq --arg FILE "$FILE" '. as $content | { ($FILE): {content: $content} }' -Rs $file 250 jq --arg FILE "$FILE" '. as $content | { ($FILE): {content: $content} }' -Rs $file
250 done \ 251 done \
251 | jq --slurp --arg DESC "$description" '{ 252 | jq --slurp --arg DESC "$description" '{
@@ -293,7 +294,7 @@ _cases() {
293 294
294_configure() { 295_configure() {
295 [[ -z "$@" ]] && (vim $config) && exit 0 296 [[ -z "$@" ]] && (vim $config) && exit 0
296 local target=$(_cases "$@") 297 target=$(_cases "$@")
297 298
298 [[ "$target" =~ [^=]$ ]] && sed -i "/^$1=/ d" $config && echo $target >> $config 299 [[ "$target" =~ [^=]$ ]] && sed -i "/^$1=/ d" $config && echo $target >> $config
299 cat $config 300 cat $config