Fix #526: persistent session

This commit is contained in:
Arun Prakash Jana 2020-04-18 04:54:07 +05:30
parent c63fb28eff
commit 645f43355e
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 10 additions and 7 deletions

5
nnn.1
View file

@ -109,7 +109,7 @@ supports the following options:
load a session by name load a session by name
.Pp .Pp
.Fl S .Fl S
start in disk usage analyzer mode persistent session
.Pp .Pp
.Fl "t secs" .Fl "t secs"
idle timeout in seconds to lock terminal idle timeout in seconds to lock terminal
@ -160,7 +160,8 @@ Sessions can be loaded dynamically from within a running
instance, or with a program option. instance, or with a program option.
.Pp .Pp
When a session is loaded dynamically, the last working session is saved When a session is loaded dynamically, the last working session is saved
automatically to a dedicated -- "last session" -- session file. automatically to a dedicated -- "last session" -- session file. The "last
session" is also used in persistent session mode.
.Pp .Pp
All the session files are located by session name in the directory All the session files are located by session name in the directory
.Pp .Pp

View file

@ -6245,6 +6245,9 @@ nochange:
break; // fallthrough break; // fallthrough
} }
if (session && *session == '@' && !session[1])
save_session(TRUE, NULL);
/* CD on Quit */ /* CD on Quit */
/* In vim picker mode, clear selection and exit */ /* In vim picker mode, clear selection and exit */
/* Picker mode: reset buffer or clear file */ /* Picker mode: reset buffer or clear file */
@ -6531,7 +6534,7 @@ static void usage(void)
" -r use advcpmv patched cp, mv\n" " -r use advcpmv patched cp, mv\n"
" -R no rollover at edges\n" " -R no rollover at edges\n"
" -s name load session by name\n" " -s name load session by name\n"
" -S du mode\n" " -S persistent session\n"
" -t secs timeout to lock\n" " -t secs timeout to lock\n"
" -T key sort order [a/d/e/r/s/t/v]\n" " -T key sort order [a/d/e/r/s/t/v]\n"
" -V show version\n" " -V show version\n"
@ -6696,10 +6699,6 @@ int main(int argc, char *argv[])
case 'c': case 'c':
cfg.cliopener = 1; cfg.cliopener = 1;
break; break;
case 'S':
cfg.blkorder = 1;
nftw_fn = sum_bsize;
blk_shift = ffs(S_BLKSIZE) - 1; // fallthrough
case 'd': case 'd':
cfg.showdetail = 1; cfg.showdetail = 1;
printptr = &printent_long; printptr = &printent_long;
@ -6770,6 +6769,9 @@ int main(int argc, char *argv[])
if (env_opts_id < 0) if (env_opts_id < 0)
session = optarg; session = optarg;
break; break;
case 'S':
session = "@";
break;
case 't': case 't':
if (env_opts_id < 0) if (env_opts_id < 0)
idletimeout = atoi(optarg); idletimeout = atoi(optarg);