Question: I'm looking for a way to map "emacs" to "emacs -nw" in powershell. I tried this (screenshot below), and it adds it as an alias, but it doesn't work. However, the command "emacs -nw" works before setting the alias.

[![enter image description here](https://i.stack.imgur.com/q4HkM.png)](https://i.stack.imgur.com/q4HkM.png)

And I also want a way to save that alias for future sessions (restarting the powershell gets me back to square zero)

EDIT:(aditional info)
Also tried creating a function, but when calling that function powershell freezes for a while, then I get the following message (screenshot below)
[![enter image description here](https://i.stack.imgur.com/PMnc0.png)](https://i.stack.imgur.com/PMnc0.png)

EDIT2:(aditional info)
At first, `function enw {emacs.exe -nw}` (changed function name to 'enw' for explanation purposes) seems to work. But then there's a problem. For the standard emacs, I can type `emacs -nw filename.txt`, and that would open the file `filename.txt` in `emacs -nw`. Calling the function `enw filename.txt` will not open the `filename.txt` file, providing the same result as just typing `enw`.

The solution to this is `function enw {Param($myparam) emacs.exe -nw $myparam}`

Answer: 
try creating a function:

```
function emacs {emacs.exe -nw}

```

then add it to your powershell profile ( `$profile` )
I see you have your answers but I just wanted to spell it out here. You created a recursive function.

By not specifying the .exe as part of the extension PowerShell was able to match `emacs` back to your function definition. So it would call itself infinitely. 

You can see this by checking the results of `Get-Command emacs` both before and after you register your function.