Last active
July 30, 2018 04:59
-
-
Save xPMo/756751204108c203781fd0d191e61eb5 to your computer and use it in GitHub Desktop.
OSC 8 hyperlink implementation in C using libcurl
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
#include <curl/curl.h> | |
#include <stdio.h> | |
#include <string.h> | |
void usage(char * s) | |
{ | |
fprintf(stderr, "Usage: %s <text> <url>\n", s); | |
} | |
int main(int argc, char ** argv) | |
{ | |
if(argc < 3){ | |
usage(argv[0]); | |
return 1; | |
} | |
char *url = curl_escape(argv[2], strlen(argv[2])); | |
if (!url){ | |
fprintf(stderr, "Failed to parse url."); | |
return 1; | |
} | |
printf("\e]8;;%s\a%s\e]8;;\a\n", url, argv[1]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment