In Unix, I create a lot of aliases/functions. Here is my workflow:

  • I have a file name 'aliases.txt' in my $HOME directory
  • I have a quick command to edit that file
  • I have an alias named 'sa' that sources that alias file. I.e.

    'alias sa='. $HOME/aliases.txt'

I can quickly and easily create, modify, and use new aliases.

I'm trying to re-create the same work flow in PowerShell but it doesn't work. I've got the aliases.ps1 file in my $HOME directory. I tried creating an 'sa' alias, but of course a PowerShell alias can't contain an argument. So I've tried:

function sa {. $HOME\aliases.ps1 }

I can run it but changes in my aliases.pl1 file don't get reflected in my shell session. I'm assuming it's because Windows runs the 'sa' function in a new process, which Unix runs functions and aliases in the same process. How can I get my 'sa' back?

("Type '. $HOME\aliases.ps1' at the command line each time" is not the answer I'm looking for.

link|improve this question
I can think of a 1000 reasons why they would not run them in the same process. Never the less, I don't think it's possible unless you reload the script. – surfasb Jul 29 '11 at 0:34
So you're saying there's no way to create a function/alias/cmdlet that will run in the same process? – jonathan Jul 29 '11 at 0:35
AFAIK, no. But I'm gonna see if we can move this question to the Serverfault audience. The Powershell experts reside there. – surfasb Jul 29 '11 at 0:43
Question on Stack Overflow: stackoverflow.com/questions/6867442/… – Gareth Jul 29 '11 at 3:45
Please don't cross-post – Sathya Jul 29 '11 at 4:01
feedback

closed as off topic by surfasb, Sathya Jul 29 '11 at 4:01

Questions on Super User are expected to generally relate to computer software or computer hardware, within the scope defined in the faq.

Browse other questions tagged or ask your own question.