Allow specification of alternate samrcs via SAMRC. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 3f2c8e96b3233b85916aaca81d4f414a8e90887f
(DIR) parent 94871df993984b49dcb7037968bbd5277a7268f9
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Fri, 23 Sep 2016 21:29:23 -0500
Allow specification of alternate samrcs via SAMRC.
Diffstat:
doc/sam.1 | 8 ++++++++
samterm/main.c | 6 +++++-
2 files changed, 13 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/doc/sam.1 b/doc/sam.1
@@ -1052,6 +1052,14 @@ e.g.
Any additional arguments should be passed to the command on the remote machine.
By default, this is the string
.Dq "ssh" "."
+.It Ev SAMRC
+If set,
+provides the name of the
+.Xr samrc 5
+file to read at startup.
+By default,
+this is
+.Pa ${HOME}/.samrc "."
.It Ev TABS
A number between 1 and 12, indicating the width of a tab character.
This number is treated as a multiplier of the width of the '0' character.
(DIR) diff --git a/samterm/main.c b/samterm/main.c
@@ -51,7 +51,11 @@ main(int argc, char *argv[])
installdefaultbindings();
installdefaultchords();
- snprintf(rcpath, PATH_MAX, "%s/.samrc", getenv("HOME") ? getenv("HOME") : ".");
+ if (getenv("SAMRC"))
+ strncpy(rcpath, getenv("SAMRC"), PATH_MAX);
+ else
+ snprintf(rcpath, PATH_MAX, "%s/.samrc", getenv("HOME") ? getenv("HOME") : ".");
+
rc = fopen(rcpath, "r");
if (rc){
loadrcfile(rc);