I'm trying to create an alias in PowerShell to reload my profile quickly using `. $PROFILE`. I set up a function called `so`, but when I tried to use it after modifying my profile, it didn't work. However, executing `. $PROFILE` directly works fine. Is there something about scoping or the way I set this up that I'm missing? Here's what I did:
```powershell
# alias in my profile
function so {
. $PROFILE
}
```
Then in my session, I modified my profile with:`vim $PROFILE` and tried `so`, but it didn't reload. The command `. $PROFILE` works as expected.
2 Answers
It sounds like you might be running into a scoping issue. When you define a function like `so` to dot-source your profile, it might not be executing in the global scope. A tip is to try adding an extra dot when calling it to run in the correct scope. It should look like this: `. so`. This should help you reload your profile as expected!
I've had a similar issue before. Instead of `so`, I created a function called `reload-profile` that uses `& $PROFILE` to run the profile. It seems to work better for me in terms of reloading.
Yeah, definitely give that a shot! Scoping can be tricky in PowerShell.