CFLAGS += $(CFLAGS_OPTIMIZATION)
CFLAGS += $(CFLAGS_CURSES)
-LDLIBS += $(LDLIBS_CURSES)
+LDLIBS += -lreadline $(LDLIBS_CURSES)
DISTFILES = src nnn.1 Makefile README.md LICENSE
SRC = src/nnn.c
#### Dependencies
-`nnn` needs a curses library with wide character support (like ncursesw) and standard libc.
+`nnn` needs a curses library with wide character support (like ncursesw), libreadline and standard libc.
#### From a package manager
To cook yourself, download the [latest stable release](https://github.com/jarun/nnn/releases/latest) or clone this repository (*risky*). Then install the dependencies and compile (e.g. on Ubuntu 16.04):
- $ sudo apt-get install pkg-config libncursesw5-dev
+ $ sudo apt-get install pkg-config libncursesw5-dev libreadline6-dev
$ make
$ sudo make install
- pkg-config
deps:
- ncurses
+ - readline
container: "base/archlinux"
centos7.2:
builddeps:
- gcc
- pkgconfig
- ncurses-devel
+ - readline-devel
deps:
- ncurses
+ - readline
commands:
pre:
- yum install epel-release
- gcc
- pkgconfig
- ncurses-devel
+ - readline-devel
deps:
- ncurses
+ - readline
commands:
pre:
- yum install epel-release
- gcc
- pkgconfig
- ncurses-devel
+ - readline-devel
deps:
- ncurses
+ - readline
commands:
pre:
- yum install epel-release
- gcc
- pkg-config
- libncursesw5-dev
+ - libreadline-dev
deps:
- libncursesw5
+ - libreadline-common
fedora25:
builddeps:
- make
- gcc
- pkgconfig
- ncurses-devel
+ - readline-devel
deps:
- ncurses
+ - readline
fedora26:
builddeps:
- make
- gcc
- pkg-config
- ncurses-devel
+ - readline-devel
deps:
- ncurses
+ - readline
fedora27:
builddeps:
- make
- gcc
- pkg-config
- ncurses-devel
+ - readline-devel
deps:
- ncurses
+ - readline
fedora28:
builddeps:
- make
- gcc
- pkg-config
- ncurses-devel
+ - readline-devel
deps:
- ncurses
+ - readline
fedora29:
builddeps:
- make
- gcc
- pkg-config
- ncurses-devel
+ - readline-devel
deps:
- ncurses
+ - readline
# opensuse42.3:
# builddeps:
# - make
- gcc
- pkg-config
- libncursesw5-dev
+ - libreadline6-dev
deps:
- libncursesw5
+ - libreadline6
ubuntu18.04:
builddeps:
- make
- gcc
- pkg-config
- libncursesw5-dev
+ - libreadline-dev
deps:
- libncursesw5
+ - libreadline7
#endif
#include <locale.h>
#include <pwd.h>
+#include <readline/history.h>
+#include <readline/readline.h>
#include <regex.h>
#include <signal.h>
#include <stdarg.h>
}
break;
default: /* SEL_RUNCMD */
- tmp = xreadline(NULL, "> ");
- if (tmp && tmp[0])
+ exitcurses();
+ tmp = readline("nnn> ");
+ refresh();
+ if (tmp && tmp[0]) {
spawn(shell, "-c", tmp, path, F_NORMAL | F_SIGINT);
+ add_history(tmp);
+ free(tmp);
+ }
}
/* Continue in navigate-as-you-type mode, if enabled */
setlocale(LC_ALL, "");
crc8init();
+ /* Bind TAB to cycling */
+ rl_variable_bind("completion-ignore-case", "on");
+ rl_bind_key('\t', rl_menu_complete);
+ read_history(NULL);
+
#ifdef DEBUGMODE
enabledbg();
#endif
browse(ipath);
exitcurses();
+ write_history(NULL);
+
if (cfg.pickraw) {
if (copybufpos) {
opt = selectiontofd(1);