diff --git a/README.md b/README.md

index ea1f81f04aac1b93f73fca7d984b6e3f02415a2b..e1b424367e49daad233793f663f6340849eb4286 100644

--- a/README.md

+++ b/README.md

@@ -17,6 +17,7 @@ This project is of fork of https://git.sr.ht/~sircmpwn/gmni

It includes the following modifications:

- default 4 char indenting

+- e[N] command to open a link in default external program (requires `xdg-open`)

- colored headings & links

The actual colors used depend on your terminal palette:

diff --git a/src/cgmnlm.c b/src/cgmnlm.c

index 6f0b8773c16001ab95edaec345879874483114a9..5bf7dfdbea9a60cd610d76b82bb8e9bc3d5ffa1d 100644

--- a/src/cgmnlm.c

+++ b/src/cgmnlm.c

@@ -82,6 +82,7 @@ "The following commands are available:\n\n"

"q\tQuit\n"

"[N]\tFollow Nth link (where N is a number)\n"

"u[N]\tShow URL of Nth link (where N is a number)\n"

+ "e[N]\tSend URL of Nth link in external default program\n"

"b\tBack (in the page history)\n"

"f\tForward (in the page history)\n"

"H\tView all page history\n"

@@ -502,8 +503,11 @@ {

enum prompt_result result;

fprintf(browser->tty, "%s", prompt);

- size_t l = 0;

+ struct link *link = browser->links;

+ char *endptr = NULL;

+ int linksel = 0;

char *in = NULL;

+ size_t l = 0;

ssize_t n = getline(&in, &l, browser->tty);

if (n == -1 && feof(browser->tty)) {

result = PROMPT_QUIT;

@@ -592,11 +596,10 @@ fprintf(stderr, "Cannot move to next result; we are not searching for anything\n");

result = PROMPT_AGAIN;

goto exit;

}

+ case 'e':

case 'u':

if (!in[1]) break;

- struct link *link = browser->links;

- char *endptr;

- int linksel = (int)strtol(in+1, &endptr, 10);

+ linksel = (int)strtol(in+1, &endptr, 10);

if (!endptr[0] && linksel >= 0) {

while (linksel > 0 && link) {

link = link->next;

@@ -607,8 +610,12 @@ if (!link) {

fprintf(stderr, "Error: no such link.\n");

} else {

fprintf(browser->tty, "=> %s\n", link->url);

- result = PROMPT_AGAIN;

- goto exit;

+ if (in[0] == 'e') {

+ char xdgopen[4096];

+ snprintf(xdgopen, sizeof(xdgopen), "xdg-open %s", link->url);

+ if ( !system(xdgopen) ) fprintf(browser->tty, "Link send to xdg-open\n");

+ }

+ fprintf(browser->tty, "\n");

}

} else {

fprintf(stderr, "Error: invalid argument.\n");

@@ -664,9 +671,7 @@ result = PROMPT_AGAIN;

goto exit;

}

- struct link *link = browser->links;

- char *endptr;

- int linksel = (int)strtol(in, &endptr, 10);

+ linksel = (int)strtol(in, &endptr, 10);

if ((endptr[0] == '\0' || endptr[0] == '|') && linksel >= 0) {

while (linksel > 0 && link) {

link = link->next;