~skiqqy/bin

9d8a9f8519f50dcfd8398ed73133b7532f79d85a — Stephen Cochrane 2 months ago 6876c80
Clip can now handle multiline copies
1 files changed, 4 insertions(+), 3 deletions(-)

M clip
M clip => clip +4 -3
@@ 31,7 31,7 @@ paste()

	if [ "$len" -gt 0 ]
	then
		dmenu -l "$len" < "$buffer" | xclip -r -selection clipboard
		dmenu -l "$len" < "$buffer" | tr "$delim" '\n' | xclip -r -selection clipboard
	else
		printf 'Buffer is empty.\n'
		return 1


@@ 57,7 57,7 @@ copy()
	if [ -n "$(xclip -o)" ]
	then
		{
			xclip -o
			xclip -o | tr  '\n' "$delim" # Replace new lines with delim char \x1f
			printf '\n'
		} >> "$buffer"
	else


@@ 70,13 70,14 @@ copy()
clean()
{
	printf 'Resetting buffer...\n'
	true > "$buffer" # True is just to no-op
	: > "$buffer"
}

main()
{
	max=10 # Max items to be kept in the buffer.
	buffer='/tmp/copy.buffer'
	delim="$(printf '\x1f')"

	while getopts hb: opt
	do