added -e and -t option.
This commit is contained in:
parent
97695baf4f
commit
9d82bdd947
36
st.c
36
st.c
|
@ -28,6 +28,10 @@
|
||||||
#include <libutil.h>
|
#include <libutil.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define USAGE \
|
||||||
|
"st-" VERSION ", (c) 2010 st engineers\n" \
|
||||||
|
"usage: st [-t title] [-e cmd] [-v]\n"
|
||||||
|
|
||||||
/* Arbitrary sizes */
|
/* Arbitrary sizes */
|
||||||
#define ESC_TITLE_SIZ 256
|
#define ESC_TITLE_SIZ 256
|
||||||
#define ESC_BUF_SIZ 256
|
#define ESC_BUF_SIZ 256
|
||||||
|
@ -210,6 +214,8 @@ static CSIEscape escseq;
|
||||||
static int cmdfd;
|
static int cmdfd;
|
||||||
static pid_t pid;
|
static pid_t pid;
|
||||||
static Selection sel;
|
static Selection sel;
|
||||||
|
static char *opt_cmd = NULL;
|
||||||
|
static char *opt_title = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
selinit(void) {
|
selinit(void) {
|
||||||
|
@ -329,9 +335,12 @@ die(const char *errstr, ...) {
|
||||||
|
|
||||||
void
|
void
|
||||||
execsh(void) {
|
execsh(void) {
|
||||||
char *args[3] = {getenv("SHELL"), "-i", NULL};
|
char *args[] = {getenv("SHELL"), "-i", NULL};
|
||||||
DEFAULT(args[0], SHELL); /* if getenv() failed */
|
if(opt_cmd)
|
||||||
putenv("TERM=" TNAME);
|
args[0] = opt_cmd, args[1] = NULL;
|
||||||
|
else
|
||||||
|
DEFAULT(args[0], SHELL);
|
||||||
|
putenv("TERM="TNAME);
|
||||||
execvp(args[0], args);
|
execvp(args[0], args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,7 +1198,7 @@ xinit(void) {
|
||||||
|
|
||||||
XMapWindow(xw.dis, xw.win);
|
XMapWindow(xw.dis, xw.win);
|
||||||
xhints();
|
xhints();
|
||||||
XStoreName(xw.dis, xw.win, "st");
|
XStoreName(xw.dis, xw.win, opt_title ? opt_title : "st");
|
||||||
XSync(xw.dis, 0);
|
XSync(xw.dis, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1429,10 +1438,21 @@ run(void) {
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
if(argc == 2 && !strncmp("-v", argv[1], 3))
|
int i;
|
||||||
die("st-" VERSION ", (c) 2010 st engineers\n");
|
|
||||||
else if(argc != 1)
|
for(i = 1; i < argc; i++) {
|
||||||
die("usage: st [-v]\n");
|
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, "");
|
setlocale(LC_CTYPE, "");
|
||||||
tnew(80, 24);
|
tnew(80, 24);
|
||||||
ttynew();
|
ttynew();
|
||||||
|
|
Loading…
Reference in New Issue