aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-11-11 14:53:20 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-11-11 15:00:34 +0100
commitec9d22a3062fa7a4acda70a50059df848474676e (patch)
treef4da47b1301bf85abf88467f960c4a38efec7c6d
parentb54f81925ef1dac55ad075e1b8b72e608aab269f (diff)
downloadvis-ec9d22a3062fa7a4acda70a50059df848474676e.tar.gz
vis-ec9d22a3062fa7a4acda70a50059df848474676e.tar.xz
vis: add `:set shell` option
-rw-r--r--README.md4
-rw-r--r--sam.c6
-rw-r--r--vis-cmds.c11
3 files changed, 21 insertions, 0 deletions
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;