diff options
| author | yuzu-eva <stevenhu@web.de> | 2022-08-22 22:48:02 +0200 |
|---|---|---|
| committer | yuzu-eva <stevenhu@web.de> | 2022-08-22 22:48:02 +0200 |
| commit | b2abf7439ed3c8097bccd3f71f3f5410552ac7fe (patch) | |
| tree | b650fd81505e6d015e490cebf0aa9b4f0dba68c5 /.config/nnn/plugins/.cbcp | |
| parent | 599e1315ce9be32944681ff4e88fc5afa8ae81b8 (diff) | |
switch from powerline to starship, added mpd & ncmpcpp configs. also using nnn now
Diffstat (limited to '.config/nnn/plugins/.cbcp')
| -rwxr-xr-x | .config/nnn/plugins/.cbcp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/.config/nnn/plugins/.cbcp b/.config/nnn/plugins/.cbcp new file mode 100755 index 0000000..70f9b75 --- /dev/null +++ b/.config/nnn/plugins/.cbcp @@ -0,0 +1,51 @@ +#!/usr/bin/env sh + +# Description: Copy selection to system clipboard as newline-separated entries +# Dependencies: +# - tr +# - xclip/xsel (Linux) +# - pbcopy (macOS) +# - termux-clipboard-set (Termux) +# - clip.exe (WSL) +# - clip (Cygwin) +# - wl-copy (Wayland) +# - clipboard (Haiku) +# +# 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=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +[ -s "$selection" ] || { echo "plugin .cbcp error: empty selection" >&2 ; exit 1; } + +if type xsel >/dev/null 2>&1; then + # Linux + tr '\0' '\n' < "$selection" | xsel -bi +elif type xclip >/dev/null 2>&1; then + # Linux + tr '\0' '\n' < "$selection" | xclip -sel clip +elif type pbcopy >/dev/null 2>&1; then + # macOS + tr '\0' '\n' < "$selection" | pbcopy +elif type termux-clipboard-set >/dev/null 2>&1; then + # Termux + tr '\0' '\n' < "$selection" | termux-clipboard-set +elif type clip.exe >/dev/null 2>&1; then + # WSL + tr '\0' '\n' < "$selection" | clip.exe +elif type clip >/dev/null 2>&1; then + # Cygwin + tr '\0' '\n' < "$selection" | clip +elif type wl-copy >/dev/null 2>&1; then + # Wayland + tr '\0' '\n' < "$selection" | wl-copy +elif type clipboard >/dev/null 2>&1; then + # Haiku + tr '\0' '\n' < "$selection" | clipboard --stdin +fi |
