-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init
- Loading branch information
0 parents
commit 6bc5fdc
Showing
9 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Console clipboard (https://github.com/zvezdochiot/cb) | ||
|
||
AUTHOR: | ||
|
||
zvezdochiot (https://github.com/zvezdochiot) | ||
|
||
--- | ||
2018 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Console clipboard (https://github.com/zvezdochiot/cb) | ||
|
||
0.20180620 zvezdochiot | ||
init: cbc, cbf, cbp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Simplified BSD License | ||
http://www.opensource.org/licenses/bsd-license.html | ||
|
||
Copyright (c) 2018 zvezdochiot (https://github.com/zvezdochiot) | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in | ||
the documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
PNAME = cb | ||
PVER = 0.20180620 | ||
PROG1 = cbc | ||
PROG2 = cbf | ||
PROG3 = cbp | ||
PROGS = $(PROG1) $(PROG2) $(PROG3) | ||
PDOCS = AUTHORS CHANGELOG LICENSE README.md | ||
CC = gcc | ||
PREFIX = /usr/local | ||
RM = @rm -fv | ||
INSTALL = install | ||
|
||
.PHONY: all clean install | ||
|
||
all: $(PROGS) | ||
|
||
$(PROG1): | ||
$(CC) src/$@.c -o $@ | ||
|
||
$(PROG2): | ||
$(CC) src/$@.c -o $@ | ||
|
||
$(PROG3): | ||
$(CC) src/$@.c -o $@ | ||
|
||
clean: | ||
$(RM) $(PROGS) | ||
|
||
install: $(PROGS) | ||
$(INSTALL) -d $(PREFIX) | ||
$(INSTALL) -m 0755 $(PROGS) $(PREFIX)/bin/ | ||
$(INSTALL) -d $(PREFIX)/share/doc/$(PNAME) | ||
$(INSTALL) -m 0644 $(PDOCS) $(PREFIX)/share/doc/$(PNAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Console clipboard [copy/file/paste] (https://github.com/zvezdochiot/cb) | ||
=================================== | ||
|
||
An easy to way to perform copy & paste operations in the terminal. | ||
|
||
Copy and paste using `stdin/stdout` | ||
|
||
```sh | ||
# Copy a single line | ||
cbc "This is some data" | ||
|
||
# Copy lots of data | ||
cat ./sample.txt | cbf - | ||
|
||
# Copy a single file | ||
cbf sample.txt | ||
|
||
# Now its time to paste the data... | ||
|
||
# Using stdout | ||
cbp | ||
|
||
# Send clipboard data to file | ||
cbp > output.txt | ||
``` | ||
|
||
Building clip is very simple. Just use the predefined `Makefile` | ||
|
||
```sh | ||
# Compile all the sources. | ||
make | ||
|
||
# To install the application globally run | ||
[sudo] make install | ||
``` | ||
|
||
This will generate an executable called `cbc`, `cbf` and `cbp` in the working directory. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* clip - A simple copy and paste utility for the terminal | ||
* | ||
* @author Matthew Cross <[email protected]> | ||
* @package clip | ||
*/ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
const char* consoleclip = "/tmp/clipboard.tmp"; | ||
FILE *fcc; | ||
char buf[1024]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* cbc - Console clipboard copy (no X11). | ||
* | ||
* @author zvezdochiot <[email protected]> | ||
*/ | ||
#include "cb.h" | ||
|
||
void usage() | ||
{ | ||
printf("Concole clipboard copy\n\n"); | ||
printf("Usage: cbc <copy_text>\n\n"); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
int i; | ||
if (argc < 2) { | ||
usage(); | ||
exit(0); | ||
} | ||
|
||
if ((fcc = fopen(consoleclip, "w")) == NULL) | ||
{ | ||
printf("can't open %s\n", consoleclip); | ||
exit(1); | ||
} | ||
|
||
for (i = 1; i < argc; i++) | ||
{ | ||
fprintf(fcc, "%s ", argv[i]); | ||
} | ||
|
||
fclose(fcc); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* cbc - Console clipboard copy file (no X11). | ||
* | ||
* @author zvezdochiot <[email protected]> | ||
*/ | ||
#include "cb.h" | ||
|
||
void usage() | ||
{ | ||
printf("Concole clipboard copy file\n\n"); | ||
printf("Usage: cbf <file_name>\n\n"); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
int i; | ||
FILE *fin; | ||
if (argc < 2) { | ||
usage(); | ||
exit(0); | ||
} | ||
|
||
if ((fin = strcmp(argv[1], "-")? fopen(argv[1], "r") : stdin) == NULL) | ||
{ | ||
printf("can't open %s\n", argv[1]); | ||
exit(1); | ||
} | ||
|
||
if ((fcc = fopen(consoleclip, "w")) == NULL) | ||
{ | ||
printf("can't open %s\n", consoleclip); | ||
exit(1); | ||
} | ||
|
||
while (fgets(buf, 1024, fin) != NULL) | ||
{ | ||
fprintf(fcc, "%s", buf); | ||
} | ||
|
||
fclose(fin); | ||
fclose(fcc); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* cbp - Console clipboard paste (no X11). | ||
* | ||
* @author zvezdochiot <[email protected]> | ||
*/ | ||
#include "cb.h" | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
|
||
if ((fcc = fopen(consoleclip, "r")) == NULL) | ||
{ | ||
printf("can't open %s\n", consoleclip); | ||
exit(1); | ||
} | ||
|
||
while (fgets(buf, 1024, fcc) != NULL) | ||
{ | ||
printf("%s", buf); | ||
} | ||
|
||
fclose(fcc); | ||
} | ||
|