vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit fe613e57557dbfc1b2fe68276059e2299372f275
parent d2083a6ec4a1b57fe45a42b69c23e5088054878c
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri, 11 Nov 2016 14:53:20 +0100

vis: add `:set shell` option

Diffstat:
MREADME.md | 4++++
Msam.c | 6++++++
Mvis-cmds.c | 11+++++++++++
3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -404,6 +404,10 @@ Operators can be forced to work line wise by specifying `V`. :wq write changes then close window :w write current buffer content to file + shell path default $SHELL, /etc/passwd, /bin/sh + + set shell to use for external commands (e.g. <, >, |) + tabwidth [1-8] default 8 set display width of a tab and number of spaces to use if diff --git a/sam.c b/sam.c @@ -197,6 +197,7 @@ typedef struct { } OptionDef; enum { + OPTION_SHELL, OPTION_AUTOINDENT, OPTION_EXPANDTAB, OPTION_TABWIDTH, @@ -213,6 +214,11 @@ enum { }; static const OptionDef options[] = { + [OPTION_SHELL] = { + { "shell" }, + OPTION_TYPE_STRING, OPTION_FLAG_NONE, + "Shell to use for external commands (default: $SHELL, /etc/passwd, /bin/sh)", + }, [OPTION_AUTOINDENT] = { { "autoindent", "ai" }, OPTION_TYPE_BOOL, OPTION_FLAG_NONE, diff --git a/vis-cmds.c b/vis-cmds.c @@ -150,6 +150,17 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor size_t opt_index = opt - options; switch (opt_index) { + case OPTION_SHELL: + { + char *shell = strdup(arg.s); + if (!shell) { + vis_info_show(vis, "Failed to change shell"); + return false; + } + free(vis->shell); + vis->shell = shell; + break; + } case OPTION_EXPANDTAB: vis->expandtab = arg.b; break;