mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Use libreadline at command prompt
This commit is contained in:
parent
31849fd5fb
commit
94e4201dc1
2
Makefile
2
Makefile
|
@ -22,7 +22,7 @@ CFLAGS += -Wall -Wextra -Wno-unused-parameter
|
||||||
CFLAGS += $(CFLAGS_OPTIMIZATION)
|
CFLAGS += $(CFLAGS_OPTIMIZATION)
|
||||||
CFLAGS += $(CFLAGS_CURSES)
|
CFLAGS += $(CFLAGS_CURSES)
|
||||||
|
|
||||||
LDLIBS += $(LDLIBS_CURSES)
|
LDLIBS += -lreadline $(LDLIBS_CURSES)
|
||||||
|
|
||||||
DISTFILES = src nnn.1 Makefile README.md LICENSE
|
DISTFILES = src nnn.1 Makefile README.md LICENSE
|
||||||
SRC = src/nnn.c
|
SRC = src/nnn.c
|
||||||
|
|
|
@ -133,7 +133,7 @@ Intrigued? Find out [HOW](https://github.com/jarun/nnn/wiki/performance-factors)
|
||||||
|
|
||||||
#### Dependencies
|
#### 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
|
#### From a package manager
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ Packages for Arch Linux, CentOS, Debian, Fedora, Solus, and Ubuntu are available
|
||||||
|
|
||||||
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):
|
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
|
$ make
|
||||||
$ sudo make install
|
$ sudo make install
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ packages:
|
||||||
- pkg-config
|
- pkg-config
|
||||||
deps:
|
deps:
|
||||||
- ncurses
|
- ncurses
|
||||||
|
- readline
|
||||||
container: "base/archlinux"
|
container: "base/archlinux"
|
||||||
centos7.2:
|
centos7.2:
|
||||||
builddeps:
|
builddeps:
|
||||||
|
@ -21,8 +22,10 @@ packages:
|
||||||
- gcc
|
- gcc
|
||||||
- pkgconfig
|
- pkgconfig
|
||||||
- ncurses-devel
|
- ncurses-devel
|
||||||
|
- readline-devel
|
||||||
deps:
|
deps:
|
||||||
- ncurses
|
- ncurses
|
||||||
|
- readline
|
||||||
commands:
|
commands:
|
||||||
pre:
|
pre:
|
||||||
- yum install epel-release
|
- yum install epel-release
|
||||||
|
@ -32,8 +35,10 @@ packages:
|
||||||
- gcc
|
- gcc
|
||||||
- pkgconfig
|
- pkgconfig
|
||||||
- ncurses-devel
|
- ncurses-devel
|
||||||
|
- readline-devel
|
||||||
deps:
|
deps:
|
||||||
- ncurses
|
- ncurses
|
||||||
|
- readline
|
||||||
commands:
|
commands:
|
||||||
pre:
|
pre:
|
||||||
- yum install epel-release
|
- yum install epel-release
|
||||||
|
@ -43,8 +48,10 @@ packages:
|
||||||
- gcc
|
- gcc
|
||||||
- pkgconfig
|
- pkgconfig
|
||||||
- ncurses-devel
|
- ncurses-devel
|
||||||
|
- readline-devel
|
||||||
deps:
|
deps:
|
||||||
- ncurses
|
- ncurses
|
||||||
|
- readline
|
||||||
commands:
|
commands:
|
||||||
pre:
|
pre:
|
||||||
- yum install epel-release
|
- yum install epel-release
|
||||||
|
@ -54,48 +61,60 @@ packages:
|
||||||
- gcc
|
- gcc
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- libncursesw5-dev
|
- libncursesw5-dev
|
||||||
|
- libreadline-dev
|
||||||
deps:
|
deps:
|
||||||
- libncursesw5
|
- libncursesw5
|
||||||
|
- libreadline-common
|
||||||
fedora25:
|
fedora25:
|
||||||
builddeps:
|
builddeps:
|
||||||
- make
|
- make
|
||||||
- gcc
|
- gcc
|
||||||
- pkgconfig
|
- pkgconfig
|
||||||
- ncurses-devel
|
- ncurses-devel
|
||||||
|
- readline-devel
|
||||||
deps:
|
deps:
|
||||||
- ncurses
|
- ncurses
|
||||||
|
- readline
|
||||||
fedora26:
|
fedora26:
|
||||||
builddeps:
|
builddeps:
|
||||||
- make
|
- make
|
||||||
- gcc
|
- gcc
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- ncurses-devel
|
- ncurses-devel
|
||||||
|
- readline-devel
|
||||||
deps:
|
deps:
|
||||||
- ncurses
|
- ncurses
|
||||||
|
- readline
|
||||||
fedora27:
|
fedora27:
|
||||||
builddeps:
|
builddeps:
|
||||||
- make
|
- make
|
||||||
- gcc
|
- gcc
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- ncurses-devel
|
- ncurses-devel
|
||||||
|
- readline-devel
|
||||||
deps:
|
deps:
|
||||||
- ncurses
|
- ncurses
|
||||||
|
- readline
|
||||||
fedora28:
|
fedora28:
|
||||||
builddeps:
|
builddeps:
|
||||||
- make
|
- make
|
||||||
- gcc
|
- gcc
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- ncurses-devel
|
- ncurses-devel
|
||||||
|
- readline-devel
|
||||||
deps:
|
deps:
|
||||||
- ncurses
|
- ncurses
|
||||||
|
- readline
|
||||||
fedora29:
|
fedora29:
|
||||||
builddeps:
|
builddeps:
|
||||||
- make
|
- make
|
||||||
- gcc
|
- gcc
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- ncurses-devel
|
- ncurses-devel
|
||||||
|
- readline-devel
|
||||||
deps:
|
deps:
|
||||||
- ncurses
|
- ncurses
|
||||||
|
- readline
|
||||||
# opensuse42.3:
|
# opensuse42.3:
|
||||||
# builddeps:
|
# builddeps:
|
||||||
# - make
|
# - make
|
||||||
|
@ -110,13 +129,17 @@ packages:
|
||||||
- gcc
|
- gcc
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- libncursesw5-dev
|
- libncursesw5-dev
|
||||||
|
- libreadline6-dev
|
||||||
deps:
|
deps:
|
||||||
- libncursesw5
|
- libncursesw5
|
||||||
|
- libreadline6
|
||||||
ubuntu18.04:
|
ubuntu18.04:
|
||||||
builddeps:
|
builddeps:
|
||||||
- make
|
- make
|
||||||
- gcc
|
- gcc
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- libncursesw5-dev
|
- libncursesw5-dev
|
||||||
|
- libreadline-dev
|
||||||
deps:
|
deps:
|
||||||
- libncursesw5
|
- libncursesw5
|
||||||
|
- libreadline7
|
||||||
|
|
18
src/nnn.c
18
src/nnn.c
|
@ -78,6 +78,8 @@
|
||||||
#endif
|
#endif
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <readline/history.h>
|
||||||
|
#include <readline/readline.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -3710,9 +3712,14 @@ nochange:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: /* SEL_RUNCMD */
|
default: /* SEL_RUNCMD */
|
||||||
tmp = xreadline(NULL, "> ");
|
exitcurses();
|
||||||
if (tmp && tmp[0])
|
tmp = readline("nnn> ");
|
||||||
|
refresh();
|
||||||
|
if (tmp && tmp[0]) {
|
||||||
spawn(shell, "-c", tmp, path, F_NORMAL | F_SIGINT);
|
spawn(shell, "-c", tmp, path, F_NORMAL | F_SIGINT);
|
||||||
|
add_history(tmp);
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Continue in navigate-as-you-type mode, if enabled */
|
/* Continue in navigate-as-you-type mode, if enabled */
|
||||||
|
@ -4022,6 +4029,11 @@ int main(int argc, char *argv[])
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
crc8init();
|
crc8init();
|
||||||
|
|
||||||
|
/* Bind TAB to cycling */
|
||||||
|
rl_variable_bind("completion-ignore-case", "on");
|
||||||
|
rl_bind_key('\t', rl_menu_complete);
|
||||||
|
read_history(NULL);
|
||||||
|
|
||||||
#ifdef DEBUGMODE
|
#ifdef DEBUGMODE
|
||||||
enabledbg();
|
enabledbg();
|
||||||
#endif
|
#endif
|
||||||
|
@ -4031,6 +4043,8 @@ int main(int argc, char *argv[])
|
||||||
browse(ipath);
|
browse(ipath);
|
||||||
exitcurses();
|
exitcurses();
|
||||||
|
|
||||||
|
write_history(NULL);
|
||||||
|
|
||||||
if (cfg.pickraw) {
|
if (cfg.pickraw) {
|
||||||
if (copybufpos) {
|
if (copybufpos) {
|
||||||
opt = selectiontofd(1);
|
opt = selectiontofd(1);
|
||||||
|
|
Loading…
Reference in a new issue