mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 03:41:27 +00:00
Options -e and -t
Replaces the following environment variables: - NNN_USE_EDITOR - NNN_IDLE_TIMEOUT
This commit is contained in:
parent
94a233b808
commit
64667b377d
|
@ -86,10 +86,10 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/watch?v=AbaauM7gUJw
|
||||||
|
|
||||||
1. Install the [utilities you may need](https://github.com/jarun/nnn#utility-dependencies) based on your regular workflows.
|
1. Install the [utilities you may need](https://github.com/jarun/nnn#utility-dependencies) based on your regular workflows.
|
||||||
2. Configure [cd on quit](https://github.com/jarun/nnn/wiki/Basic-use-cases#configure-cd-on-quit).
|
2. Configure [cd on quit](https://github.com/jarun/nnn/wiki/Basic-use-cases#configure-cd-on-quit).
|
||||||
3. Optionally open all text files in `$VISUAL` (else `$EDITOR`, fallback vi): `export NNN_USE_EDITOR=1`.
|
3. To open text files in `$VISUAL` (else `$EDITOR`, fallback vi) add program option `-e` in your alias.
|
||||||
4. For additional functionality [install plugins](https://github.com/jarun/nnn/tree/master/plugins#installing-plugins).
|
4. For additional functionality [install plugins](https://github.com/jarun/nnn/tree/master/plugins#installing-plugins).
|
||||||
5. To copy selected file paths to system clipboard and show notis on cp, mv, rm completion use option `-x`.
|
5. To copy selected file paths to system clipboard and show notis on cp, mv, rm completion use option `-x`.
|
||||||
6. For a strictly CLI environment, see plugin `nuke`. It's a sample opener you can customize.
|
6. For a strictly CLI environment, customize and use plugin [`nuke`](https://github.com/jarun/nnn/blob/master/plugins/nuke).
|
||||||
|
|
||||||
Don't memorize! Arrows (or <kbd>h</kbd> <kbd>j</kbd> <kbd>k</kbd> <kbd>l</kbd>), <kbd>/</kbd>, <kbd>q</kbd> suffice. <kbd>Tab</kbd> creates, cycles contexts. <kbd>?</kbd> lists shortcuts.
|
Don't memorize! Arrows (or <kbd>h</kbd> <kbd>j</kbd> <kbd>k</kbd> <kbd>l</kbd>), <kbd>/</kbd>, <kbd>q</kbd> suffice. <kbd>Tab</kbd> creates, cycles contexts. <kbd>?</kbd> lists shortcuts.
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ _nnn ()
|
||||||
-b
|
-b
|
||||||
-c
|
-c
|
||||||
-d
|
-d
|
||||||
|
-e
|
||||||
-E
|
-E
|
||||||
-g
|
-g
|
||||||
-H
|
-H
|
||||||
|
@ -29,6 +30,7 @@ _nnn ()
|
||||||
-R
|
-R
|
||||||
-s
|
-s
|
||||||
-S
|
-S
|
||||||
|
-t
|
||||||
-v
|
-v
|
||||||
-V
|
-V
|
||||||
-x
|
-x
|
||||||
|
@ -42,6 +44,8 @@ _nnn ()
|
||||||
elif [[ $prev == -s ]]; then
|
elif [[ $prev == -s ]]; then
|
||||||
local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
|
local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
|
||||||
COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
|
COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
|
||||||
|
elif [[ $prev == -t ]]; then
|
||||||
|
return 1
|
||||||
elif [[ $cur == -* ]]; then
|
elif [[ $cur == -* ]]; then
|
||||||
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
|
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
|
||||||
else
|
else
|
||||||
|
|
|
@ -16,6 +16,7 @@ complete -c nnn -s A -d 'disable dir auto-select'
|
||||||
complete -c nnn -s b -r -d 'bookmark key to open' -x -a '(echo $NNN_BMS | awk -F: -v RS=\; \'{print $1"\t"$2}\')'
|
complete -c nnn -s b -r -d 'bookmark key to open' -x -a '(echo $NNN_BMS | awk -F: -v RS=\; \'{print $1"\t"$2}\')'
|
||||||
complete -c nnn -s c -d 'cli-only opener'
|
complete -c nnn -s c -d 'cli-only opener'
|
||||||
complete -c nnn -s d -d 'start in detail mode'
|
complete -c nnn -s d -d 'start in detail mode'
|
||||||
|
complete -c nnn -s e -d 'open text files in $VISUAL/$EDITOR/vi'
|
||||||
complete -c nnn -s E -d 'use EDITOR for undetached edits'
|
complete -c nnn -s E -d 'use EDITOR for undetached edits'
|
||||||
complete -c nnn -s g -d 'regex filters'
|
complete -c nnn -s g -d 'regex filters'
|
||||||
complete -c nnn -s H -d 'show hidden files'
|
complete -c nnn -s H -d 'show hidden files'
|
||||||
|
@ -28,6 +29,7 @@ complete -c nnn -s r -d 'show cp, mv progress (Linux-only)'
|
||||||
complete -c nnn -s R -d 'disable rollover at edges'
|
complete -c nnn -s R -d 'disable rollover at edges'
|
||||||
complete -c nnn -s s -r -d 'load session by name' -x -a '@\t"last session" (ls $sessions_dir)'
|
complete -c nnn -s s -r -d 'load session by name' -x -a '@\t"last session" (ls $sessions_dir)'
|
||||||
complete -c nnn -s S -d 'start in disk usage analyzer mode'
|
complete -c nnn -s S -d 'start in disk usage analyzer mode'
|
||||||
|
complete -c nnn -s t -r -d 'timeout in seconds to lock'
|
||||||
complete -c nnn -s v -d 'use version compare to sort files'
|
complete -c nnn -s v -d 'use version compare to sort files'
|
||||||
complete -c nnn -s V -d 'show program version and exit'
|
complete -c nnn -s V -d 'show program version and exit'
|
||||||
complete -c nnn -s x -d 'notis, sel to system clipboard'
|
complete -c nnn -s x -d 'notis, sel to system clipboard'
|
||||||
|
|
|
@ -14,6 +14,7 @@ args=(
|
||||||
'(-b)-b[bookmark key to open]:key char'
|
'(-b)-b[bookmark key to open]:key char'
|
||||||
'(-c)-c[cli-only opener]'
|
'(-c)-c[cli-only opener]'
|
||||||
'(-d)-d[start in detail mode]'
|
'(-d)-d[start in detail mode]'
|
||||||
|
'(-e)-e[open text files in $VISUAL/$EDITOR/vi]'
|
||||||
'(-E)-E[use EDITOR for undetached edits]'
|
'(-E)-E[use EDITOR for undetached edits]'
|
||||||
'(-g)-g[regex filters]'
|
'(-g)-g[regex filters]'
|
||||||
'(-H)-H[show hidden files]'
|
'(-H)-H[show hidden files]'
|
||||||
|
@ -26,6 +27,7 @@ args=(
|
||||||
'(-R)-R[disable rollover at edges]'
|
'(-R)-R[disable rollover at edges]'
|
||||||
'(-s)-s[load session]:session name'
|
'(-s)-s[load session]:session name'
|
||||||
'(-S)-S[start in disk usage analyzer mode]'
|
'(-S)-S[start in disk usage analyzer mode]'
|
||||||
|
'(-t)-t[timeout to lock]:seconds'
|
||||||
'(-v)-v[use version compare to sort files]'
|
'(-v)-v[use version compare to sort files]'
|
||||||
'(-V)-V[show program version and exit]'
|
'(-V)-V[show program version and exit]'
|
||||||
'(-x)-x[notis, sel to system clipboard]'
|
'(-x)-x[notis, sel to system clipboard]'
|
||||||
|
|
24
nnn.1
24
nnn.1
|
@ -11,6 +11,7 @@
|
||||||
.Op Ar -b key
|
.Op Ar -b key
|
||||||
.Op Ar -c
|
.Op Ar -c
|
||||||
.Op Ar -d
|
.Op Ar -d
|
||||||
|
.Op Ar -e
|
||||||
.Op Ar -E
|
.Op Ar -E
|
||||||
.Op Ar -g
|
.Op Ar -g
|
||||||
.Op Ar -H
|
.Op Ar -H
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
.Op Ar -R
|
.Op Ar -R
|
||||||
.Op Ar -s name
|
.Op Ar -s name
|
||||||
.Op Ar -S
|
.Op Ar -S
|
||||||
|
.Op Ar -t secs
|
||||||
.Op Ar -v
|
.Op Ar -v
|
||||||
.Op Ar -V
|
.Op Ar -V
|
||||||
.Op Ar -x
|
.Op Ar -x
|
||||||
|
@ -60,11 +62,14 @@ supports the following options:
|
||||||
specify bookmark key to open
|
specify bookmark key to open
|
||||||
.Pp
|
.Pp
|
||||||
.Fl c
|
.Fl c
|
||||||
opener opens files in cli utilities only
|
opener opens files in cli utilities only (overrides -e)
|
||||||
.Pp
|
.Pp
|
||||||
.Fl d
|
.Fl d
|
||||||
detail mode
|
detail mode
|
||||||
.Pp
|
.Pp
|
||||||
|
.Fl e
|
||||||
|
open text files in $VISUAL (else $EDITOR, fallback vi) [preferably CLI]
|
||||||
|
.Pp
|
||||||
.Fl E
|
.Fl E
|
||||||
use $EDITOR for internal undetached edits
|
use $EDITOR for internal undetached edits
|
||||||
.Pp
|
.Pp
|
||||||
|
@ -102,6 +107,9 @@ supports the following options:
|
||||||
.Fl S
|
.Fl S
|
||||||
start in disk usage analyzer mode
|
start in disk usage analyzer mode
|
||||||
.Pp
|
.Pp
|
||||||
|
.Fl "t secs"
|
||||||
|
idle timeout in seconds to lock terminal
|
||||||
|
.Pp
|
||||||
.Fl v
|
.Fl v
|
||||||
use case-insensitive version compare to sort files
|
use case-insensitive version compare to sort files
|
||||||
.Pp
|
.Pp
|
||||||
|
@ -229,9 +237,8 @@ to list the selection file.
|
||||||
The minimum file size unit is byte (B). The rest are K, M, G, T, P, E, Z, Y
|
The minimum file size unit is byte (B). The rest are K, M, G, T, P, E, Z, Y
|
||||||
(powers of 1024), same as the default units in \fIls\fR.
|
(powers of 1024), same as the default units in \fIls\fR.
|
||||||
.Sh ENVIRONMENT
|
.Sh ENVIRONMENT
|
||||||
The SHELL, EDITOR (VISUAL, if defined) and PAGER environment variables take
|
The SHELL, EDITOR (VISUAL, if defined) and PAGER environment variables are
|
||||||
precedence when dealing with the !, e and p commands respectively. A single
|
used. A single combination of arguments is supported for SHELL and PAGER.
|
||||||
combination to arguments is supported for SHELL and PAGER.
|
|
||||||
.Pp
|
.Pp
|
||||||
\fBNNN_OPENER:\fR specify a custom file opener.
|
\fBNNN_OPENER:\fR specify a custom file opener.
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
|
@ -291,12 +298,6 @@ combination to arguments is supported for SHELL and PAGER.
|
||||||
----------------------------------- + -------------------------------------------------
|
----------------------------------- + -------------------------------------------------
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
\fBNNN_USE_EDITOR:\fR use VISUAL (else EDITOR, preferably CLI, fallback vi)
|
|
||||||
to handle text files.
|
|
||||||
.Bd -literal
|
|
||||||
export NNN_USE_EDITOR=1
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
\fBNNN_CONTEXT_COLORS:\fR string of color codes for each context, e.g.:
|
\fBNNN_CONTEXT_COLORS:\fR string of color codes for each context, e.g.:
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
export NNN_CONTEXT_COLORS='1234'
|
export NNN_CONTEXT_COLORS='1234'
|
||||||
|
@ -318,9 +319,6 @@ to handle text files.
|
||||||
NOTE: The options must be preceded by `rclone` and max 5 flags are supported.
|
NOTE: The options must be preceded by `rclone` and max 5 flags are supported.
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
\fBNNN_IDLE_TIMEOUT:\fR set idle timeout (in seconds) to invoke terminal locker
|
|
||||||
(default: disabled).
|
|
||||||
.Pp
|
|
||||||
\fBNNN_TRASH:\fR trash (instead of \fIdelete\fR) files to desktop Trash.
|
\fBNNN_TRASH:\fR trash (instead of \fIdelete\fR) files to desktop Trash.
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
export NNN_TRASH=1
|
export NNN_TRASH=1
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# # export NNN_OPENER=nuke
|
# # export NNN_OPENER=nuke
|
||||||
# 2. Run nnn with the program option to indicate a CLI opener
|
# 2. Run nnn with the program option to indicate a CLI opener
|
||||||
# nnn -c
|
# nnn -c
|
||||||
# # The -c program option overrides config `NNN_USE_EDITOR`
|
# # The -c program option overrides option -e
|
||||||
# 3. nuke can use nnn plugins (e.g. mocplay is used for audio), $PATH is updated.
|
# 3. nuke can use nnn plugins (e.g. mocplay is used for audio), $PATH is updated.
|
||||||
#
|
#
|
||||||
# Details:
|
# Details:
|
||||||
|
|
35
src/nnn.c
35
src/nnn.c
|
@ -521,22 +521,18 @@ static const char * const messages[] = {
|
||||||
#define NNN_BMS 0
|
#define NNN_BMS 0
|
||||||
#define NNN_OPENER 1
|
#define NNN_OPENER 1
|
||||||
#define NNN_CONTEXT_COLORS 2
|
#define NNN_CONTEXT_COLORS 2
|
||||||
#define NNN_IDLE_TIMEOUT 3
|
#define NNNLVL 3
|
||||||
#define NNNLVL 4
|
#define NNN_PIPE 4
|
||||||
#define NNN_PIPE 5
|
#define NNN_ARCHIVE 5 /* strings end here */
|
||||||
#define NNN_ARCHIVE 6 /* strings end here */
|
#define NNN_TRASH 6 /* flags begin here */
|
||||||
#define NNN_USE_EDITOR 7 /* flags begin here */
|
|
||||||
#define NNN_TRASH 8
|
|
||||||
|
|
||||||
static const char * const env_cfg[] = {
|
static const char * const env_cfg[] = {
|
||||||
"NNN_BMS",
|
"NNN_BMS",
|
||||||
"NNN_OPENER",
|
"NNN_OPENER",
|
||||||
"NNN_CONTEXT_COLORS",
|
"NNN_CONTEXT_COLORS",
|
||||||
"NNN_IDLE_TIMEOUT",
|
|
||||||
"NNNLVL",
|
"NNNLVL",
|
||||||
"NNN_PIPE",
|
"NNN_PIPE",
|
||||||
"NNN_ARCHIVE",
|
"NNN_ARCHIVE",
|
||||||
"NNN_USE_EDITOR",
|
|
||||||
"NNN_TRASH",
|
"NNN_TRASH",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4772,7 +4768,6 @@ nochange:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If NNN_USE_EDITOR is set, open text in EDITOR */
|
|
||||||
if (cfg.useeditor && (!sb.st_size ||
|
if (cfg.useeditor && (!sb.st_size ||
|
||||||
#ifdef FILE_MIME_OPTS
|
#ifdef FILE_MIME_OPTS
|
||||||
(get_output(g_buf, CMD_LEN_MAX, "file", FILE_MIME_OPTS, newpath, FALSE)
|
(get_output(g_buf, CMD_LEN_MAX, "file", FILE_MIME_OPTS, newpath, FALSE)
|
||||||
|
@ -5739,8 +5734,9 @@ static void usage(void)
|
||||||
" -a use access time\n"
|
" -a use access time\n"
|
||||||
" -A no dir auto-select\n"
|
" -A no dir auto-select\n"
|
||||||
" -b key open bookmark key\n"
|
" -b key open bookmark key\n"
|
||||||
" -c cli-only opener\n"
|
" -c cli-only opener (overrides -e)\n"
|
||||||
" -d detail mode\n"
|
" -d detail mode\n"
|
||||||
|
" -e text in $VISUAL ($EDITOR/vi)\n"
|
||||||
" -E use EDITOR for undetached edits\n"
|
" -E use EDITOR for undetached edits\n"
|
||||||
" -g regex filters [default: string]\n"
|
" -g regex filters [default: string]\n"
|
||||||
" -H show hidden files\n"
|
" -H show hidden files\n"
|
||||||
|
@ -5753,6 +5749,7 @@ static void usage(void)
|
||||||
" -R no rollover at edges\n"
|
" -R no rollover at edges\n"
|
||||||
" -s name load session by name\n"
|
" -s name load session by name\n"
|
||||||
" -S du mode\n"
|
" -S du mode\n"
|
||||||
|
" -t secs timeout to lock\n"
|
||||||
" -v version sort\n"
|
" -v version sort\n"
|
||||||
" -V show version\n"
|
" -V show version\n"
|
||||||
" -x notis, sel to system clipboard\n"
|
" -x notis, sel to system clipboard\n"
|
||||||
|
@ -5903,7 +5900,7 @@ int main(int argc, char *argv[])
|
||||||
bool progress = FALSE;
|
bool progress = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "HSKaAb:cdEgnop:QrRs:vVxh")) != -1) {
|
while ((opt = getopt(argc, argv, "HSKaAb:cdeEgnop:QrRs:t:vVxh")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'S':
|
case 'S':
|
||||||
cfg.blkorder = 1;
|
cfg.blkorder = 1;
|
||||||
|
@ -5925,6 +5922,9 @@ int main(int argc, char *argv[])
|
||||||
case 'c':
|
case 'c':
|
||||||
cfg.cliopener = 1;
|
cfg.cliopener = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
cfg.useeditor = 1;
|
||||||
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
cfg.waitedit = 1;
|
cfg.waitedit = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -5972,6 +5972,9 @@ int main(int argc, char *argv[])
|
||||||
case 's':
|
case 's':
|
||||||
session = optarg;
|
session = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
idletimeout = xatoi(optarg);
|
||||||
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
check_key_collision();
|
check_key_collision();
|
||||||
return _SUCCESS;
|
return _SUCCESS;
|
||||||
|
@ -6080,9 +6083,9 @@ int main(int argc, char *argv[])
|
||||||
return _FAILURE;
|
return _FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Edit text in EDITOR if opted (and opener is not all-CLI) */
|
/* An all-CLI opener overrides option -e) */
|
||||||
if (!cfg.cliopener && xgetenv_set(env_cfg[NNN_USE_EDITOR]))
|
if (cfg.cliopener)
|
||||||
cfg.useeditor = 1;
|
cfg.useeditor = 0;
|
||||||
|
|
||||||
/* Get VISUAL/EDITOR */
|
/* Get VISUAL/EDITOR */
|
||||||
enveditor = xgetenv(envs[ENV_EDITOR], utils[UTIL_VI]);
|
enveditor = xgetenv(envs[ENV_EDITOR], utils[UTIL_VI]);
|
||||||
|
@ -6125,10 +6128,6 @@ int main(int argc, char *argv[])
|
||||||
/* Set nnn nesting level */
|
/* Set nnn nesting level */
|
||||||
setenv(env_cfg[NNNLVL], xitoa(xatoi(getenv(env_cfg[NNNLVL])) + 1), 1);
|
setenv(env_cfg[NNNLVL], xitoa(xatoi(getenv(env_cfg[NNNLVL])) + 1), 1);
|
||||||
|
|
||||||
/* Get locker wait time, if set */
|
|
||||||
idletimeout = xatoi(getenv(env_cfg[NNN_IDLE_TIMEOUT]));
|
|
||||||
DPRINTF_U(idletimeout);
|
|
||||||
|
|
||||||
if (xgetenv_set(env_cfg[NNN_TRASH]))
|
if (xgetenv_set(env_cfg[NNN_TRASH]))
|
||||||
cfg.trash = 1;
|
cfg.trash = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue