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

From: Ian Remmler <ian_AT_remmler.org>
Date: Thu, 9 May 2019 16:27:31 -0500

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.
Received on Thu May 09 2019 - 23:27:31 CEST

This archive was generated by hypermail 2.3.0 : Fri May 10 2019 - 00:24:08 CEST