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

index 6ebffa64d42f52cd1a75c320fa33d2946bbbfdd7..4a5932482fe706e3c91636e95694b0d4b8feb53b 100644

--- a/src/gmnlm.c

+++ b/src/gmnlm.c

@@ -810,7 +810,12 @@ result = PROMPT_AGAIN;

goto exit;

}

set_url(browser, url, NULL);

- download_resp(browser->tty, resp, trim_ws(&in[1]), url);

+ char file[1024] = {0};

+ strncpy(file, trim_ws(&in[1]), sizeof(file));

+ if (file[0] == '~') {

+ snprintf(file, sizeof(file), "%s%s", getenv("HOME"), &trim_ws(&in[1])[1]);

+ }

+ download_resp(browser->tty, resp, file, url);

gemini_response_finish(&resp);

result = PROMPT_AGAIN;

goto exit;