cgmnlm

colorful gemini line mode browser
git clone https://git.clttr.info/cgmnlm.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 2fe9bafc5cb5da96adf9068505d79bfbe9a82e9a
parent e84d5c5ed7c675c97c8bb4d6c6e4d43e02d5e81b
Author: René Wagner <rwa@clttr.info>
Date:   Sun, 31 Oct 2021 22:17:06 +0100

allow ~ as home alias in file path for download

closes #1

Diffstat:
Msrc/gmnlm.c | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gmnlm.c b/src/gmnlm.c @@ -810,7 +810,12 @@ do_prompts(const char *prompt, struct browser *browser) 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;