[wiki] [sites] [st][patch] workingdir: Set working dir at startup || David Gricar

From: <git_AT_suckless.org>
Date: Tue, 17 Mar 2020 23:14:25 +0100

commit 209ccd1d9db5b343544a994feab31c0957a920a9
Author: David Gricar <coppie_AT_protonmail.com>
Date: Tue Mar 17 23:11:08 2020 +0100

    [st][patch] workingdir: Set working dir at startup
    
    This patch adds a '-d path' switch to open 'path' as working directory
    when st spawns.
    It behaves as if 'cd path' would be ran after st starts and does
    nothing if path is invalid.

diff --git a/st.suckless.org/patches/workingdir/index.md b/st.suckless.org/patches/workingdir/index.md
new file mode 100644
index 00000000..bee4b642
--- /dev/null
+++ b/st.suckless.org/patches/workingdir/index.md
_AT_@ -0,0 +1,25 @@
+workingdir
+==========
+
+Description
+-----------
+This patch allows user to specify the initial path st should use as WD
+(working directory).
+
+Examples
+--------
+Absolute path:
+`st -d /usr/bin/`
+
+Relative path:
+`st -d dev/st/`
+or
+`st -d ~/dev/st/`
+
+Download
+--------
+* [st-workingdirectory-YYYYMMDD-hash.diff](st-anysize-0.8.1.diff)
+
+Authors
+-------
+* David Gričar - <suckless_AT_coppie.xyz>
diff --git a/st.suckless.org/patches/workingdir/st-workingdir-20200317-51e19ea.diff b/st.suckless.org/patches/workingdir/st-workingdir-20200317-51e19ea.diff
new file mode 100644
index 00000000..65de0848
--- /dev/null
+++ b/st.suckless.org/patches/workingdir/st-workingdir-20200317-51e19ea.diff
_AT_@ -0,0 +1,97 @@
+From ae14b869d7bc0e0cd8ed16157837ad09aaacacc0 Mon Sep 17 00:00:00 2001
+From: David Gricar <coppie_AT_protonmail.com>
+Date: Tue, 17 Mar 2020 13:38:05 +0100
+Subject: [PATCH] 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.
+---
+ st.1 | 8 ++++++++
+ x.c | 13 +++++++++----
+ 2 files changed, 17 insertions(+), 4 deletions(-)
+
+diff --git a/st.1 b/st.1
+index e8d6059..a901122 100644
+--- a/st.1
++++ b/st.1
+_AT_@ -6,6 +6,8 @@ st \- simple terminal
+ .RB [ \-aiv ]
+ .RB [ \-c
+ .IR class ]
++.RB [ \-d
++.IR path ]
+ .RB [ \-f
+ .IR font ]
+ .RB [ \-g
+_AT_@ -30,6 +32,8 @@ st \- simple terminal
+ .RB [ \-aiv ]
+ .RB [ \-c
+ .IR class ]
++.RB [ \-d
++.IR path ]
+ .RB [ \-f
+ .IR font ]
+ .RB [ \-g
+_AT_@ -58,6 +62,10 @@ disable alternate screens in terminal
+ .BI \-c " class"
+ defines the window class (default $TERM).
+ .TP
++.BI \-d " path"
++changes the working directory to
++.IR path .
++.TP
+ .BI \-f " font"
+ defines the
+ .I font
+diff --git a/x.c b/x.c
+index 48a6676..fab2ddc 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -250,6 +250,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 int oldbutton = 3; /* button event on startup: 3 = release */
+
+_AT_@ -1958,12 +1959,12 @@ run(void)
+ void
+ usage(void)
+ {
+- die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]"
+- " [-n name] [-o file]
"
++ die("usage: %s [-aiv] [-c class] [-d path] [-f font]"
++ " [-g geometry] [-n name] [-o file]
"
+ " [-T title] [-t title] [-w windowid]"
+ " [[-e] command [args ...]]
"
+- " %s [-aiv] [-c class] [-f font] [-g geometry]"
+- " [-n name] [-o file]
"
++ " %s [-aiv] [-c class] [-d path] [-f font]"
++ " [-g geometry] [-n name] [-o file]
"
+ " [-T title] [-t title] [-w windowid] -l line"
+ " [stty_args ...]
", argv0, argv0);
+ }
+_AT_@ -2015,6 +2016,9 @@ main(int argc, char *argv[])
+ case 'v':
+ die("%s " VERSION "
", argv0);
+ break;
++ case 'd':
++ opt_dir = EARGF(usage());
++ break;
+ default:
+ usage();
+ } ARGEND;
+_AT_@ -2034,6 +2038,7 @@ run:
+ xinit(cols, rows);
+ xsetenv();
+ selinit();
++ chdir(opt_dir);
+ run();
+
+ return 0;
+--
+2.25.1
+
Received on Tue Mar 17 2020 - 23:14:25 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 17 2020 - 23:24:51 CET