diff options
author | joe <rbo@gmx.us> | 2025-09-15 16:17:25 +0200 |
---|---|---|
committer | joe <rbo@gmx.us> | 2025-09-15 16:17:25 +0200 |
commit | 5d87eb6e9eebf6cf36062ed047611fc487deb3c0 (patch) | |
tree | 8e51667d7ae389ee18ac10cdd5e89a75e79da0f2 /.config | |
parent | up (diff) | |
download | dotfiles-bsd-5d87eb6e9eebf6cf36062ed047611fc487deb3c0.tar.gz dotfiles-bsd-5d87eb6e9eebf6cf36062ed047611fc487deb3c0.tar.bz2 dotfiles-bsd-5d87eb6e9eebf6cf36062ed047611fc487deb3c0.tar.xz dotfiles-bsd-5d87eb6e9eebf6cf36062ed047611fc487deb3c0.tar.zst dotfiles-bsd-5d87eb6e9eebf6cf36062ed047611fc487deb3c0.zip |
Diffstat (limited to '.config')
-rw-r--r-- | .config/env | 2 | ||||
-rwxr-xr-x | .config/nnn/plugins/joe_dragdrop | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/.config/env b/.config/env index aafc3fc..83b78ac 100644 --- a/.config/env +++ b/.config/env @@ -110,7 +110,7 @@ export NNN_BATSTYLE='plain' export NNN_PREVIEWIMGPROG='icat' export NNN_PREVIEWVIDEO='tct' export NNN_ICONLOOKUP=0 -export NNN_PLUG='t:joe_fzfcd;p:-preview-tui;s:-!gdu -s;f:-fzopen;c:-joe_clipper' +export NNN_PLUG='t:joe_fzfcd;p:-preview-tui;s:-!gdu -s;f:-fzopen;c:-joe_clipper;d:-joe_dragdrop' export RUSTFLAGS='-L /usr/local/lib' export WWW_HOME='https://start.duckduckgo.com/' export YTFZF_HIST='0' diff --git a/.config/nnn/plugins/joe_dragdrop b/.config/nnn/plugins/joe_dragdrop new file mode 100755 index 0000000..2623c47 --- /dev/null +++ b/.config/nnn/plugins/joe_dragdrop @@ -0,0 +1,47 @@ +#!/usr/bin/env sh + +# Description: Open a Drag and drop window, to drop files onto other programs. +# Also provides drag and drop window for files. +# +# Dependencies: dragon - https://github.com/mwh/dragon +# +# Notes: +# 1. Files that are dropped will be added to nnn's selection +# Some web-based files will be downloaded to current dir +# with curl and it may overwrite some existing files +# 2. The user has to mm to clear nnn's selection first +# +# Shell: POSIX compliant +# Author: 0xACE + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +resp=f +all= +if type dragon-drag-and-drop >/dev/null 2>&1; then + dnd="dragon-drag-and-drop" +elif type dragon-drop >/dev/null 2>&1; then + dnd="dragon-drop" +else + dnd="dragon" +fi + +add_file () +{ + printf '%s\0' "$@" >> "$selection" +} + +if [ -s "$selection" ]; then + printf "Drag selection (s) or drag current file (f) [default=f]: " + read -r resp +else + resp=f +fi + +if [ "$resp" = "s" ]; then + all="--all" + sed -z 's|'"$PWD/"'||g' < "$selection" | xargs -0 "$dnd" --and-exit "$all" & +else + if [ -n "$1" ] && [ -e "$1" ]; then + "$dnd" --and-exit "$1" & + fi +fi |