From ec9d22a3062fa7a4acda70a50059df848474676e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 11 Nov 2016 14:53:20 +0100 Subject: vis: add `:set shell` option --- README.md | 4 ++++ sam.c | 6 ++++++ vis-cmds.c | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/README.md b/README.md index 1c7a694..58533af 100644 --- 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 index 2459fa5..926b056 100644 --- 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 index 16debea..e6ddeb0 100644 --- 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; -- cgit v1.2.3