1
1
mirror of https://github.com/jarun/nnn.git synced 2024-11-22 06:35:55 +03:00
63 Troubleshooting
Arun edited this page 2024-05-05 22:28:06 +05:30

Wrong file opener

If your text files are opening in the browser, check out the program option -e.

Use the following command to set default applications for mimetypes when using xdg-open as opener:

xdg-mime default application mimetype(s)
e.g.
xdg-mime default sxiv.desktop image/jpeg image/png

If your system uses mimeopen, you may have to install perl-file-mimeinfo.

More on default applications and openers.

Broken file names

If unicode characters are not showing correctly, please check the following:

Tmux configuration

Keyboard

nnn may not handle keypresses correctly when used with tmux (see issue #104 for more details). Set TERM=xterm-256color to address it.

By default tmux advertises 8-color support. To show icons in tmux add the following to tmux configuration file:

set -g default-terminal "screen-256color"

If compiled with netbsd-curses set it to:

set -g default-terminal "xterm-256color"

If the Esc key isn't working as expected, add the following in .tmux.conf:

set -g escape-time 0

To start nnn within tmux use a shell function:

n ()
{
    if [ -n "$TMUX" ]; then
        nnn -a $@
    else
        tmux -u new-session nnn -a $@
    fi
}

New window/pane using cwd

nnn does not set the terminal's cwd while navigating. So the following may not work:

tmux new-window -c "#{pane_current_path}"

One possible workaround is to extract the path from the cwd command that nnn uses:

lsof -c nnn | grep cwd

To get the path on the last executed cwd command:

lsof -w -c nnn | grep cwd | tail -n 1 | awk '{print $9}'

A script exampletmux_split_curdir.sh:

#!/usr/bin/env sh

cwd=
cc=$(tmux display -p '#{pane_current_command}')
if [ $cc == "nnn" ] ; then
   cwd=$(lsof -w -c nnn | grep cwd | tail -n 1 | awk '{print $9}')
else
   cwd=$(tmux display -p '#{pane_current_path}')
fi

tmux split-window -c "$cwd"

Adding this script to your tmux path allows it to be run with run-shell:

bind -n KEYS run-shell "tmux_split_curdir.sh"

Broken control key

If a Ctrl-key combination is not working, check if it's masked due to terminal line settings:

stty -a

If that's the case, clear (undef) the setting. E.g.:

stty start undef
stty stop undef
stty lwrap undef
stty lnext undef

You can do this when starting nnn. See the quitcd scripts.

Help not showing

If your PAGER is less, remove the option -F (automatically exit if the entire file can be displayed on the first screen). There are other screens which use less as well.

Note that the less command takes its default parameters from the $LESS environment variable, so you may need to remove -F from your shell initialization.

Default batch rename limits

TL;DR: If you need a full-featured batch-renamer, install plugins. nnn auto-detects and invokes the internal plugin .nmv (a bash script) which is feature-complete.

The in-built batch-renamer implemented in nnn is a very simplified one. It's single-pass - reads the name/path of files iteratively (from a list of source files) and renames/moves them (as specified in the corresponding line number in a list of renamed/destination files). It doesn't handle deletions or perform any pre-parsing to account for rename loops, swaps, replaces, etc.

Note that the instance of the editor must wait for the editing to complete and the changes to be saved (e.g. use -w with VSCode).

Misaligned size column

We have seen this issue with WSL and Putty where sometimes repeated space characters are not printed correctly.

To fix this:

export TERM=rxvt-unicode
// OR
export TERM=rxvt-unicode-256color

Detailed explanation.

Can't list within list

List view is a temporary view of symlinks. To avoid remembering the temporary paths to all listed views the current path is removed when the next list is loaded. This is also inline with the fact that find doesn't look within symlinks to directories. If you need to search the entries within a loaded list, visit the original directory and run the refined search.

BSD terminal issue

TL;DR: On releases previous to v2.7, use the keybind K to toggle selection if you are having issues with ^Y.

On OpenBSD & FreeBSD (and probably on macOS as well) stty maps ^Y to DSUSP by default. This means that typing ^Y will suspend nnn as if you typed ^Z (you can bring nnn back to the foreground by issuing fg) instead of entering multi-selection mode. You can check this with stty -a. If it includes the text dsusp = ^Y, issuing stty dsusp undef will disable this DSUSP and let nnn receive the ^Y instead.

Amethyst WM

There's a known issue with Amethyst window manager on macOS - redraws do not work correctly and the screen breaks. See issue #521 for more details.

Running inside docker containers

When run inside docker container nnn exits instantly. The solution is to create the container with the flag --init.

Icons not working properly

Ensure that the primary font of your terminal is set to a suitable one (e.g when using O_NERD, primary font should be a nerd font). Also ensure that your system's locale is set up properly.

When using ST some icons may appear truncated. A patch fixing this issue is available in a reddit thread here.

Wrong/Bad sorting order (#1652)

nnn respects the environmental LC_COLLATE value - the effect of this depends on your libc. Try setting it to something standard/well-supported such as "C" or "C.UTF8" and see if that fixes the issue or not.