diff options
author | typebrook <typebrook@gmail.com> | 2020-03-17 16:50:43 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-03-17 17:56:13 +0800 |
commit | d86d25e22dd265cbe29ffdaf01e3c1d09bd79386 (patch) | |
tree | f92e3063a4c3aea0778b37303ad1630cea57c587 | |
parent | 6018e546ab3d283a71d21479f2e73cfd334bd158 (diff) |
Improve 'gist edit'
- Prefill with original description
- Fix pattern when editing is finished
-rwxr-xr-x | gist | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -593,9 +593,9 @@ _create_gist() { | |||
593 | _edit_gist() { | 593 | _edit_gist() { |
594 | _gist_id "$1" || return 1 | 594 | _gist_id "$1" || return 1 |
595 | 595 | ||
596 | local prefill=$(sed -ne "/^$1 / p" $INDEX | cut -d' ' -f9-) | ||
596 | if [[ -z $2 ]]; then | 597 | if [[ -z $2 ]]; then |
597 | echo 'Type new description:' | 598 | read -e -p 'Edit description: ' -i "$prefill" -r DESC < /dev/tty |
598 | read -e -r DESC < /dev/tty | ||
599 | else | 599 | else |
600 | DESC="$2" | 600 | DESC="$2" |
601 | fi | 601 | fi |
@@ -606,7 +606,7 @@ _edit_gist() { | |||
606 | | sed -e '1 s/^/[/; $ s/$/]/' \ | 606 | | sed -e '1 s/^/[/; $ s/$/]/' \ |
607 | | _parse_response "$1" ) | 607 | | _parse_response "$1" ) |
608 | [[ -n $new_record ]] && sed -i'' -E -e "/^$1 / s^.+^$new_record^" $INDEX \ | 608 | [[ -n $new_record ]] && sed -i'' -E -e "/^$1 / s^.+^$new_record^" $INDEX \ |
609 | && hint=false _show_list | grep -E "^[ ]+$1" \ | 609 | && hint=false mark="$1 " _show_list \ |
610 | || echo 'Fail to modify gist description' | 610 | || echo 'Fail to modify gist description' |
611 | } | 611 | } |
612 | 612 | ||