aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--st.16
-rw-r--r--st.c14
2 files changed, 19 insertions, 1 deletions
diff --git a/st.1 b/st.1
index b6c119f..931b481 100644
--- a/st.1
+++ b/st.1
@@ -10,6 +10,8 @@ st \- simple terminal
10.RB [ \-w 10.RB [ \-w
11.IR windowid ] 11.IR windowid ]
12.RB [ \-v ] 12.RB [ \-v ]
13.RB [ \-f
14.IR file ]
13.RB [ \-e 15.RB [ \-e
14.IR command ...] 16.IR command ...]
15.SH DESCRIPTION 17.SH DESCRIPTION
@@ -30,6 +32,10 @@ embeds st within the window identified by
30.B \-v 32.B \-v
31prints version information to stderr, then exits. 33prints version information to stderr, then exits.
32.TP 34.TP
35.BI \-f " file"
36writes all the I/O to
37.I file
38.TP
33.BI \-e " program " [ " arguments " "... ]" 39.BI \-e " program " [ " arguments " "... ]"
34st executes 40st executes
35.I program 41.I program
diff --git a/st.c b/st.c
index bd230a3..fde0493 100644
--- a/st.c
+++ b/st.c
@@ -36,7 +36,7 @@
36 36
37#define USAGE \ 37#define USAGE \
38 "st " VERSION " (c) 2010-2012 st engineers\n" \ 38 "st " VERSION " (c) 2010-2012 st engineers\n" \
39 "usage: st [-t title] [-c class] [-w windowid] [-v] [-e command...]\n" 39 "usage: st [-t title] [-c class] [-w windowid] [-v] [-f file] [-e command...]\n"
40 40
41/* XEMBED messages */ 41/* XEMBED messages */
42#define XEMBED_FOCUS_IN 4 42#define XEMBED_FOCUS_IN 4
@@ -342,7 +342,9 @@ static STREscape strescseq;
342static int cmdfd; 342static int cmdfd;
343static pid_t pid; 343static pid_t pid;
344static Selection sel; 344static Selection sel;
345static FILE *fileio;
345static char **opt_cmd = NULL; 346static char **opt_cmd = NULL;
347static char *opt_io = NULL;
346static char *opt_title = NULL; 348static char *opt_title = NULL;
347static char *opt_embed = NULL; 349static char *opt_embed = NULL;
348static char *opt_class = NULL; 350static char *opt_class = NULL;
@@ -776,6 +778,10 @@ ttynew(void) {
776 close(s); 778 close(s);
777 cmdfd = m; 779 cmdfd = m;
778 signal(SIGCHLD, sigchld); 780 signal(SIGCHLD, sigchld);
781 if (opt_io && !(fileio = fopen(opt_io, "w"))) {
782 fprintf(stderr, "Error opening %s:%s",
783 opt_io, strerror(errno));
784 }
779 } 785 }
780} 786}
781 787
@@ -1534,6 +1540,9 @@ tputtab(bool forward) {
1534void 1540void
1535tputc(char *c) { 1541tputc(char *c) {
1536 char ascii = *c; 1542 char ascii = *c;
1543
1544 if (fileio)
1545 putc(ascii, fileio);
1537 if(term.esc & ESC_START) { 1546 if(term.esc & ESC_START) {
1538 if(term.esc & ESC_CSI) { 1547 if(term.esc & ESC_CSI) {
1539 csiescseq.buf[csiescseq.len++] = ascii; 1548 csiescseq.buf[csiescseq.len++] = ascii;
@@ -2269,6 +2278,9 @@ main(int argc, char *argv[]) {
2269 case 'w': 2278 case 'w':
2270 if(++i < argc) opt_embed = argv[i]; 2279 if(++i < argc) opt_embed = argv[i];
2271 break; 2280 break;
2281 case 'f':
2282 if (++i < argc) opt_io = argv[i];
2283 break;
2272 case 'e': 2284 case 'e':
2273 /* eat every remaining arguments */ 2285 /* eat every remaining arguments */
2274 if(++i < argc) opt_cmd = &argv[i]; 2286 if(++i < argc) opt_cmd = &argv[i];