improve rename mode
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user