dotfiles/sh/.local/bin/clip
Marty Oehme 95e2fea951
nvim: Disable uninstalled python language servers
Had to manually disable python lsps that are not on my system since
neovim otherwise complains about it whenever I enter a new python
filetype file.
2022-04-30 21:00:05 +02:00

41 lines
881 B
Bash
Executable file

#!/usr/bin/env sh
# clip -- easy copying to clipboard manager with
# wl-copy / xclip / xsel
#
# clips arguments passed to the clipboard
# or stdin if stdin is passed.
#
# idea ~~stolen~~ creatively borrowed from
# https://github.com/kyazdani42/dotfiles/blob/master/bin/copy
clip() {
if exist wl-copy; then
printf "%s" "$1" | wl-copy
elif exist xclip; then
echo "$1" | xclip -i -selection clipboard
elif exist xsel; then
echo "$1" | xsel -i --clipboard
else
printf "No working clipboard program found. Install wl-copy/xclip/xsel and try again."
exit 1
fi
}
# if we are in a pipe, read from stdin
if [ ! -t 0 ]; then
clip "$(cat /dev/stdin)"
exit 0
fi
# TODO check if $1 is a file, and if it's png or similar, clip that
if [ $# -lt 1 ]; then
printf "No file argument or stdin passed to clip. Exiting."
exit 1
fi
if [ "$#" -ge 1 ]; then
clip "$*"
exit 0
fi