sclip

shitty clipboard
git clone git://git.ckyln.com/~cem/sclip.git
Log | Files | Refs | README | LICENSE

commit 50bbd17fe43ee8b70ec80d14116ba143018e255b
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 20 Nov 2019 11:41:30 +0300

initial commit

Diffstat:
ALICENSE | 21+++++++++++++++++++++
AMakefile | 17+++++++++++++++++
AREADME | 43+++++++++++++++++++++++++++++++++++++++++++
Asclip | 15+++++++++++++++
4 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Cem Keylan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile @@ -0,0 +1,17 @@ +PREFIX = /usr/local +BINDIR = $(PREFIX)/bin + +options: + @echo Build options for sclip + @echo PREFIX = ${PREFIX} + @echo BINDIR = ${BINDIR} + +install: + install -Dm755 sclip $(DESTDIR)$(BINDIR)/sclip + +uninstall: + rm -f $(DESTDIR)$(BINDIR)/sclip + + +.PHONY: options install uninstall + diff --git a/README b/README @@ -0,0 +1,43 @@ +sclip +===== + +dumb clipboard manager with 10 lines +of POSIX shell code (excluding whitespace) + + +Features +-------- + +* Pipe into sclip to add text to clipboard +* Can pipe the text being copied to stdout +* Very scriptable +* Literally shorter than this README +* Works both in X and TTY + + +Non-Features +------------- + +* Does not use a complex buffer, writes into a file +* Does not integrate with the selection and + clipboard defined by the Free Desktop Specification + + +Usage Examples +-------------- + + +[create a dmenu after copying text] + + $ printf "list item 1\\nlist item 2\\n" | sclip -o | dmenu + + +[copy sclip to xclip or vice versa] + + $ sclip -p | xclip -selection clipboard + $ xclip -out | sclip + + +Author +------ +Cem Keylan diff --git a/sclip b/sclip @@ -0,0 +1,15 @@ +#!/bin/sh + +# Dumb clipboard manager for tty + +usage() { printf "USAGE: ${0##*/} -p[rint]|-d[elete]|-o[ut]|-h[elp]\\nSee README for more info\\n"; exit 1; } + +[ "$1" = "-h" ] || [ "$1" = "--help" ] && usage +mkdir -p "$HOME/.cache" # Create cache directory if it doesn't exist +while getopts ':pdo' args; do case $args in + p) cat "$HOME/.cache/clipboard"; exit ;; # Print clipboard + d) :> "$HOME/.cache/clipboard"; exit ;; # Delete clipboard + o) stdout="1" ;; # Print stdin to stdout + ?) printf "${0##*/}: invalid option -- $OPTARG\\n" ; exit 1 ;; esac; done +cat > "$HOME/.cache/clipboard" +[ -z "$stdout" ] || cat "$HOME/.cache/clipboard"