mirror of
https://github.com/hydroxycarbamide/dotfiles.git
synced 2025-05-07 21:39:07 -04:00
Add nnn
This commit is contained in:
parent
0ef5de12ac
commit
c0889285ff
58 changed files with 5175 additions and 0 deletions
62
dot_config/nnn/plugins/executable_x2sel
Normal file
62
dot_config/nnn/plugins/executable_x2sel
Normal file
|
@ -0,0 +1,62 @@
|
|||
#!/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)
|
||||
#
|
||||
# Note:
|
||||
# - 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 [ "$XDG_SESSION_TYPE" = "wayland" ]; then
|
||||
# Wayland
|
||||
wl-paste
|
||||
elif type xsel >/dev/null 2>&1; then
|
||||
# Linux
|
||||
xsel -bo
|
||||
elif type xclip >/dev/null 2>&1; then
|
||||
# Linux
|
||||
xclip -sel clip -o
|
||||
elif type pbpaste >/dev/null 2>&1; then
|
||||
# macOS
|
||||
pbpaste
|
||||
elif type termux-clipboard-get >/dev/null 2>&1; then
|
||||
# Termux
|
||||
termux-clipboard-get
|
||||
elif type powershell.exe >/dev/null 2>&1; then
|
||||
# WSL
|
||||
powershell.exe Get-Clipboard
|
||||
elif [ -r /dev/clipboard ] ; then
|
||||
# Cygwin
|
||||
cat /dev/clipboard
|
||||
elif type 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"
|
Loading…
Add table
Add a link
Reference in a new issue