Closed pschmitt closed 3 years ago
So it turns out you can fetch the public from the log file if you enable verbose logging. Here's what I ended up with:
TTY_SHARE_LOGFILE="${TMPDIR:-/tmp}/tty-share.log"
tty-share() {
if [[ -n "$TTY_SHARE" ]]
then
echo "TTY_SHARE is set. You are already running tty-share. Unset TTY_SHARE to force."
return 1
fi
tmux set-env -g TTY_SHARE 1
TTY_SHARE=1 command tty-share \
--logfile "$TTY_SHARE_LOGFILE" --verbose \
"$@"
tmux set-env -gu TTY_SHARE
}
if [[ -n "$TTY_SHARE" ]]
then
export TTY_SHARE=1
if [[ -r "$TTY_SHARE_LOGFILE" ]]
then
export TTY_SHARE_URL="$(head -n 1 "$TTY_SHARE_LOGFILE" | sed -nr 's/.*Connected to (http[^ ]+).*/\1/p')"
fi
fi
# vim: set ft=zsh et ts=2 sw=2 :
Hey @pschmitt!
I thought about the same, inspired by tmux, but unfortunately I didn't get to do it. I'll add it to my TODO list, and hopefully add it soon, as it probably should be very simple. Sorry you had to go through that pain of parsing the logs for this.
And thanks for using tty-share, it's motivating to read that :)
FYI, I added the environmental variables in the latest commit, @pschmitt. https://github.com/elisescu/tty-share/pull/27
Cheers 🥳
Hey, great piece of software - I'll 100% use this for my next online meeting.
I couldn't find an easy way to set env vars in the command executed by tty-share though. Here's what I would like to be able to do:
TTY_SHARE=1
. This way you could for example change your prompt when running inside tty-share.TTY_SHARE_PUBLIC_URL=https://xxx
TTY_SHARE_LOCAL_URL=http://localhost:8000/xxx
)You can right now already get around the first "issue" by using a custom shell function (see below), but I couldn't find a way to get the urls after the initial launch.
Thanks for this epic alternative to tmate!
EDIT: Having an env var such as
TTY_SHARE
would also make it pretty easy to avoid running nested tty-share sessions (same as tmux)