Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I like to make a lot of changes to my $profile file. After saving a change, I would like to source the file using an "sop" alias. Here's how I hope to accomplish that:

set-alias sop Source-Profile
function Source-Profile {
    . $profile

This function does not throw any errors, so it appears to work. However, when I do make changes to my $profile file, this function doesn’t appear to to anything. I still have to type . $profile from the PS prompt to re-evaluate that file. And that's ok, but it is a minor pain. I would rather use an alias to source that file.

What am I missing here?

share|improve this question
up vote 1 down vote accepted

Dot-sourcing a file runs it in the current scope (rather than its own scope). To source a file in a function and get the definitions in the file to be included in the calling scope, you need to dot-source the function. Try this:

. sop
share|improve this answer
Awesome, this works! Too bad though that you can't do this without the dot. This sort of thing works in BASH and such. – Tom Purl Mar 5 '13 at 16:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.