diff options
| author | 2019-12-12 19:51:08 +0530 | |
|---|---|---|
| committer | 2019-12-12 19:51:08 +0530 | |
| commit | fd8a8387b8a21216ae379f6a8c448c82fd52fd28 (patch) | |
| tree | 915ce95e9ed0842fe7a86dfe160e0052826dbc65 /plugins | |
| parent | f95ee54870e2259e9384c6f5641cb6d374526a65 (diff) | |
| download | nnn-fd8a8387b8a21216ae379f6a8c448c82fd52fd28.tar.gz | |
Add option to show noti and copy selection to system clipboard
Diffstat (limited to 'plugins')
| -rwxr-xr-x | plugins/.cbcp | 45 | ||||
| -rwxr-xr-x | plugins/.ntfy (renamed from plugins/.notify) | 0 |
2 files changed, 45 insertions, 0 deletions
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/.ntfy index fe0e18a..fe0e18a 100755 --- a/plugins/.notify +++ b/plugins/.ntfy |