Closed sijad closed 4 years ago
It seems there is actually a more general problem here about setting up the environment of the client shell/application.
Changing directory is not the only thing you might want to do, you might also want to:
I've thought about adding environment variables before and concluded that it would be better to just set them by telling havoc to call a script that can then do arbitrary setup, for example: mysetup.sh:
export MYVAR=2
cd /var/log
exec bash
And then havoc sh mysetup.sh
This would then mean we can do more complex setup, like reading some part of the environment from a file, changing to a directory that is specified dynamically somehow, and we would not have to add any code to havoc.
I agree that it's a bit more roundabout though, so let me know what you think.
If you're already in a shell then simple kinds of setup can be done before running havoc: export MYVAR=2; cd /var/log && havoc
, but that's not always possible.
I needed this option to open a new terminal with same directory as the old one in sway. other terminal (termite, alacritty, etc) has this option, so I guess havoc should have this too.
I've tried your approach (cd
in subscript) but it does not working with sway exec
. in this script I've tried cd
and then running havoc but it opened in $HOME
instead
The running script approach should work, for example:
exec havoc sh /usr/local/bin/termsetup.sh
But maybe the convenience of just having -d
justifies it, not sure.
you're right. in my case swaymsg -t command exec
changes the cwd
to $HOME
.
I'm really not sure either but in last example, there's also a sh
process per terminal instance.
The sh
instance is always there, that is done by sway.
This should also work:
swaymsg -t command exec havoc sh /usr/local/bin/termsetup.sh
where
$ cat /usr/local/bin/termsetup.sh
cd /var/log
exec bash
I didn't know about exec command. I'm going to use your approach, feel free to close PR.
now it's possible to open havoc in a directory
havoc -d /var/log/