diff -ur original-src/browser.c my-src/browser.c --- original-src/browser.c 2016-02-26 02:17:10.000000000 +0530 +++ my-src/browser.c 2016-04-23 15:31:28.826298000 +0530 @@ -60,6 +60,8 @@ /* The selected file we had before the current selected file. */ functionptrtype func; /* The function of the key the user typed in. */ + path_for_tab_c = strdup("./"); + /* Assigned is default path; from where nano is running. */ /* Don't show a cursor in the file list. */ curs_set(0); @@ -271,6 +273,7 @@ /* Start over again with the new path value. */ free(path); path = new_path; + path_for_tab_c = mallocstrcpy(path_for_tab_c, path); goto change_browser_directory; } else if (func == do_up_void) { if (selected >= width) @@ -335,6 +338,7 @@ prev_dir = striponedir(filelist[selected]); path = mallocstrcpy(path, filelist[selected]); + path_for_tab_c = mallocstrcpy(path_for_tab_c, path); /* Start over again with the new path value. */ goto change_browser_directory; Only in my-src: .deps diff -ur original-src/files.c my-src/files.c --- original-src/files.c 2016-02-26 02:17:10.000000000 +0530 +++ my-src/files.c 2016-04-23 15:46:08.102302000 +0530 @@ -2713,7 +2713,11 @@ free(tmpdirname); } else { filename = dirname; - dirname = mallocstrcpy(NULL, "./"); + dirname = mallocstrcpy(NULL, path_for_tab_c); + if (dirname[strlen(dirname) - 1] != '/') { + dirname = realloc(dirname, PATH_MAX + 1); + strcat(dirname, "/"); + } } assert(dirname[strlen(dirname) - 1] == '/'); diff -ur original-src/global.c my-src/global.c --- original-src/global.c 2016-02-22 20:17:49.000000000 +0530 +++ my-src/global.c 2016-04-23 15:36:02.742299000 +0530 @@ -40,6 +40,8 @@ /* Whether the current keystroke is an extended keypad value. */ bool focusing = FALSE; /* Whether an update of the edit window should center the cursor. */ +char *path_for_tab_c = NULL; + /* Stores current path in browser for cwd_tab_completion(). */ #ifndef NANO_TINY int controlleft = CONTROL_LEFT; diff -ur original-src/proto.h my-src/proto.h --- original-src/proto.h 2016-02-26 02:17:10.000000000 +0530 +++ my-src/proto.h 2016-04-23 15:32:14.834298000 +0530 @@ -34,6 +34,7 @@ extern bool meta_key; extern bool func_key; extern bool focusing; +extern char *path_for_tab_c; #ifndef NANO_TINY extern int controlleft;