From fd8a8387b8a21216ae379f6a8c448c82fd52fd28 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Thu, 12 Dec 2019 19:51:08 +0530 Subject: Add option to show noti and copy selection to system clipboard --- plugins/.cbcp | 45 +++++++++++++++++++++++++++++++++++++++++++++ plugins/.notify | 20 -------------------- plugins/.ntfy | 20 ++++++++++++++++++++ 3 files changed, 65 insertions(+), 20 deletions(-) create mode 100755 plugins/.cbcp delete mode 100755 plugins/.notify create mode 100755 plugins/.ntfy (limited to 'plugins') diff --git a/plugins/.cbcp b/plugins/.cbcp new file mode 100755 index 0000000..022e88a --- /dev/null +++ b/plugins/.cbcp @@ -0,0 +1,45 @@ +#!/usr/bin/env sh + +# Description: Copy selection to system clipboard as newline-separated entries +# Requires: tr and +# xclip/xsel (Linux) +# pbcopy (macOS) +# termux-clipboard-set (Termux) +# clip.exe (WSL) +# clip (Cygwin) +# wl-copy (Wayland) +# +# LIMITATION: breaks if a filename has newline in it +# +# Note: For a space-separated list: +# xargs -0 < "$SELECTION" +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n + +SELECTION=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection + +if which xsel >/dev/null 2>&1; then + # Linux + tr '\0' '\n' < "$SELECTION" | xsel -bi +elif which xclip >/dev/null 2>&1; then + # Linux + tr '\0' '\n' < "$SELECTION" | xclip -sel clip +elif which pbcopy >/dev/null 2>&1; then + # macOS + tr '\0' '\n' < "$SELECTION" | pbcopy +elif which termux-clipboard-set >/dev/null 2>&1; then + # Termux + tr '\0' '\n' < "$SELECTION" | termux-clipboard-set +elif which clip.exe >/dev/null 2>&1; then + # WSL + tr '\0' '\n' < "$SELECTION" | clip.exe +elif which clip >/dev/null 2>&1; then + # Cygwin + tr '\0' '\n' < "$SELECTION" | clip +elif which wl-copy >/dev/null 2>&1; then + # Wayland + tr '\0' '\n' < "$SELECTION" | wl-copy +fi diff --git a/plugins/.notify b/plugins/.notify deleted file mode 100755 index fe0e18a..0000000 --- a/plugins/.notify +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env sh - -# Description: Show a notification -# -# Details: nnn invokes this plugin to show notification when a cp/mv/rm operation is complete. -# -# Requires: notify-send (Ubuntu)/ntfy (https://github.com/dschep/ntfy)/osascript (macOS) -# -# Shell: POSIX compliant -# Author: Anna Arad - -OS="$(uname)" - -if which notify-send >/dev/null 2>&1; then - notify-send nnn "Done!" -elif [ "$OS" = "Darwin" ]; then - osascript -e 'display notification "Done!" with title "nnn"' -elif which ntfy >/dev/null 2>&1; then - ntfy -t nnn send "Done!" -fi diff --git a/plugins/.ntfy b/plugins/.ntfy new file mode 100755 index 0000000..fe0e18a --- /dev/null +++ b/plugins/.ntfy @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +# Description: Show a notification +# +# Details: nnn invokes this plugin to show notification when a cp/mv/rm operation is complete. +# +# Requires: notify-send (Ubuntu)/ntfy (https://github.com/dschep/ntfy)/osascript (macOS) +# +# Shell: POSIX compliant +# Author: Anna Arad + +OS="$(uname)" + +if which notify-send >/dev/null 2>&1; then + notify-send nnn "Done!" +elif [ "$OS" = "Darwin" ]; then + osascript -e 'display notification "Done!" with title "nnn"' +elif which ntfy >/dev/null 2>&1; then + ntfy -t nnn send "Done!" +fi -- cgit v1.2.3-70-g09d2