diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2020-11-13 11:31:11 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2020-11-13 11:37:28 +0530 |
commit | 7afc3eeedd77d6e871e764cb63fb7e794df7e604 (patch) | |
tree | 2521331ecf4d738a31f9016efda8239332e7648b | |
parent | 1c4bc318f50f259c368f15e37dbf4b5246eade77 (diff) | |
download | nnn-7afc3eeedd77d6e871e764cb63fb7e794df7e604.tar.gz |
Fix #777: input stream ishould trump -s/-S
If an input stream is available, prioritize that over sessions. find/grep
syntax can be very complex and can be scripted. On the contrary, sessions
can be loaded at runtime and the persistent session can be "restored".
An interesting use case is the listing is done in picker mode from a script
and the user expects to "pick" some entries among the listed search results.
Another important change is - if the user tries to load the "last session"
explicitly by name instead of using the session option _restore_, we should
not overwrite the "last session" ("@") before loading the it.
-rw-r--r-- | nnn.1 | 7 | ||||
-rw-r--r-- | src/nnn.c | 7 |
2 files changed, 12 insertions, 2 deletions
@@ -197,6 +197,9 @@ When a session is loaded dynamically, the last working session is saved automatically to a dedicated -- "last session" -- session file. The "last session" is also used in persistent session mode. .Pp +Listing input stream is given a higher priority to persistent sessions. Use +session option \fIrestore\fR to restore the persistent session at runtime. +.Pp All the session files are located by session name in the directory .Pp \fB${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions\fR @@ -345,8 +348,8 @@ A temporary directory will be created containing symlinks to the given paths. Any action performed on these symlinks will be performed only on their targets, after which they might become invalid. .Pp -Right arrow or 'l' on a symlink in the listing dir takes to the target file. -Press '-' to return to the listing dir. Press 'Enter' to open the symlink. +Right arrow or 'l' on a symlink in the listing dir takes to the target +file. Press '-' to return to the listing dir. Press 'Enter' to open the symlink. .Sh UNITS The minimum file size unit is byte (B). The rest are K, M, G, T, P, E, Z, Y (powers of 1024), same as the default units in \fIls\fR. @@ -3955,6 +3955,10 @@ static bool load_session(const char *sname, char **path, char **lastdir, char ** return FALSE; mkpath(ssnpath, sname, spath); + + /* If user is explicitly loading the "last session", skip auto-save */ + if ((sname[0] == '@') && !sname[1]) + has_loaded_dynamically = FALSE; } else mkpath(ssnpath, "@", spath); @@ -7687,6 +7691,9 @@ int main(int argc, char *argv[]) /* We return to tty */ dup2(STDOUT_FILENO, STDIN_FILENO); + + if (session) + session = NULL; } home = getenv("HOME"); |