jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
19.37k stars 761 forks source link

ToDo list #427

Closed jarun closed 4 years ago

jarun commented 4 years ago

Rolled from #386.

For next release

Proposed features and tasks (up for grabs)

Anything else which would add value (please discuss in this thread).

List of completed features and tasks.

0xACE commented 4 years ago

Shall we change $nnn to $n? What issues do you guys see? Any possibility of conflict with n used as var in a script?

I wouldn't recommend changing it to $n. We are already polluting the environment... My comment was regarding that hitting ./$nnn is a rather large key-stroke sequence for me, even ./$n would be considered too long for me, hence I'm sticking with SEL_EXEC.

jarun commented 4 years ago

OK.

jarun commented 4 years ago

@maximbaz I am working on -e and -t.

deadpyxel commented 4 years ago

Not sure if I am missing something, but the shortcut to extract files inside nnn is gone, right?

Does that mean I have to setup a special shortcut for it and bind it, or I need to enable something in configs? Sorry if this is a stupid question.

jarun commented 4 years ago

Not sure if I am missing something, but the shortcut to extract files inside nnn is gone, right?

Yes. Did you try to hit Enter on the file? ;)

nnn now understand gzip, bzip2, zip by default. For more, install atool or bsdtar which understand those formats and export NNN_ARCHIVE: https://github.com/jarun/nnn/wiki/Usage#configuration with all file extensions you want to use.

I have atool and:

export NNN_ARCHIVE="\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$"
deadpyxel commented 4 years ago

Oh, that is what I was missing. Ty @jarun , didn't think of Entersince I was thinking it would try to mount the zip. This way is much better to be honest.

jarun commented 4 years ago

Yes, for the basic formats you don't even need to install anything or set any config. As we mentioned, v2.9 has several smart workflows.

jarun commented 4 years ago

if you like the project do award a star and share with your friends. We invest a lot of our personal time on contributing to open source software for free. ;)

pat-s commented 4 years ago

I'd like to see a force umount option - often stuck with the normal umount and force helps :)

(Really like v2.9 - thanks a lot!)

jarun commented 4 years ago

Unfortunately pmount doesn't have a force unmount option. But you can easily have a plugin that takes the device name as input and force unmonts.

jarun commented 4 years ago

@pat-s are you talking about the Unmount shortcut?

pat-s commented 4 years ago

Yes, the one bound to u.

jarun commented 4 years ago

Ok, I'll check what can be done.

jarun commented 4 years ago

@pat-s please search a little and let me know the option for fusermount.

pat-s commented 4 years ago

One can pass mount options via -o to fusermount.

So far I use umount -f <mount point> if I get the message device not configured when failing with the current umount via nnn.

This usually happens when there is a network disconnect and I didn't manually disconnect the drive beforehand.

I sometimes also get

mount_osxfuse: mount point /Users/pjs/.config/nnn/edi is itself on a OSXFUSE volume

when unmounting via nnn.

jarun commented 4 years ago

I tried -o but it seemed it's not having any effect. My problem is I can't repro this.

Try this: when the unmount from nnn fails try fusermount with the required options. Maybe:

fusermount -u -o -f /mount/point

and see if it works. Share the command which works for you.

jarun commented 4 years ago

Also see if fusermount -z /mount/point works.

maximbaz commented 4 years ago

Please don't make any forced unmount by default, normally there is some process blocking the resource and it makes sense to get an error and investigate this manually. Maybe if unmount failed, show prompt "retry with force? y/n" ?

jarun commented 4 years ago

I am thinking of the following workflow:

u -> force? -> if y, force, else don't

@pat-s we can't use umount directly so please don't share umount solutions. I would like to know whatever works with fusermount.

jarun commented 4 years ago

@pat-s I think what we are looking for is fusermount -uz /mount/point.

Can you please confirm?

jarun commented 4 years ago

@pat-s please confirm if the following patch works.

diff --git a/src/nnn.c b/src/nnn.c
index ecf17e1..b69c39b 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -473,8 +473,9 @@ static char * const utils[] = {
 #define MSG_BOOKMARK_KEYS 35
 #define MSG_INVALID_REG 36
 #define MSG_ORDER 37
+#define MSG_LAZY 38
 #ifndef DIR_LIMITED_SELECTION
-#define MSG_DIR_CHANGED 38 /* Must be the last entry */
+#define MSG_DIR_CHANGED 39 /* Must be the last entry */
 #endif

 static const char * const messages[] = {
@@ -516,6 +517,7 @@ static const char * const messages[] = {
        "bookmark keys:",
        "invalid regex",
        "toggle 'a'u / 'd'u / 'e'xtn / 'r'everse / 's'ize / 't'ime / 'v'ersion?",
+       "unmount failed! try lazy?"
 #ifndef DIR_LIMITED_SELECTION
        "dir changed, range sel off", /* Must be the last entry */
 #endif
@@ -3555,8 +3557,15 @@ static bool unmount(char *name, char *newpath, int *presel, char *currentpath)
        }

        if (spawn(cmd, "-u", newpath, NULL, F_NORMAL)) {
-               printwait(messages[MSG_FAILED], presel);
-               return FALSE;
+               int r = get_input(messages[MSG_LAZY]);
+
+               if (r != 'y' && r != 'Y')
+                       return FALSE;
+
+               if (spawn(cmd, "-uz", newpath, NULL, F_NORMAL)) {
+                       printwait(messages[MSG_FAILED], presel);
+                       return FALSE;
+               }
        }

        return TRUE;
pat-s commented 4 years ago

Just found that fusermount does not exist on macOS.

Do you handle os-dependent calls in nnn? Seems one needs to go with umount for macOS. Hence, I can't test the fusermount approach you wrote.

Thanks for tackling this.

jarun commented 4 years ago

Then it's a problem. I think mount requires superuser permissions. Are you able to unmount the directory as a normal user? I'm on Ubuntu and it fails. That's the reason we use fusermount.

jarun commented 4 years ago

Also, please share the following commands:

pat-s commented 4 years ago

Are you able to unmount the directory as a normal user?

umount -f works as a normal user in a normal scenario (mount/umount without network disconnect or other interruptions). I do not get prompted for sudo.

Are you using umount <mount point> for unmounts currently to support macOS? Or how is it done currently?

Looking at the linked issue and the fact that there were no updates since 2017 in sshfs for macOS and the README still talks about fusermount which is not available, I'd say there is only umount on macOS? Not an expert in this field..

Also, please share the following commands:

umount without force/lazy that works in normal cases
umount with force/lazy that works when you are disconnected

Normal cases work fine with nnn.

Can't replicate the other case right now even though I tried. Let me get back to you when it happens the next time? I used sudo lately but just tried umount -f on a normal mount and didn't have any problems.

jarun commented 4 years ago

Are you using umount for unmounts currently to support macOS? Or how is it done currently?

We are using fusermount at the moment and as you mentioned, it is not available on MacOS.

I think we can have a mac-specific handling where we use umount if the regular mount fails.

jarun commented 4 years ago

@pat-s please test the following patch and confirm unmounting works for both remote mounts and mounted archives.

diff --git a/src/nnn.c b/src/nnn.c
index ecf17e1..e38841c 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -473,8 +473,9 @@ static char * const utils[] = {
 #define MSG_BOOKMARK_KEYS 35
 #define MSG_INVALID_REG 36
 #define MSG_ORDER 37
+#define MSG_LAZY 38
 #ifndef DIR_LIMITED_SELECTION
-#define MSG_DIR_CHANGED 38 /* Must be the last entry */
+#define MSG_DIR_CHANGED 39 /* Must be the last entry */
 #endif

 static const char * const messages[] = {
@@ -516,6 +517,7 @@ static const char * const messages[] = {
    "bookmark keys:",
    "invalid regex",
    "toggle 'a'u / 'd'u / 'e'xtn / 'r'everse / 's'ize / 't'ime / 'v'ersion?",
+   "unmount failed! try lazy?"
 #ifndef DIR_LIMITED_SELECTION
    "dir changed, range sel off", /* Must be the last entry */
 #endif
@@ -3518,18 +3520,24 @@ static bool remote_mount(char *newpath, int *presel)
  */
 static bool unmount(char *name, char *newpath, int *presel, char *currentpath)
 {
+#ifdef __APPLE__
+   static char cmd[] = "umount";
+#else
    static char cmd[] = "fusermount3"; /* Arch Linux utility */
    static bool found = FALSE;
+#endif
    char *tmp = name;
    struct stat sb, psb;
    bool child = FALSE;
    bool parent = FALSE;

+#ifndef __APPLE__
    /* On Ubuntu it's fusermount */
    if (!found && !getutil(cmd)) {
        cmd[10] = '\0';
        found = TRUE;
    }
+#endif

    if (tmp && strcmp(cfgdir, currentpath) == 0) {
        mkpath(cfgdir, tmp, newpath);
@@ -3554,9 +3562,24 @@ static bool unmount(char *name, char *newpath, int *presel, char *currentpath)
        return FALSE;
    }

+#ifdef __APPLE__
+   if (spawn(cmd, newpath, NULL, NULL, F_NORMAL)) {
+#else
    if (spawn(cmd, "-u", newpath, NULL, F_NORMAL)) {
-       printwait(messages[MSG_FAILED], presel);
-       return FALSE;
+#endif
+       int r = get_input(messages[MSG_LAZY]);
+
+       if (r != 'y' && r != 'Y')
+           return FALSE;
+
+#ifdef __APPLE__
+       if (spawn(cmd, "-l", newpath, NULL, F_NORMAL)) {
+#else
+       if (spawn(cmd, "-uz", newpath, NULL, F_NORMAL)) {
+#endif
+           printwait(messages[MSG_FAILED], presel);
+           return FALSE;
+       }
    }

    return TRUE;
pat-s commented 4 years ago

Works, even with a conflict I think. I think I spotted a short glimpse of the typical error I got but it was skipped immediately and the unmount worked.

Thanks!!

jarun commented 4 years ago

Thanks for the confirmation!

jarun commented 4 years ago

I am assuming you are used the lazy unmount version of the patch. If not sure, please test master.

jarun commented 4 years ago

Rolled at #448.