diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/gist | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/scripts/gist b/scripts/gist index 7d61e71..5c62a18 100755 --- a/scripts/gist +++ b/scripts/gist | |||
| @@ -165,11 +165,11 @@ _show_list() { | |||
| 165 | echo ' gist update' | 165 | echo ' gist update' |
| 166 | return 0 | 166 | return 0 |
| 167 | fi | 167 | fi |
| 168 | local filter='/^s/ d; /^$/ d' | 168 | local filter='/^ *s/ d; /^$/ d' |
| 169 | [[ $1 == "s" ]] && filter='/^[^s]/ d; /^$/ d' | 169 | [[ $1 == "s" ]] && filter='/^ *[^ s]/ d; /^$/ d' |
| 170 | 170 | ||
| 171 | while read index link blob_code file_num extra author description; do | 171 | while read index link blob_code file_num extra author description; do |
| 172 | [[ $1 == "s" ]] && local author=$author | 172 | [[ $1 == "s" ]] && local name=$author |
| 173 | local repo=$folder/$(echo $link | sed 's#.*/##') | 173 | local repo=$folder/$(echo $link | sed 's#.*/##') |
| 174 | local occupy=0 | 174 | local occupy=0 |
| 175 | 175 | ||
| @@ -180,10 +180,10 @@ _show_list() { | |||
| 180 | # if there is a commit not yet push, show red message "ahead" | 180 | # if there is a commit not yet push, show red message "ahead" |
| 181 | [[ -n $(cd $repo && git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" && occupy=7 | 181 | [[ -n $(cd $repo && git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" && occupy=7 |
| 182 | 182 | ||
| 183 | echo -e $index $link $author $file_num $extra $(echo $description | cut -c -$(( 60 -$occupy -1 )) ) | 183 | echo -e "$(printf "% 3s" $index) $link $name $file_num $extra $(echo $description | cut -c -$(( 60 -$occupy -1 )) )" |
| 184 | done < $INDEX \ | 184 | done < $INDEX \ |
| 185 | | sed "$filter" | 185 | | sed "$filter" |
| 186 | echo -e '\nrun "gist help" for more details' | 186 | echo -e '\nrun "gist help" for more details' > /dev/null |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | # parse JSON from STDIN with string of commands | 189 | # parse JSON from STDIN with string of commands |
| @@ -437,8 +437,10 @@ _edit_gist() { | |||
| 437 | 437 | ||
| 438 | echo -n 'Type new description: ' | 438 | echo -n 'Type new description: ' |
| 439 | read DESC < /dev/tty | 439 | read DESC < /dev/tty |
| 440 | echo "{ \"description\": \"$DESC\" }" \ | 440 | |
| 441 | | http_method PATCH $GITHUB_API/gists/$GIST_ID > /dev/null \ | 441 | http_data=$(mktemp) |
| 442 | echo "{ \"description\": \"$DESC\" }" > $http_data | ||
| 443 | http_method PATCH $http_data $GITHUB_API/gists/$GIST_ID > /dev/null \ | ||
| 442 | && _update | 444 | && _update |
| 443 | } | 445 | } |
| 444 | 446 | ||