aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tmux.120
-rw-r--r--tmux.c18
2 files changed, 29 insertions, 9 deletions
diff --git a/tmux.1 b/tmux.1
index d93185cd..569a7edc 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1,4 +1,4 @@
-.\" $Id: tmux.1,v 1.272 2010-12-06 21:55:42 nicm Exp $
+.\" $Id: tmux.1,v 1.273 2010-12-06 21:59:42 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 14 2010 $
+.Dd $Mdocdate: November 29 2010 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -1852,7 +1852,12 @@ or right justified.
.Xc
Use vi or emacs-style
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
Display
.Ar string
@@ -2140,7 +2145,14 @@ Set window modes foreground colour.
.Op Ic vi | emacs
.Xc
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
.It Xo Ic mode-mouse
.Op Ic on | off
diff --git a/tmux.c b/tmux.c
index a2908537..c4677d2e 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.222 2010-12-06 21:53:00 nicm Exp $ */
+/* $Id: tmux.c,v 1.223 2010-12-06 21:59:42 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -234,13 +234,13 @@ main(int argc, char **argv)
struct options *oo, *so, *wo;
struct keylist *keylist;
char *s, *path, *label, *home, **var;
- int opt, flags, quiet = 0;
+ int opt, flags, quiet, keys;
#if defined(DEBUG) && defined(__OpenBSD__)
malloc_options = (char *) "AFGJPX";
#endif
- flags = 0;
+ quiet = flags = 0;
label = path = NULL;
login_shell = (**argv == '-');
while ((opt = getopt(argc, argv, "28c:df:lL:qS:uUv")) != -1) {
@@ -362,7 +362,6 @@ main(int argc, char **argv)
options_set_number(so, "status-fg", 0);
options_set_number(so, "status-interval", 15);
options_set_number(so, "status-justify", 0);
- options_set_number(so, "status-keys", MODEKEY_EMACS);
options_set_string(so, "status-left", "[#S]");
options_set_number(so, "status-left-attr", 0);
options_set_number(so, "status-left-bg", 8);
@@ -403,7 +402,6 @@ main(int argc, char **argv)
options_set_number(wo, "mode-attr", 0);
options_set_number(wo, "mode-bg", 3);
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, "monitor-activity", 0);
options_set_string(wo, "monitor-content", "%s", "");
@@ -431,6 +429,16 @@ main(int argc, char **argv)
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. */
if (cfg_file == NULL) {
home = getenv("HOME");