Introduction
Introduction Statistics Contact Development Disclaimer Help
tadded -e and -t option. - st - [fork] customized build of st, the simple termi…
git clone git://src.adamsgaard.dk/st
Log
Files
Refs
README
LICENSE
---
commit 9d82bdd94708fa2daabc0b53f8b71bca2a3c6f0a
parent 97695baf4f9bc3632792a3330fb46e188ef166a2
Author: AurĂ©lien Aptel <[email protected]>
Date: Thu, 2 Sep 2010 01:37:01 +0200
added -e and -t option.
Diffstat:
M st.c | 36 ++++++++++++++++++++++++-----…
1 file changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/st.c b/st.c
t@@ -28,6 +28,10 @@
#include <libutil.h>
#endif
+#define USAGE \
+ "st-" VERSION ", (c) 2010 st engineers\n" \
+ "usage: st [-t title] [-e cmd] [-v]\n"
+
/* Arbitrary sizes */
#define ESC_TITLE_SIZ 256
#define ESC_BUF_SIZ 256
t@@ -210,6 +214,8 @@ static CSIEscape escseq;
static int cmdfd;
static pid_t pid;
static Selection sel;
+static char *opt_cmd = NULL;
+static char *opt_title = NULL;
void
selinit(void) {
t@@ -329,9 +335,12 @@ die(const char *errstr, ...) {
void
execsh(void) {
- char *args[3] = {getenv("SHELL"), "-i", NULL};
- DEFAULT(args[0], SHELL); /* if getenv() failed */
- putenv("TERM=" TNAME);
+ char *args[] = {getenv("SHELL"), "-i", NULL};
+ if(opt_cmd)
+ args[0] = opt_cmd, args[1] = NULL;
+ else
+ DEFAULT(args[0], SHELL);
+ putenv("TERM="TNAME);
execvp(args[0], args);
}
t@@ -1189,7 +1198,7 @@ xinit(void) {
XMapWindow(xw.dis, xw.win);
xhints();
- XStoreName(xw.dis, xw.win, "st");
+ XStoreName(xw.dis, xw.win, opt_title ? opt_title : "st");
XSync(xw.dis, 0);
}
t@@ -1429,10 +1438,21 @@ run(void) {
int
main(int argc, char *argv[]) {
- if(argc == 2 && !strncmp("-v", argv[1], 3))
- die("st-" VERSION ", (c) 2010 st engineers\n");
- else if(argc != 1)
- die("usage: st [-v]\n");
+ int i;
+
+ for(i = 1; i < argc; i++) {
+ switch(argv[i][0] != '-' || argv[i][2] ? -1 : argv[i][1]) {
+ case 't':
+ if(++i < argc) opt_title = argv[i];
+ break;
+ case 'e':
+ if(++i < argc) opt_cmd = argv[i];
+ break;
+ case 'v':
+ default:
+ die(USAGE);
+ }
+ }
setlocale(LC_CTYPE, "");
tnew(80, 24);
ttynew();
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.