1
1
mirror of https://github.com/jarun/nnn.git synced 2024-09-22 02:18:04 +03:00
nnn/config.def.h
Martin Kühl d1ed0cff11 Support commands specified by environment variables
Specifying commands by name in config.h means that
every time one switches ones editor (for example),
one has to modify every config.h file referencing that editor
and then recompile every corresponding program.

This change adds a string `env` for specifying an environment
variable to `struct key` and uses it to optionally specify the
command to run on SEL_{RUN,RUNARG}.
The `run` string is used as a fallback when the environment variable
has not been specified or is not set.
It also updates `config.def.h` to demonstrate this new capability.
2015-11-26 13:37:03 +00:00

71 lines
1.9 KiB
C

/* See LICENSE file for copyright and license details. */
#define CWD "cwd: "
#define CURSR " > "
#define EMPTY " "
int mtimeorder = 0; /* Set to 1 to sort by time in the default case */
int idletimeout = 0; /* Screensaver timeout in seconds, 0 to disable */
char *idlecmd = "rain"; /* The screensaver program */
struct assoc assocs[] = {
{ "\\.(avi|mp4|mkv|mp3|ogg|flac|mov)$", "mplayer" },
{ "\\.(png|jpg|gif)$", "feh" },
{ "\\.(html|svg)$", "firefox" },
{ "\\.pdf$", "mupdf" },
{ "\\.sh$", "sh" },
{ ".", "less" },
};
struct key bindings[] = {
/* Quit */
{ 'q', SEL_QUIT },
/* Back */
{ KEY_BACKSPACE, SEL_BACK },
{ KEY_LEFT, SEL_BACK },
{ 'h', SEL_BACK },
{ CONTROL('H'), SEL_BACK },
/* Inside */
{ KEY_ENTER, SEL_GOIN },
{ '\r', SEL_GOIN },
{ KEY_RIGHT, SEL_GOIN },
{ 'l', SEL_GOIN },
/* Filter */
{ '/', SEL_FLTR },
{ '&', SEL_FLTR },
/* Filter as you type */
{ '?', SEL_TYPE },
/* Next */
{ 'j', SEL_NEXT },
{ KEY_DOWN, SEL_NEXT },
{ CONTROL('N'), SEL_NEXT },
/* Previous */
{ 'k', SEL_PREV },
{ KEY_UP, SEL_PREV },
{ CONTROL('P'), SEL_PREV },
/* Page down */
{ KEY_NPAGE, SEL_PGDN },
{ CONTROL('D'), SEL_PGDN },
/* Page up */
{ KEY_PPAGE, SEL_PGUP },
{ CONTROL('U'), SEL_PGUP },
/* Home */
{ KEY_HOME, SEL_HOME },
{ CONTROL('A'), SEL_HOME },
{ '^', SEL_HOME },
/* End */
{ KEY_END, SEL_END },
{ CONTROL('E'), SEL_END },
{ '$', SEL_END },
/* Change dir */
{ 'c', SEL_CD },
/* Toggle sort by time */
{ 't', SEL_MTIME },
{ CONTROL('L'), SEL_REDRAW },
/* Run command */
{ 'z', SEL_RUN, "top" },
{ '!', SEL_RUN, "sh", "SHELL" },
/* Run command with argument */
{ 'e', SEL_RUNARG, "vi", "EDITOR" },
{ 'p', SEL_RUNARG, "less", "PAGER" },
};