Changing the StudioShell prompt...

Feb 10, 2012 at 1:34 PM

During my presentations I always show how to change the PowerShell prompt in order to prevent displaying long directories lines.  Unfortunately, the following code won't load under StudioShell:

function prompt
{
  ## - This function will change the PS Console to enumerate each line
  ## - preventing long pathnames:
  if ($host.UI.RawUI.CursorPosition.Y -eq 0)
  {
    "< $pwd > `n`r" + "PS ["+$host.UI.RawUI.CursorPosition.Y+"] > "
  } 
  Else
  {
    "PS ["+$host.UI.RawUI.CursorPosition.Y+"] > "
  };
};

It's giving me the following error: 

! Missing closing '}' in statement block.
! Missing function body in function declaration.

Is there any way to go around this issue?

Thx,

Max

 

Coordinator
Feb 10, 2012 at 8:35 PM

Max;

 

Sorry, I thought I had responded to this earlier, but I guess I never clicked Save...

At the moment SS doesn't support multi-line input at the prompt the way the console does.  This is on the list of to-dos for 1.4.  However, you can put your prompt function in your StudioShell profile script, and it will work like a champ from there.

Read more about the studioshell profile script here: [about_StudioShell_Profiles] (http://studioshell.codeplex.com/wikipage?title=about_StudioShell_Profiles&referringTitle=Documentation)

 

 

Feb 10, 2012 at 11:39 PM

Well, this is strange.  I didn't use the StudioShell profile because I already have a "Microsoft.PowerShell_Profile.ps1" and my prompt function won't work in it.  But, if I use your StudioShell profile then it's find.  So, I can't use my Windows PS profile. 

Also, I did a couple of test with the StudioShell "Options" and the it's not working.  If I make a change to it, I'm expecting to be kept but is not saving it.  Even, if I want to only use my Windows PS profile, it still loads both of them and this is not right. 

Anyway, beside all of these minor issues.. YES! you app Rocks!!  I just learned my limitations with it.

Good Job!!

:)