blob: f43cde14dc1b3e96fcd99c11948e03c1877c35eb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/usr/bin/env sh
# Description: Provides drag and drop window for files.
#
# Files that are dropped will be added to nnn's selection
# Some web based files will be downloaded to current directory with curl
# and it may overwrite some existing files
#
# The user has to press mm to clear nnn's selection first
#
# Dependency: https://github.com/mwh/dragon
# Shell: POSIX compliant
# Author: 0xACE
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
dnd()
{
if which dragon-drag-and-drop; then
dragon-drag-and-drop "$@"
else
dragon "$@"
fi
}
function add_file() {
echo -n "$@" >> "$selection"
echo -ne "\0" >> "$selection"
}
echo -n > "$selection"
# which dnd
# upstream calls it dragon
dnd --print-path --target | while read f
do
if echo -n "$f" | grep '^\(https\?\|ftps\?\|s\?ftp\):\/\/' ; then
curl -LJO "$f"
add_file "$PWD/$(basename "$f")"
elif [ -e "$f" ]; then
add_file "$f"
fi
done &
|