mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-27 02:23:15 +01:00
If VISUAL or EDITOR contains "vi", configure mode-keys and status-keys
to vi. Based on a diff from martynas@, previously requested by a couple of other people.
This commit is contained in:
parent
ef9b2eb566
commit
ebd0eb4fb4
16
tmux.1
16
tmux.1
@ -1852,7 +1852,12 @@ or right justified.
|
|||||||
.Xc
|
.Xc
|
||||||
Use vi or emacs-style
|
Use vi or emacs-style
|
||||||
key bindings in the status line, for example at the command prompt.
|
key bindings in the status line, for example at the command prompt.
|
||||||
Defaults to emacs.
|
The default is emacs, unless the
|
||||||
|
.Ev VISUAL
|
||||||
|
or
|
||||||
|
.Ev EDITOR
|
||||||
|
environment variables are set and contain the string
|
||||||
|
.Ql vi .
|
||||||
.It Ic status-left Ar string
|
.It Ic status-left Ar string
|
||||||
Display
|
Display
|
||||||
.Ar string
|
.Ar string
|
||||||
@ -2140,7 +2145,14 @@ Set window modes foreground colour.
|
|||||||
.Op Ic vi | emacs
|
.Op Ic vi | emacs
|
||||||
.Xc
|
.Xc
|
||||||
Use vi or emacs-style key bindings in copy and choice modes.
|
Use vi or emacs-style key bindings in copy and choice modes.
|
||||||
Key bindings default to emacs.
|
As with the
|
||||||
|
.Ic status-keys
|
||||||
|
option, the default is emacs, unless
|
||||||
|
.Ev VISUAL
|
||||||
|
or
|
||||||
|
.Ev EDITOR
|
||||||
|
contains
|
||||||
|
.Ql vi .
|
||||||
.Pp
|
.Pp
|
||||||
.It Xo Ic mode-mouse
|
.It Xo Ic mode-mouse
|
||||||
.Op Ic on | off
|
.Op Ic on | off
|
||||||
|
16
tmux.c
16
tmux.c
@ -231,13 +231,13 @@ main(int argc, char **argv)
|
|||||||
struct options *oo, *so, *wo;
|
struct options *oo, *so, *wo;
|
||||||
struct keylist *keylist;
|
struct keylist *keylist;
|
||||||
char *s, *path, *label, *home, **var;
|
char *s, *path, *label, *home, **var;
|
||||||
int opt, flags, quiet = 0;
|
int opt, flags, quiet, keys;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
malloc_options = (char *) "AFGJPX";
|
malloc_options = (char *) "AFGJPX";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
flags = 0;
|
quiet = flags = 0;
|
||||||
label = path = NULL;
|
label = path = NULL;
|
||||||
login_shell = (**argv == '-');
|
login_shell = (**argv == '-');
|
||||||
while ((opt = getopt(argc, argv, "28c:df:lL:qS:uUv")) != -1) {
|
while ((opt = getopt(argc, argv, "28c:df:lL:qS:uUv")) != -1) {
|
||||||
@ -359,7 +359,6 @@ main(int argc, char **argv)
|
|||||||
options_set_number(so, "status-fg", 0);
|
options_set_number(so, "status-fg", 0);
|
||||||
options_set_number(so, "status-interval", 15);
|
options_set_number(so, "status-interval", 15);
|
||||||
options_set_number(so, "status-justify", 0);
|
options_set_number(so, "status-justify", 0);
|
||||||
options_set_number(so, "status-keys", MODEKEY_EMACS);
|
|
||||||
options_set_string(so, "status-left", "[#S]");
|
options_set_string(so, "status-left", "[#S]");
|
||||||
options_set_number(so, "status-left-attr", 0);
|
options_set_number(so, "status-left-attr", 0);
|
||||||
options_set_number(so, "status-left-bg", 8);
|
options_set_number(so, "status-left-bg", 8);
|
||||||
@ -400,7 +399,6 @@ main(int argc, char **argv)
|
|||||||
options_set_number(wo, "mode-attr", 0);
|
options_set_number(wo, "mode-attr", 0);
|
||||||
options_set_number(wo, "mode-bg", 3);
|
options_set_number(wo, "mode-bg", 3);
|
||||||
options_set_number(wo, "mode-fg", 0);
|
options_set_number(wo, "mode-fg", 0);
|
||||||
options_set_number(wo, "mode-keys", MODEKEY_EMACS);
|
|
||||||
options_set_number(wo, "mode-mouse", 0);
|
options_set_number(wo, "mode-mouse", 0);
|
||||||
options_set_number(wo, "monitor-activity", 0);
|
options_set_number(wo, "monitor-activity", 0);
|
||||||
options_set_string(wo, "monitor-content", "%s", "");
|
options_set_string(wo, "monitor-content", "%s", "");
|
||||||
@ -428,6 +426,16 @@ main(int argc, char **argv)
|
|||||||
options_set_number(wo, "utf8", 0);
|
options_set_number(wo, "utf8", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keys = MODEKEY_EMACS;
|
||||||
|
if ((s = getenv("VISUAL")) != NULL || (s = getenv("EDITOR")) != NULL) {
|
||||||
|
if (strrchr(s, '/') != NULL)
|
||||||
|
s = strrchr(s, '/') + 1;
|
||||||
|
if (strstr(s, "vi") != NULL)
|
||||||
|
keys = MODEKEY_VI;
|
||||||
|
}
|
||||||
|
options_set_number(so, "status-keys", keys);
|
||||||
|
options_set_number(wo, "mode-keys", keys);
|
||||||
|
|
||||||
/* Locate the configuration file. */
|
/* Locate the configuration file. */
|
||||||
if (cfg_file == NULL) {
|
if (cfg_file == NULL) {
|
||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
|
Loading…
Reference in New Issue
Block a user