Resolve ~ (HOME) at chdir prompt

This commit is contained in:
Arun Prakash Jana 2017-04-05 10:25:59 +05:30
parent 2e3502ea4b
commit b7e4968a48
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 13 additions and 3 deletions

View file

@ -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" },

12
nnn.c
View file

@ -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;