jarun/nnn

ToDo list

jarun opened this issue ยท 41 comments

jarun commented

Rolled from #1292.

Cooking

  • emoji support for supporting distros and terminals (#1346)
  • open the target directory of symlinked bookmarks (#1353)
  • set bsdtar as the default archive utility
  • enable directory auto-enter during filter operation (-A to disable)
  • enable filter prompt inside the bookmark/plugin dirs
  • add new icon colors for mp4 and flac files
  • use stat -x for file details on *BSD and macOS (#1389)
  • interpret suffix $nnn when paging (#1355)
  • disable key e (edit file) in explorer mode (#1394)
  • .cbcp: more verbose message on paste without a selection
  • plugin preview-tui: scale-up kitty previews
  • plugin preview-tui: account for ueberzug offset
  • plugin autojump: support z.lua

Up for grabs

None open at the time.

For anything else please discuss in this thread.

Contribution guideline.

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

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

nnn/plugins/.cbcp

Lines 24 to 26 in fd998b3

selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
if type xsel >/dev/null 2>&1; then

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

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

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

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

Would it be possible to add Alt+b and Alt+f to 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

No plans for that.

@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

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

Da-Va commented

Tab completion for open with:

jarun commented

Write yourself a small plugin using readline.

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.

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

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.

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

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

#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

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

jarun commented

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

@eNV25 I am ok to set bsdtar as the default. You will need to re-raise the PR. See #1386 (comment).

@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 4baee85 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.

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

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

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

Sure, hadn't seen anyone express interest so I didn't bother yet. Done in #1401.

N-R-K commented

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.

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

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

^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

patch src/nnn.h < key-bindings.diff
patch src/nnn.c < help-menu.diff

Compile

sudo make strip install
jarun commented

@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.

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

jarun commented

Yes, please!

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

Please let us know when you are done.

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

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

@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...

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

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.

Yes. The only requirement is export XDG_CURRENT_DESKTOP=i3

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