-
-
Notifications
You must be signed in to change notification settings - Fork 770
Developer guides
- Run tests with generated
outdir
files - Update program options and help in Wiki, if required
- Update auto-completion scripts, if required
- Update
VERSION
in source - Update the
app_version
section withinmisc/haiku/nnn.rdef
. - Also, change the
variety
fromB_APPV_DEVELOPMENT
toB_APPV_FINAL
. - Update date in man page
- Review list of auto-generated packages
- Update
CHANGELOG
- Create signed tag and push to GitHub
- Run
make O_NOUG=1 upload-local
(requireslibgpm-dev
,upx
,jq
) to upload source package signature and static binary - Create a GitHub release and populate the release notes from
CHANGELOG
- Revert the
variety
back toB_APPV_DEVELOPMENT
in/misc/haiku/nnn.rdef
- Notify downstream package maintainers
The sources tarball is signed with PGP key, which you can verify as following:
$ gpg --verify nnn-<VERSION>.tar.gz.sig nnn-<VERSION>.tar.gz
gpg: Signature made ...
gpg: using RSA key BBAD0B2F3093A7C3377A8F6BA75979F35C080412
gpg: Good signature from "Arun Prakash Jana <...>"
Primary key fingerprint: BBAD 0B2F 3093 A7C3 377A 8F6B A759 79F3 5C08 0412
nnn
provides several make variables to customize the features to include or exclude. This also helps in reducing the binary size further.
POSIX regex is the default. To enable PCRE, install the PCRE development library and set O_PCRE
.
On Ubuntu 18.04:
sudo apt install libpcre3-dev
make O_PCRE=1
On macOS:
brew install pcre # if you're using Homebrew
sudo port install pcre # if you're using MacPorts
make O_PCRE=1
make O_NORL=1
make O_NOMOUSE=1
make O_NOBATCH=1
Use it if you have plugin .nmv
(bash script).
make O_NOFIFO=1
make O_NOSSN=1
make O_NOUG=1
Storing and decoding user and group info adds significantly to resident memory usage.
make O_ICONS=1
More details here. This variable is not compatible with O_NERD=1
, O_EMOJI=1
and O_NOLC=1
.
make O_NERD=1
More details here. This variable is not compatible with O_ICONS=1
, O_EMOJI=1
and O_NOLC=1
.
make O_EMOJI=1
More details here. This variable is not compatible with O_ICONS=1
, O_NERD=1
and O_NOLC=1
.
make O_NOLC=1
Unsupported characters in file names will be replaced by ?
. Operations on files work seamlessly.
make O_NOX11=1
Disable notifications on cp
, mv
, rm
completion, selection sync to system clipboard and xterm title advertisement on directory change.
make O_QSORT=1
make O_CTX8=1
Warning: Saved sessions may no longer be usable when the number of contexts is switched.
make O_MATCHFLTR=1
Discard filter key when there's no match.
make O_NOSORT=1
This option is useful in type-to-nav mode. Loads dirs faster on initial entry. Any filter sorts the listing. Usable with xterm 256 colors only.
Install the GPM development library and set the Makefile variable O_STATIC
.
On Ubuntu 16.04/18.04:
sudo apt install libgpm-dev
make O_STATIC=1 strip
On macOS: It's not possible to compile with -static
on macOS at the moment. So please ignore this option if you're on macOS.
This option will not work on Mac OS X unless all libraries (including libgcc.a) have also been compiled with -static. Since neither a static version of libSystem.dylib nor crt0.o are provided, this option is not useful to most people.
Verify the binary.
file nnn
nnn: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=1be54d27687f83cf42393dd59dba2723798956de, stripped
Careful use of make variables, static compilation and upx compression can do wonders!
$ make CFLAGS+=-march=native O_NORL=1 O_NOMOUSE=1 O_NOLC=1 O_NOBATCH=1 O_NOSSN=1 O_NOFIFO=1 O_QSORT=1 O_NOUG=1 static
$ upx nnn-static
$ ls -l nnn-static
-rwxrwxr-x 1 user user 593808 Nov 2 00:45 nnn-static
# top output (/usr/bin has 1544 files)
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
31953 user 20 0 2428 2244 4 S 0.0 0.0 0:00.02 ./nnn-static -cdDEnQrux /usr/bin
On macos the default system ncurses library is too old and can cause issues (see https://github.com/jarun/nnn/issues/1703).
Install a more up to date version from homebrew and link against it via adding the library path to $LDLIBS
$ LDLIBS="-L/opt/homebrew/opt/ncurses/lib/" make
The nnn
version available as a stable Raspbian package is very out of date (v2.2), which means that the only way to get a recent version of nnn
is to compile from source.
As an example, to compile nnn
v3.5 for a Raspberry Pi running Raspbian Buster, get nnn-v3.5.tar.gz
from the release assets, put the tarball file on the Pi, and then do the following:
sudo apt install pkg-config libncursesw5-dev libreadline-dev
tar -zxvf nnn-v3.5.tar.gz
cd nnn-3.5
sudo make strip install
The above was tested on a Raspberry Pi Zero W running Buster and worked with no problems.
Install plugins and use the program option -x
.
See jarun/nnn#1200.
In this example we will compile nnn
on Ubuntu 20.04 with
- netbsd-curses
- musl-fts
- musl libc
- pcre (optional)
Discussion thread.
See this patch to save some more on terminfo
.
Compilation script for Ubuntu closely following this procedure.
sudo apt install musl musl-dev musl-tools
git clone https://github.com/sabotage-linux/netbsd-curses
cd netbsd-curses
git checkout v0.3.2
make CC=musl-gcc CFLAGS="-O3 -Wall -fPIC" -j$(($(nproc)+1)) all
sudo mkdir /opt/nnn-libs
sudo cp libcurses/libcurses.so libterminfo/libterminfo.so /opt/nnn-libs/
make clean
make CC=musl-gcc CFLAGS=-O3 LDFLAGS=-static all-static
sudo cp libcurses/libcurses.a libterminfo/libterminfo.a /opt/nnn-libs/
git clone https://github.com/void-linux/musl-fts --depth=1
cd musl-fts
./bootstrap.sh
./configure
make CC=musl-gcc CFLAGS=-O3 LDFLAGS=-static -j$(($(nproc)+1))
sudo cp .libs/libfts.a /opt/nnn-libs/
make clean
make CC=musl-gcc CFLAGS=-O3 -j$(($(nproc)+1))
sudo cp .libs/libfts.so.0.0.0 /opt/nnn-libs/libfts.so
wget https://downloads.sourceforge.net/pcre/pcre-8.45.tar.bz2
./configure --enable-unicode-properties --enable-pcre16 --enable-pcre32
make CFLAGS=-O3 CC=musl-gcc LDFLAGS=-static
sudo cp .libs/libpcre.a /opt/nnn-libs
make CFLAGS=-O3 CC=musl-gcc
sudo cp .libs/libpcre.so.1.2.13 /opt/nnn-libs
# shared
musl-gcc -O3 -DNORL -DNOMOUSE -std=c11 -Wall -Wextra -Wshadow -I/path_to/netbsd-curses/libcurses -I/path_to/musl-fts -o nnn src/nnn.c -Wl,-Bsymbolic-functions -lpthread -L/opt/nnn-libs -lcurses -lterminfo -lfts
# shared custom
musl-gcc -O3 -DNORL -DNOLC -DNOMOUSE -DNOBATCH -DNOFIFO -DTOURBIN_QSORT -DNOSSN -DNOUG -DNOX11 -std=c11 -Wall -Wextra -Wshadow -I/path_to/netbsd-curses/libcurses -I/path_to/musl-fts -o nnn src/nnn.c -Wl,-Bsymbolic-functions -lpthread -L/opt/nnn-libs -lcurses -lterminfo -lfts
# Note 1: For static compilation append `-static` to the above commands
# Note 2: To enable pcre, add `-I./pcre-8.45` and `-lpcre`
# strip the binary
strip nnn
# For shared lib
export LD_LIBRARY_PATH=/opt/nnn-libs:$LD_LIBRARY_PATH
# ./nnn
This section applies to Linux as host, Android on arm64 target and an xterm-256color terminal.
We are going to link statically against libreadline and libncursesw so we won't need to install them separately on the phone.
For anything else, please adjust accordingly.
- Download ncurses
- Download readline
- Extract ncurses and readline
- Setup Android's NDK and make sure you
export
all the necessary variables for GNU Autoconf. -
export ANDROID_ENV
to be the location where we install our cross-compiled dependencies
-
cd
into ncurses' directory -
configure
./configure --enable-widec --enable-termcap --with-fallbacks=xterm-256color --disable-stripping --host=aarch64-linux-android --prefix=$ANDROID_ENV
-
make and install
make && make install
-
cd
into readline's directory -
configure
./configure --enable-multibyte --with-curses --disable-shared --host=aarch64-linux-android --prefix=$ANDROID_ENV
-
make and install
make && make install
-
cd
into nnn's directory export CFLAGS="$CFLAGS -I$ANDROID_ENV/include/ncursesw -I$ANDROID_ENV/include"
export LDFLAGS="$LDFLAGS -L$ANDROID_ENV/lib"
- run
make
file nnn
should yield something like:
nnn: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, not stripped
Move the binary to your phone and run with your favourite terminal emulator!
To debug nnn
compile the program in debug mode:
make O_DEBUG=1
The run the generated binary:
./nnn
In debug mode nnn
generates additional debug information which is logged in the file nnndbg
located (by priority) at:
/tmp/nnndbg or,
the directory in which nnn is run
To log extra information, use the DPRINTF_*
functions.
- The nnn magic!
- Add bookmarks
- Configure cd on quit
- Sync subshell
$PWD
- Hot-plugged drives
- Image, video, pdf
- Detached text
- Run commands
- Launch applications
- Open as root
- File picker
- Remote mounts
- Synced quick notes
- Drag and drop
- Duplicate file
- Create batch links
- Hidden files on top
- Disable bold fonts
- Themes
- Live previews
- File icons
- Custom keybinds
- CLI-only opener
- Desktop integration
- cp mv progress
- Control active dir
- Termux tips
- Pager as opener
- Working with lftp
- Power toys