mirror of
https://github.com/jarun/nnn.git
synced 2024-11-20 09:59:14 +00:00
3eb0a38c5e
* Added 2 plugins for drag and drop support These scripts uses https://github.com/mwh/dragon and curl. It allows nnn to drag and drop files either to other programs, or to itself. * added link to dependency and spelling * added drag/drop-file scripts to readme table
41 lines
850 B
Bash
Executable file
41 lines
850 B
Bash
Executable file
#!/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()
|
|
{
|
|
dragon "$@"
|
|
}
|
|
|
|
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 &
|