Skip to content

Instantly share code, notes, and snippets.

@rweichler
Created February 5, 2014 01:36
Show Gist options
  • Save rweichler/8815967 to your computer and use it in GitHub Desktop.
Save rweichler/8815967 to your computer and use it in GitHub Desktop.
pbcopy
#import <UIKit/UIKit.h>
#include <stdio.h>
#define yeah() printf("%s\n", pb.string.UTF8String)
int main() {
@autoreleasepool
{
UIPasteboard *pb = [UIPasteboard generalPasteboard];
char buf[BUFSIZ];
fgets(buf, sizeof buf, stdin);
char lastchar = buf[strlen(buf)-1];
if (lastchar == '\n') {
// read full line
buf[strlen(buf) - 1] = '\0';
pb.string = [NSString stringWithUTF8String:buf];
yeah();
} else {
// line was truncated
}
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment