commit 21404dd923e07a36badce6c253d4577164b803cd from: Omar Polo date: Thu Jul 15 15:14:28 2021 UTC load alternate config file per-TERM commit - ccc5591f8c57a70bbfce32f4a52c7bebd5e1bf92 commit + 21404dd923e07a36badce6c253d4577164b803cd blob - 08545bc91c7d00e23cbeb6ac8f535c60c7b1cbbf blob + 2c5fc537453d4a1eee73f043fd3b57c933ad8bb4 --- ChangeLog +++ ChangeLog @@ -1,5 +1,7 @@ 2021-07-15 Omar Polo + * parse.y (parseconfig): load alternate config file per-TERM + * telescope.c (main): added long options --help, --version and -C/--colors * defaults.h: add hide-pre-closing-line blob - 31f1b5fae40868d242254fc489b0eb708d611910 blob + 820ae40b332cf15d2358df06dd40e483fb3341d4 --- parse.y +++ parse.y @@ -63,6 +63,7 @@ static int attrname(char *); static void setattr(char *, char *, char *); static void add_proxy(char *, char *); static void bindkey(const char *, const char *, const char *); +static void do_parseconfig(const char *, int); %} @@ -526,8 +527,8 @@ bindkey(const char *map, const char *key, const char * yyerror("failed to bind %s %s %s", map, key, cmd); } -void -parseconfig(const char *filename, int fonf) +static void +do_parseconfig(const char *filename, int fonf) { if ((yyfp = fopen(filename, "r")) == NULL) { if (fonf) @@ -541,3 +542,23 @@ parseconfig(const char *filename, int fonf) if (parse_errors) exit(1); } + +void +parseconfig(const char *filename, int fonf) +{ + char altconf[PATH_MAX], *term; + + /* load the given config file */ + do_parseconfig(filename, fonf); + + /* then try to load file-TERM */ + + if ((term = getenv("TERM")) == NULL) + return; + + strlcpy(altconf, filename, sizeof(altconf)); + strlcat(altconf, "-", sizeof(altconf)); + strlcat(altconf, term, sizeof(altconf)); + + do_parseconfig(altconf, 0); +} blob - 425c2efedaa20c040b31f1e62c523f5b06dc0990 blob + 0cef6741dc87c8e1059e0e190c924c947a173e35 --- telescope.1 +++ telescope.1 @@ -523,6 +523,15 @@ or the one given with the .Fl c flag. .Pp +.Nm +will also load a file called +.Pa config-TERM , +where +.Dq TERM +is the name of the terminal type +.Pq i.e. the TERM variable , +if available. +.Pp The format of the configuration file is fairly flexible. The current line can be extended over multiple ones using a backslash