diff options
author | typebrook <typebrook@gmail.com> | 2020-01-31 10:06:38 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-01-31 10:06:38 +0800 |
commit | cdb35f3b6249444408f513a82adb0dd288b12bdb (patch) | |
tree | cadeaab3001a34ea56aa9b2b02e4bf1526d95396 /scripts/gist | |
parent | 8e3fe5d460304a302d9e52b85f83120342f83fd9 (diff) |
update
Diffstat (limited to 'scripts/gist')
-rwxr-xr-x | scripts/gist | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/gist b/scripts/gist index b797646..476936b 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -82,7 +82,7 @@ _config_cases() { | |||
82 | } | 82 | } |
83 | 83 | ||
84 | _configure() { | 84 | _configure() { |
85 | [[ -z "$@" ]] && (vim $config) && exit 0 | 85 | [[ -z "$@" ]] && (vim $config) && return 0 |
86 | target=$(_config_cases "$@") | 86 | target=$(_config_cases "$@") |
87 | 87 | ||
88 | touch $config | 88 | touch $config |
@@ -141,7 +141,7 @@ _show_list() { | |||
141 | if [[ ! -e "$1" ]]; then | 141 | if [[ ! -e "$1" ]]; then |
142 | echo 'No local file found for last update, please run command:' | 142 | echo 'No local file found for last update, please run command:' |
143 | echo " gist update" | 143 | echo " gist update" |
144 | exit 0 | 144 | return 0 |
145 | fi | 145 | fi |
146 | cat $1 \ | 146 | cat $1 \ |
147 | | while read line_num link file_url_array file_num extra description; do | 147 | | while read line_num link file_url_array file_num extra description; do |
@@ -232,10 +232,10 @@ _gist_id() { | |||
232 | GIST_ID=$( (grep -hs '' $index $starred || true) | sed -n "/^$1 / p" | cut -d' ' -f2 | sed -E 's#.*/##') | 232 | GIST_ID=$( (grep -hs '' $index $starred || true) | sed -n "/^$1 / p" | cut -d' ' -f2 | sed -E 's#.*/##') |
233 | if [[ -z "$GIST_ID" ]]; then | 233 | if [[ -z "$GIST_ID" ]]; then |
234 | echo -e "Not a valid index: \e[31m$1\e[0m" | 234 | echo -e "Not a valid index: \e[31m$1\e[0m" |
235 | echo Use the index number in the first column instead: | 235 | echo Use the index in the first column instead: |
236 | echo | 236 | echo |
237 | _show_list "$index" | 237 | _show_list "$index" |
238 | exit 1 | 238 | return 1 |
239 | fi | 239 | fi |
240 | } | 240 | } |
241 | 241 | ||
@@ -322,7 +322,7 @@ _set_gist() { | |||
322 | done | 322 | done |
323 | if [[ "$1" == '--' ]]; then shift; fi | 323 | if [[ "$1" == '--' ]]; then shift; fi |
324 | files="$@" | 324 | files="$@" |
325 | ls $files > /dev/null || exit 1 | 325 | ls $files > /dev/null || return 1 |
326 | } | 326 | } |
327 | 327 | ||
328 | _new_file() { | 328 | _new_file() { |
@@ -339,7 +339,7 @@ _new_file() { | |||
339 | # TODO support secret gist | 339 | # TODO support secret gist |
340 | # FIXME catch status code from curl if it fails | 340 | # FIXME catch status code from curl if it fails |
341 | _create_gist() { | 341 | _create_gist() { |
342 | _set_gist "$@" | 342 | _set_gist "$@" || return 1 |
343 | [[ -z "$files" ]] && files=$(_new_file $filename) | 343 | [[ -z "$files" ]] && files=$(_new_file $filename) |
344 | [[ -z "$description" ]] && read -p 'Type description: ' description < /dev/tty | 344 | [[ -z "$description" ]] && read -p 'Type description: ' description < /dev/tty |
345 | 345 | ||