cb: cross-platform clipboard script added
wayland support 👍
This commit is contained in:
parent
28f20bc15f
commit
95138d0ddf
@ -87,4 +87,4 @@ bind -n C-M-n newpanecurdir
|
|||||||
|
|
||||||
bind -T copy-mode-vi v send -X begin-selection
|
bind -T copy-mode-vi v send -X begin-selection
|
||||||
bind -T copy-mode-vi V send -X select-line
|
bind -T copy-mode-vi V send -X select-line
|
||||||
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'cb.sh set'
|
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'cb set'
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
TMPFILE="$(mktemp)"
|
TMPFILE="$(mktemp)"
|
||||||
|
|
||||||
xsel -b > "$TMPFILE"
|
cb > "$TMPFILE"
|
||||||
|
|
||||||
newterm() {
|
newterm() {
|
||||||
alacritty msg create-window "$@" ||
|
alacritty msg create-window "$@" ||
|
||||||
@ -15,4 +15,4 @@ newterm \
|
|||||||
-o 'window.opacity = 1.0' \
|
-o 'window.opacity = 1.0' \
|
||||||
-o 'window.dimensions = { columns = 84, lines = 10 }' \
|
-o 'window.dimensions = { columns = 84, lines = 10 }' \
|
||||||
-o 'window.position = { x = 0, y = 1200 }' \
|
-o 'window.position = { x = 0, y = 1200 }' \
|
||||||
-e sh -c "xsel -b > '$TMPFILE'; nvim -c 'set binary noeol textwidth=80' '$TMPFILE' && cat '$TMPFILE' | xsel -ib && rm '$TMPFILE'"
|
-e sh -c "cb > '$TMPFILE'; nvim -c 'set binary noeol textwidth=80' '$TMPFILE' && cat '$TMPFILE' | cb set && rm '$TMPFILE'"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copy a bookmark to clipboard.
|
# Copy a bookmark to clipboard.
|
||||||
#
|
#
|
||||||
# Requires fzf, xsel
|
# Requires fzf, cb (script in this repo)
|
||||||
# Bookmarks are stored in ~/dox/not/bk.txt, commented with #
|
# Bookmarks are stored in ~/dox/not/bk.txt, commented with ^
|
||||||
# -o: print to stdout
|
# -o: print to stdout
|
||||||
# -b: open in browser
|
# -b: open in browser
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ if [ "$action" = "stdout" ]; then
|
|||||||
printf "%s" "$output"
|
printf "%s" "$output"
|
||||||
fi
|
fi
|
||||||
if [ "$action" = "clip" ]; then
|
if [ "$action" = "clip" ]; then
|
||||||
printf "%s" "$output" | xsel -ib
|
printf "%s" "$output" | cb set
|
||||||
fi
|
fi
|
||||||
if [ "$action" = "browser" ]; then
|
if [ "$action" = "browser" ]; then
|
||||||
$BROWSER "$output"
|
$BROWSER "$output"
|
||||||
|
45
src/dot_local/bin/executable_cb
Normal file
45
src/dot_local/bin/executable_cb
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# cross-platform clipboard wrapper
|
||||||
|
# drop-in replacement for xsel wherever used in my dotfiles
|
||||||
|
|
||||||
|
err () {
|
||||||
|
echo $@ 1>&2
|
||||||
|
}
|
||||||
|
|
||||||
|
no_provider () {
|
||||||
|
err "no providers for clipboard found!"
|
||||||
|
err "supported: termux-api, xsel, wl-clipboard"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "$1" ] || [ "$1" = "-b" ]; then
|
||||||
|
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||||
|
if command -v wl-paste > /dev/null; then
|
||||||
|
wl-paste
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if command -v xsel > /dev/null; then
|
||||||
|
xsel -b
|
||||||
|
elif command -v termux-clipboard-set > /dev/null; then
|
||||||
|
termux-clipboard-get
|
||||||
|
else
|
||||||
|
no_provider
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
elif [ "$1" = "-i" ] || [ "$1" = "set" ]; then
|
||||||
|
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||||
|
if command -v wl-copy > /dev/null; then
|
||||||
|
wl-copy
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if command -v xsel > /dev/null; then
|
||||||
|
xsel -ib
|
||||||
|
elif command -v termux-clipboard-set > /dev/null; then
|
||||||
|
cat /dev/stdin | termux-clipboard-set
|
||||||
|
else
|
||||||
|
no_provider
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
err "usage: cb [-i] [set] [--help]"
|
||||||
|
err "communicates via stdout/stdin."
|
||||||
|
fi
|
@ -1,28 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# clipboard wrapper
|
|
||||||
|
|
||||||
no_provider () {
|
|
||||||
echo "no providers for clipboard found!"
|
|
||||||
echo "supported: termux-api, xsel, xclip"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$1" = "set" ]; then
|
|
||||||
if command -v xsel > /dev/null; then
|
|
||||||
xsel -ib
|
|
||||||
elif command -v termux-clipboard-set > /dev/null; then
|
|
||||||
cat /dev/stdin | termux-clipboard-set
|
|
||||||
else
|
|
||||||
no_provider
|
|
||||||
fi
|
|
||||||
elif [ "$1" = "get" ]; then
|
|
||||||
if command -v xsel > /dev/null; then
|
|
||||||
xsel -b
|
|
||||||
elif command -v termux-clipboard-set > /dev/null; then
|
|
||||||
termux-clipboard-get
|
|
||||||
else
|
|
||||||
no_provider
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "usage: cb.sh get/set"
|
|
||||||
echo "pipe in data"
|
|
||||||
fi
|
|
@ -2,7 +2,7 @@
|
|||||||
# Append link from clipboard/argument to mpv playlist
|
# Append link from clipboard/argument to mpv playlist
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
path="$(xsel -b)"
|
path="$(cb)"
|
||||||
else
|
else
|
||||||
path="$2"
|
path="$2"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user