Skip to content

Instantly share code, notes, and snippets.

@simonjbeaumont
Last active October 13, 2021 11:03
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save simonjbeaumont/4672606 to your computer and use it in GitHub Desktop.
Save simonjbeaumont/4672606 to your computer and use it in GitHub Desktop.
Update bash to latest tmux environment on reattaching.
#!/bin/bash
tmup ()
{
echo -n "Updating to latest tmux environment...";
export IFS=",";
for line in $(tmux showenv -t $(tmux display -p "#S") | tr "\n" ",");
do
if [[ $line == -* ]]; then
unset $(echo $line | cut -c2-);
else
export $line;
fi;
done;
unset IFS;
echo "Done"
}
@kshenoy
Copy link

kshenoy commented Jan 20, 2015

I had to deal with windows disappearing/not starting for a long time before I could figure out that the value of $DISPLAY was changing. It drove me crazy! For some time after that I was setting it manually.

Thanks for this!

@ksmith0
Copy link

ksmith0 commented Feb 13, 2015

Nice little script, I changed IFS to $'\n' and removed the tr. No need to export IFS either.

@ursetto
Copy link

ursetto commented Apr 25, 2018

showenv has a -s option now to format the output as bourne shell commands, so I think eval $(tmux showenv -s ...) should do the job of this script now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment