diff options
| author | emmett1 <me@emmett1.my> | 2026-05-30 23:57:36 +0800 |
|---|---|---|
| committer | emmett1 <me@emmett1.my> | 2026-05-30 23:57:36 +0800 |
| commit | aaf7fd829da1c021698285d8322c609f71bd3255 (patch) | |
| tree | 2d7e8546dd735a25dbb5f61c0f71314875913a87 | |
| parent | 8db9a070b7e63da034a0925788c8550d58000950 (diff) | |
| download | sfm-aaf7fd829da1c021698285d8322c609f71bd3255.tar.gz sfm-aaf7fd829da1c021698285d8322c609f71bd3255.zip | |
improve rename mode
| -rwxr-xr-x | sfm | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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 |