mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
6f9571a805
- Add a native vector icon for Haiku (it hasn't been Haiku-ified yet however) - Add a rdef file (specifies application metadata) - Add clipboard support, notififcation support, and basic nuke support - Fix support for fortunes on Haiku ("-s" option is not available on Haiku) - Cleanup Haiku recipe
63 lines
1.4 KiB
Bash
Executable file
63 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
# Description: Copy system clipboard newline-separated file list to selection
|
|
# Dependencies:
|
|
# - tr
|
|
# - xclip/xsel (Linux)
|
|
# - pbpaste (macOS)
|
|
# - termux-clipboard-get (Termux)
|
|
# - powershell (WSL)
|
|
# - cygwim's /dev/clipboard (Cygwin)
|
|
# - wl-paste (Wayland)
|
|
# - clipboard (Haiku)
|
|
#
|
|
# Limitation: breaks if a filename has newline in it
|
|
#
|
|
# Shell: POSIX compliant
|
|
# Author: Léo Villeveygoux, after Arun Prakash Jana's .cbcp
|
|
|
|
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
|
|
|
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
|
|
|
getclip () {
|
|
|
|
if which xsel >/dev/null 2>&1; then
|
|
# Linux
|
|
xsel -bo
|
|
elif which xclip >/dev/null 2>&1; then
|
|
# Linux
|
|
xclip -sel clip -o
|
|
elif which pbpaste >/dev/null 2>&1; then
|
|
# macOS
|
|
pbpaste
|
|
elif which termux-clipboard-get >/dev/null 2>&1; then
|
|
# Termux
|
|
termux-clipboard-get
|
|
elif which powershell.exe >/dev/null 2>&1; then
|
|
# WSL
|
|
powershell.exe Get-Clipboard
|
|
elif [ -r /dev/clipboard ] ; then
|
|
# Cygwin
|
|
cat /dev/clipboard
|
|
elif which wl-paste >/dev/null 2>&1; then
|
|
# Wayland
|
|
wl-paste
|
|
elif which clipboard >/dev/null 2>&1; then
|
|
# Haiku
|
|
clipboard --print
|
|
fi
|
|
|
|
}
|
|
|
|
CLIPBOARD=$(getclip)
|
|
|
|
# Check if clipboard actually contains a file list
|
|
for file in $CLIPBOARD ; do
|
|
if [ ! -e "$file" ] ; then
|
|
exit 1;
|
|
fi
|
|
done
|
|
|
|
printf "%s" "$CLIPBOARD" | tr '\n' '\0' > "$selection"
|