From d86d25e22dd265cbe29ffdaf01e3c1d09bd79386 Mon Sep 17 00:00:00 2001 From: typebrook Date: Tue, 17 Mar 2020 16:50:43 +0800 Subject: Improve 'gist edit' - Prefill with original description - Fix pattern when editing is finished --- gist | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gist b/gist index dbf4c45..d5b4f41 100755 --- a/gist +++ b/gist @@ -593,9 +593,9 @@ _create_gist() { _edit_gist() { _gist_id "$1" || return 1 + local prefill=$(sed -ne "/^$1 / p" $INDEX | cut -d' ' -f9-) if [[ -z $2 ]]; then - echo 'Type new description:' - read -e -r DESC < /dev/tty + read -e -p 'Edit description: ' -i "$prefill" -r DESC < /dev/tty else DESC="$2" fi @@ -606,7 +606,7 @@ _edit_gist() { | sed -e '1 s/^/[/; $ s/$/]/' \ | _parse_response "$1" ) [[ -n $new_record ]] && sed -i'' -E -e "/^$1 / s^.+^$new_record^" $INDEX \ - && hint=false _show_list | grep -E "^[ ]+$1" \ + && hint=false mark="$1 " _show_list \ || echo 'Fail to modify gist description' } -- cgit v1.2.3-70-g09d2