diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2017-04-05 10:25:59 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2017-04-06 06:29:13 +0530 |
commit | b7e4968a488b2718c11c7468d393102785865b43 (patch) | |
tree | e8e4cff9868a4f37d31d48ae6cf028725f8bb4e9 | |
parent | 2e3502ea4bb0327998fe03abceaa4be8ad22481e (diff) | |
download | nnn-b7e4968a488b2718c11c7468d393102785865b43.tar.gz |
Resolve ~ (HOME) at chdir prompt
-rw-r--r-- | config.def.h | 4 | ||||
-rw-r--r-- | nnn.c | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/config.def.h b/config.def.h index 6c47663..7ab3856 100644 --- a/config.def.h +++ b/config.def.h @@ -12,9 +12,9 @@ static char *idlecmd = "rain"; /* The screensaver program */ struct assoc assocs[] = { { "\\.(c|cpp|h|txt|log|sh)$", "vi" }, - //{ "\\.(avi|mp4|mkv|3gp|mov)$", "mpv" }, + { "\\.(avi|mp4|mkv|3gp|mov)$", "mpv" }, { "\\.(wma|mp3|ogg|flac|m4a)$", "mpv" }, - //{ "\\.(png|jpg|gif)$", "feh" }, + { "\\.(png|jpg|gif)$", "viewnior" }, //{ "\\.(html|svg)$", "firefox" }, { "\\.pdf$", "zathura" }, //{ "\\.sh$", "sh" }, @@ -1247,7 +1247,17 @@ nochange: clearprompt(); goto nochange; } - mkpath(path, tmp, newpath, sizeof(newpath)); + + if (tmp[0] == '~') { + char *home = getenv("HOME"); + if (home) + snprintf(newpath, PATH_MAX, + "%s%s", home, tmp + 1); + else + mkpath(path, tmp, newpath, sizeof(newpath)); + } else + mkpath(path, tmp, newpath, sizeof(newpath)); + if (canopendir(newpath) == 0) { printwarn(); goto nochange; |