Re: [dev] [st] How do I add a keybinding to open a new ST window in the current working directory?

From: Hiltjo Posthuma <>
Date: Fri, 10 May 2019 10:51:52 +0200

On Thu, May 09, 2019 at 04:27:31PM -0500, Ian Remmler wrote:
> On Thu, May 09, 2019 at 11:30:37AM +0600, Enan Ajmain wrote:
> > So, could you help me how I can create a function to open a new ST
> > terminal window on the cwd of the current ST terminal?
> I do something similar with my plumber that could be adapted. I use zsh
> which (if interactive) will evaluate a "precmd" hook function when you
> execute a command line. I believe bash has something similar. I have it
> store the cwd in the X secondary selection (which nothing else typically
> uses). You could substitute xclip for xsel.
> precmd() { xsel -s "$PWD" }
> Then you just make a script to launch st from there and bind it to a
> window manager shortcut or whatever.
> cd "$(xsel -s)"; st
> It's a kludge, but it works. Note that it will go to the cwd of the last
> terminal where you hit enter, not necessarily the one that has focus.
> --
> - Ian.

On Linux you can also use some ugly hack and get the cwd from the running
process in /proc. From the top of my head: /proc/somepid/cwd

Kind regards,
Received on Fri May 10 2019 - 10:51:52 CEST

This archive was generated by hypermail 2.3.0 : Fri May 10 2019 - 11:00:09 CEST