nnn

mirror of https://github.com/jarun/nnn
Log | Files | Refs | README | LICENSE

commit f9b956af9d9844195299fc0bba14a478e5fa8bf8
parent ec3ed2f61eba0e84585990c7686fdc516395fd86
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date:   Fri,  8 Aug 2025 22:44:36 +0530

Merge pull request #2052 from beast989898/feature/ux-improvements-dragdrop

feat: Improve UX for dragdrop plugin
Diffstat:
Mplugins/dragdrop | 32+++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/plugins/dragdrop b/plugins/dragdrop @@ -14,6 +14,9 @@ # Shell: POSIX compliant # Author: 0xACE +# If you want system notification, put this equal to 1 +notify=0 + selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} resp=f all= @@ -54,24 +57,35 @@ fi if [ "$resp" = "s" ]; then use_all - sed -z 's|'"$PWD/"'||g' < "$selection" | xargs -0 "$dnd" "$all" & + sed -z 's|'"$PWD/"'||g' < "$selection" | xargs -0 "$dnd" "$all" 2>/dev/null & elif [ "$resp" = "d" ]; then use_all - "$dnd" "$all" "$PWD/"* & + "$dnd" "$all" "$PWD/"* 2>/dev/null & elif [ "$resp" = "r" ]; then true > "$selection" - "$dnd" --print-path --target | while read -r f + "$dnd" --print-path --target 2>/dev/null | while read -r f do - if printf "%s" "$f" | grep '^\(https\?\|ftps\?\|s\?ftp\):\/\/' ; then - curl -LJO "$f" - add_file "$PWD/$(basename "$f")" - elif [ -e "$f" ]; then - add_file "$f" + if printf "%s" "$f" | grep -q '^\(https\?\|ftps\?\|s\?ftp\)://' ; then + if output=$(curl -fsLJOS "$f" 2>&1); then + filename="$(basename "${f%%\?*}")" + add_file "$PWD/$filename" + if [ $notify = 1 ]; then + notify-send "Download Complete" "Finished downloading $filename" + fi + else + if [ $notify = 1 ]; then + notify-send "Download Failed" "$output" + else + echo "Download Failed: $output" + fi fi + elif [ -e "$f" ]; then + add_file "$f" + fi done & else if [ -n "$1" ] && [ -e "$1" ]; then - "$dnd" "$1" & + "$dnd" "$1" 2>/dev/null & fi fi