From a8a9fdc32ffc5ee6e3953322a48e0a8dbceff5a7 Mon Sep 17 00:00:00 2001 From: David Gricar Date: Thu, 1 Feb 2024 05:13:29 +0300 Subject: Add switch to provide initial working directory This patch adds -p switch which takes one argument 'path' and can be used to set the initial working directory of the new st instance. It acts the same as running 'cd path' command after starting the st instance. Source: https://st.suckless.org/patches/workingdir/ --- x.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'x.c') diff --git a/x.c b/x.c index b36fb8c..2131095 100644 --- a/x.c +++ b/x.c @@ -251,6 +251,7 @@ static char *opt_io = NULL; static char *opt_line = NULL; static char *opt_name = NULL; static char *opt_title = NULL; +static char *opt_dir = NULL; static uint buttons; /* bit field of pressed buttons */ @@ -2017,12 +2018,12 @@ run(void) void usage(void) { - die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]" - " [-n name] [-o file]\n" + die("usage: %s [-aiv] [-c class] [-d path] [-f font]" + " [-g geometry] [-n name] [-o file]\n" " [-T title] [-t title] [-w windowid]" " [[-e] command [args ...]]\n" - " %s [-aiv] [-c class] [-f font] [-g geometry]" - " [-n name] [-o file]\n" + " %s [-aiv] [-c class] [-d path] [-f font]" + " [-g geometry] [-n name] [-o file]\n" " [-T title] [-t title] [-w windowid] -l line" " [stty_args ...]\n", argv0, argv0); } @@ -2074,6 +2075,9 @@ main(int argc, char *argv[]) case 'v': die("%s " VERSION "\n", argv0); break; + case 'd': + opt_dir = EARGF(usage()); + break; default: usage(); } ARGEND; @@ -2093,6 +2097,7 @@ run: xinit(cols, rows); xsetenv(); selinit(); + chdir(opt_dir); run(); return 0; -- cgit v1.2.3