jarun / nnn

nĀ³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
18.96k stars 756 forks source link

ToDo list #1348

Closed jarun closed 2 years ago

jarun commented 2 years ago

Rolled from #1292.

Cooking

Up for grabs

None open at the time.

For anything else please discuss in this thread.

Contribution guideline.

PatrickF1 commented 2 years ago

Hi, would you be open to a patch for .cbcp plugin to use the hovered file ($nnn) if there is no selection (nnn/.selection or $NNN_SEL does not exist or is blank)? I noticed that after not using this plugin for a while, I forgot I needed to select the file and was perplexed why it was not selecting the file until I quit and was met with a slightly cryptic error message.

jarun commented 2 years ago

The standard mechanism to copy and paste is to select and paste. Please feel free to patch it locally for yourself. However, this change cannot be a generic one.

N-R-K commented 2 years ago

https://github.com/jarun/nnn/blob/fd998b3045fbc8ef3a97d2f55a80781725f76919/plugins/.cbcp#L24-L26

Adding a guard here to see if "$selection" exists or not seems like a good idea. Something like [ -s "$selection" ] || exit 1.

PatrickF1 commented 2 years ago

Sure I can patch that in. But the issue for the end user is they won't even get an error message leading them back to why their copy selection command didn't work.

N-R-K commented 2 years ago

How about this then? Or are we talking about something else?

[ -s "$selection" ] || { echo "selection file not found" >&2 ; exit 1; }
PatrickF1 commented 2 years ago

https://github.com/jarun/nnn/pull/1351

dnbz commented 2 years ago

Would it be possible to add Alt+b and Alt+fto move back/forward a word in the prompt? Most shells, dmenu and others implement this. It would also be reasonable to do the same with arrow keys like Ctrl+Left/Right.

jarun commented 2 years ago

No plans for that.

luukvbaal commented 2 years ago

@jarun since you seem to have changed your stance on the bookmark dir not being a special directory, I was wondering whether you would like to reconsider entering Type-To-Nav mode. Again, the merit being fewer keystrokes when accessing bookmarks.

With your latest commits something like the following diff is needed to enter TTN automatically when pressing b, while remembering the previous TTN state upon selecting a bookmark:

@@ -367,12 +367,12 @@ typedef struct {
        uint_t rangesel   : 1;  /* Range selection on */
        uint_t runctx     : 3;  /* The context in which plugin is to be run */
        uint_t runplugin  : 1;  /* Choose plugin mode */
-       uint_t selbm      : 1;  /* Select a bookmark from bookmarks directory */
+       uint_t selbm      : 2;  /* Select a bookmark from bookmarks directory */
        uint_t selmode    : 1;  /* Set when selecting files */
        uint_t stayonsel  : 1;  /* Disable auto-jump on select */
        uint_t trash      : 2;  /* Trash method 0: rm -rf, 1: trash-cli, 2: gio trash */
        uint_t uidgid     : 1;  /* Show owner and group info */
-       uint_t reserved   : 6;  /* Adjust when adding/removing a field */
+       uint_t reserved   : 5;  /* Adjust when adding/removing a field */
 } runstate;

 /* Contexts or workspaces */
@@ -4988,7 +4988,8 @@ static size_t handle_bookmark(const char *bmark, char *newpath)
                bmark ? xstrsncpy(newpath, bmark, PATH_MAX) : (r = MSG_NOT_SET);
        else if (fd == '\r') { /* Visit bookmarks directory */
                mkpath(cfgpath, toks[TOK_BM], newpath);
-               g_state.selbm = 1;
+               g_state.selbm = cfg.filtermode + 1;
+               cfg.filtermode = 1;
        } else if (!get_kv_val(bookmark, newpath, fd, maxbm, NNN_BMS))
                r = MSG_INVALID_KEY;

@@ -6905,6 +6906,7 @@ nochange:
                        /* Cannot descend in empty directories */
                        if (!ndents) {
                                cd = FALSE;
+                               cfg.filtermode = g_state.selbm - 1;
                                g_state.selbm = g_state.runplugin = 0;
                                goto begin;
                        }
@@ -6916,6 +6918,7 @@ nochange:
                                S_ISLNK(pent->mode)
                                        ? (realpath(pent->name, newpath) && xstrsncpy(path, lastdir, PATH_MAX))
                                        : mkpath(path, pent->name, newpath);
+                               cfg.filtermode = g_state.selbm - 1;
                                g_state.selbm = 0;
                        } else
                                mkpath(path, pent->name, newpath);
jarun commented 2 years ago

Since it comes cheap, please raise the PR. ;)

Da-Va commented 2 years ago

Tab completion for open with:

jarun commented 2 years ago

Write yourself a small plugin using readline.

amosbird commented 2 years ago

Is there a way to build a xdg-desktop-portal adaptor for nnn? I'd like to use it as a file picker for telegram-desktop.

luukvbaal commented 2 years ago

You can check if the instructions for browser integration apply to your usecase.

amosbird commented 2 years ago

You can check if the instructions for browser integration apply to your usecase.

I already have that configuration applied and it works as expected for chromium, but not for tdesktop.

luukvbaal commented 2 years ago

I guess the way chromium determines the file picker is not standardized then. No idea how telegram does it sorry.

eugene-bright commented 2 years ago

Tab completion for open with:

I vote for autocompletion too (it should work in bash-like manner: the search for prefix among executables from PATH).

eNV25 commented 2 years ago

1392

1386

Also, if you have so much against atool, why are you even installing atool? Not having it would use bsdtar as fallback. I think it's too trivial an issue to spend so much time on. And unfortunately I do not have any time to spend on these discussions.

Please do NOT raise any further issue/PR on the atool/bsdtar issue without discussing in the ToDO list. If devs think it's interesting enough they would respond. You can always choose to have your own fork and have the changes there.

@jarun I opened an issue about archive support afterwards. But I can't find it now. Did you delete it?

It wasn't just about functional differences between atool and bsdtar. There are other issues as well, like how atool doesn't support zstd or iso, but archivemount and bsdtar does.

In Arch Linux atool is installed because it's part of base-devel group.

My branch that fixes these issues for me is in. https://github.com/eNV25/nnn/tree/libarchive

eNV25 commented 2 years ago

Now that I think about it the real problem is that archive handling is currently hard-coded and not configurable.

jarun commented 2 years ago

Did you delete it?

Yes. I don't have the time to spend on mundane issues that can be patched easily and discuss the same topic in different flavours at different places.

In Arch Linux atool is installed because it's part of base-devel group.

Good. Convince Arch guys how bad a tool it is and get it removed from that package. Get it replaced by bsdtar.

Now that I think about it the real problem is that archive handling is currently hard-coded and not configurable.

We don't spoon-feed our users. We expect them to be able to make minor patches to their convenience and compile and install nnn from source.

Personal inconveniences due to archive handling is not the end of the world for me. There can only be one way to code it (I am not interested in adding a program option for this) - prioritize either atool or bsdtar. bsdtar didn't suit my needs on Ubuntu. I have never used zstd in my life.

jarun commented 2 years ago

@eNV25 I am ok to set bsdtar as the default. You will need to re-raise the PR. See https://github.com/jarun/nnn/pull/1386#issuecomment-1152822146.

ggustafsson commented 2 years ago

@luukvbaal That type-to-nav patch looks pretty nice! The whole point is to get away from there as soon as possible anyways šŸ‘ Just a heads up though... If you make a PR out of it then reverse https://github.com/jarun/nnn/commit/4baee859f8763ed0ca3703ac3e5ab0d291149aed too. Also there is a corner case issue. If you for some reason got to the bookmarks directory through other means than pressing b then pressing it again will flip filtermode on next directory change. Ideally nothing should be changed unless pressing b leads to directory change.

luukvbaal commented 2 years ago

A PR was made and merged, then later reverted in https://github.com/jarun/nnn/pull/1374... I use the patch locally as I greatly prefer the UX it provides.

ggustafsson commented 2 years ago

A PR was made and merged, then later reverted in #1374... I use the patch locally as I greatly prefer the UX it provides.

Oh ok! Both ways makes sense in different ways I guess. Good thing everyone can pick & patch as they please šŸ™‚

jarun commented 2 years ago

@luukvbaal it's significant change. Why not add to the patch framework?

luukvbaal commented 2 years ago

Sure, hadn't seen anyone express interest so I didn't bother yet. Done in https://github.com/jarun/nnn/pull/1401.

N-R-K commented 2 years ago

Wanted to mention that the recent changes in bookmark dir UX (resolving symlinks, auto enabling filter) are really good.

I've been using local (and hacky) patches for them for a while now, good to see these behaviors getting merged upstream.

ggustafsson commented 2 years ago

I 100% agree with @N-R-K. Very nice!

anjerukare commented 2 years ago

Hello! I want to share my diff files with custom key bindings for Colemak-DH users.

Here is archive with key bindings and help menu: colemak-dh-patches.tar.gz

Summary of changes

New key bindings
Navigation ``` m Parent n Down e Up i Open ``` ``` ^E Top ^N End ``` Files ``` v-v Select range/clear c Create new/link j Edit File ``` Other ``` h Connect remote ^F Toggle type-to-nav ```
Deleted key bindings
These key bindings had to be sacrificed ```diff ^F File stats # Use 'f' instead v Move here # Use '^V' instead ```

How to patch

Instruction
Extract diff files and execute commands in root nnn directory (nnn-[version]/)
Apply patches ```bash patch src/nnn.h < key-bindings.diff patch src/nnn.c < help-menu.diff ``` Compile ```bash sudo make strip install ```
jarun commented 2 years ago

@luukvbaal can you please have a look? Several users asked for Colemak through years. Since I don't have any device with it, I didn't have any option.

luukvbaal commented 2 years ago

I have no opinion on the mappings but I could add it to the patch framework if that's what you meant.

jarun commented 2 years ago

Yes, please!

anjerukare commented 2 years ago

That would be great. But I think my key bindings need some polishing.

I've been using Nnn for literally two days. I wish these key bindings were as elaborate as the standard ones.

jarun commented 2 years ago

Please let us know when you are done.

luukvbaal commented 2 years ago

Is there a way to build a xdg-desktop-portal adaptor for nnn? I'd like to use it as a file picker for telegram-desktop.

Seems you can use xdg-desktop-portal-termfilechooser to this end. I tried it out and got it working. I'll try to update the wiki soon. It works for firefox at least, haven't tried telegram.

jarun commented 2 years ago

@anjerukare you can also refer to this project: https://gitlab.com/Queer_Bird/nnn-colemak

luukvbaal commented 2 years ago

@amosbird it seems the xdg-desktop-portal implementation in telegram-desktop contains some hardcoding against known DEs.

So while xdg-desktop-portal-termfilechooser allows you to set the filechooser for firefox which also uses the xdg-desktop-portal specification, it doesn't seem to work for telegram-desktop...

amosbird commented 2 years ago

@luukvbaal Thanks! It works as expected : export XDG_CURRENT_DESKTOP=i3

luukvbaal commented 2 years ago

Are you saying you got it working in telegram-desktop as well? What exactly is required for that, doesn't seem to work for me.

amosbird commented 2 years ago

Yes. The only requirement is export XDG_CURRENT_DESKTOP=i3

luukvbaal commented 2 years ago

I see, when I downgrade telegram-desktop it works for me as well. I guess you're not on the latest version.