@@ 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