Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added New Plugin #1900

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
| [suedit](suedit) | Edit file using superuser permissions | sh | sudoedit/sudo/doas |
| [togglex](togglex) | Toggle executable mode for selection [✓] | sh | chmod |
| [umounttree](umounttree) | Unmount a remote mountpoint from within | sh | fusermount |
| [upl0ad](upl0ad) | Upload files to 0x0.st | sh | curl |
| [upload](upload) | Upload to Firefox Send or ix.io (text) or file.io (bin) | sh | [ffsend](https://github.com/timvisee/ffsend), curl, jq, tr |
| [wallpaper](wallpaper) | Set wallpaper or change colorscheme | sh | nitrogen/pywal |
| [x2sel](x2sel) | Copy file list from system clipboard to selection | sh | _see in-file docs_ |
Expand Down
34 changes: 34 additions & 0 deletions plugins/upl0ad
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env sh
#
# Description: Upload files to 0x0.st
#
# Dependencies: curl
# Shell: POSIX compliant
#
# Author: Zazucki
# based on "upload" plugin by Arun Prakash Jana

selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}

if [ -s "$selection" ]; then
xargs -0 -t -I {} < "$selection" curl -F"file=@{}" -Fsecret= https://0x0.st

# Clear selection
printf "-" > "$NNN_PIPE"
else
if [ -n "$1" ] && [ -s "$1" ]; then
# Upload not limited if text file
if [ "$(file --mime-type --brief "$1" | awk -F '/' '{print $1}')" = "text" ]; then
# Upload, show download link, wait for user to press Enter
curl -F"file=@$1" -Fsecret= https://0x0.st
else
# Upload limited to 1 week if NOT a text file
curl -F"file=@$1" -Fsecret= -Fexpires=168 https://0x0.st
# NOT NECESSARY - 0x0 has auto-limited file retention based on size
fi
else
printf "File is empty!"
fi
fi

read -r _