From aaf7fd829da1c021698285d8322c609f71bd3255 Mon Sep 17 00:00:00 2001 From: emmett1 Date: Sat, 30 May 2026 23:57:36 +0800 Subject: improve rename mode --- sfm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sfm b/sfm index 061c68a..144a849 100755 --- a/sfm +++ b/sfm @@ -777,8 +777,10 @@ open_file() { # read a line of input in raw mode, returns result in READ_LINE # returns 1 if user pressed Esc (cancel), 0 on Enter read_line() { - READ_LINE="" + READ_LINE="${_init:-}" + _init="" show_cursor + printf '%s' "$READ_LINE" while true; do IFS= read -r -n1 _ch 2>/dev/null || IFS= read -r _ch case "$_ch" in @@ -1351,10 +1353,11 @@ do_delete() { do_rename() { entry=$(get_entry "$SEL") + _name="${entry%@}"; _name="${_name%/}" goto "$(term_rows)" 1 - printf '%s%s Rename "%s" to (esc=cancel): %s' "${ERASE_LINE}" "${YELLOW}${BOLD}" "$entry" "${RESET}" - if read_line && [ -n "$READ_LINE" ] && [ "$READ_LINE" != "$entry" ]; then - _name="${entry%@}"; _name="${_name%/}" + printf '%s%s Rename: %s' "${ERASE_LINE}" "${YELLOW}${BOLD}" "${RESET}" + _init="$_name" + if read_line && [ -n "$READ_LINE" ] && [ "$READ_LINE" != "$_name" ]; then mv "${CWD}/${_name}" "${CWD}/${READ_LINE}" load_entries else -- cgit v1.2.3