mirror of
https://github.com/jarun/nnn.git
synced 2024-11-18 08:59:14 +00:00
Print the resolved path for cwd
Avoids weird things like /etc/.. when displaying cwd. Also no need for cwd to be on the heap.
This commit is contained in:
parent
2d87145fa2
commit
a715201255
14
noice.c
14
noice.c
|
@ -595,8 +595,9 @@ populate(void)
|
||||||
void
|
void
|
||||||
redraw(void)
|
redraw(void)
|
||||||
{
|
{
|
||||||
|
char cwd[PATH_MAX], cwdresolved[PATH_MAX];
|
||||||
|
size_t ncols;
|
||||||
int nlines, odd;
|
int nlines, odd;
|
||||||
char *cwd;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
nlines = MIN(LINES - 4, n);
|
nlines = MIN(LINES - 4, n);
|
||||||
|
@ -615,11 +616,14 @@ redraw(void)
|
||||||
DPRINTF_S(path);
|
DPRINTF_S(path);
|
||||||
|
|
||||||
/* No text wrapping in cwd line */
|
/* No text wrapping in cwd line */
|
||||||
cwd = xmalloc(COLS * sizeof(char));
|
ncols = COLS;
|
||||||
strlcpy(cwd, path, COLS * sizeof(char));
|
if (ncols > PATH_MAX)
|
||||||
cwd[COLS - strlen(CWD) - 1] = '\0';
|
ncols = PATH_MAX;
|
||||||
|
strlcpy(cwd, path, ncols);
|
||||||
|
cwd[ncols - strlen(CWD) - 1] = '\0';
|
||||||
|
realpath(cwd, cwdresolved);
|
||||||
|
|
||||||
printw(CWD "%s\n\n", cwd);
|
printw(CWD "%s\n\n", cwdresolved);
|
||||||
|
|
||||||
/* Print listing */
|
/* Print listing */
|
||||||
odd = ISODD(nlines);
|
odd = ISODD(nlines);
|
||||||
|
|
Loading…
Reference in a new issue