2

I use my mac at home and at work. And I use a program called Marco-polo to detect whether I am at home or at work. Through this, I can get it to run a script that changes my proxy and run some scripts to configure my computer differently for the different environments like copying hosts.work and hosts.home over /etc/hosts and copy .profile.work and .profile.home over ~/.profile.

What I have not been able to do successfully so far, is to find a way to have all my running terminals reload my .profile file when I change location. Can anyone suggest a method for doing this?

Thanks, Tom


fm48 answer below in combination with this simple script (placed at /usr/bin/pkill) worked perfectly.

#!/bin/sh
sig=""
if [[ "$1" =~ - ]]; then
  sig=$1;
  shift
fi

for X in `ps acx | grep -i $1 | awk {'print $1'}`; do
    kill $sig $X;
done
3
  • You'll get a lot more people looking at your question if you add a tag for osx. Good luck. Commented Oct 13, 2011 at 13:34
  • why? its not really osx specific Commented Oct 15, 2011 at 21:17
  • and yet you say 'unfortunately pkill is not available on osx leopard'. The only reason I mention adding tags is to get more eyes on your problem. You're always entitled to do as you see fit, and as you have got a good answer, I'm happy for you. Good luck. Commented Oct 15, 2011 at 23:55

2 Answers 2

9

You should use a signal like SIGUSR1. First enable the signal to reload the ~/.profile with trap ". ${HOME}/.profile" SIGUSR1.

After that you should send all shells the SIGUSR1 signal. For example pkill -SIGUSR1 bash if bash is the used shell.

Sign up to request clarification or add additional context in comments.

2 Comments

Nice answer. I would have said you couldn't do it.
genius! unfortunately pkill is not available on osx leopard (mac ports proctools doesn't compile) - i have added a script to my question that one can use.
0

If you adopt Screen as a terminal manager, you can send commands to all your shells with:
screen -X at \# stuff "whatever command\n"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.