![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| | |||||||
| |
| 07-30-2009 | #1 (permalink) |
| | prompt function and the last command entered I'd like my prompt function to have knowledge of the last command entered, meaning the one that produced output before the next command line prompt is displayed. I attempted to use the automatic variable $^ in the prompt function and I have discovered that the value of $^ is still its older value, not the command that just executed. How else can I get the string that represents the last command entered at the command prompt in a way that it can be used by the prompt function? - Larry |
| My System Specs |
| 07-30-2009 | #2 (permalink) |
| | Re: prompt function and the last command entered If I follow: PS>function prompt { (get-history -count 1|select -exp commandline)+">" } "Larry__Weiss" <lfw@xxxxxx> wrote in message news:OmaaRLXEKHA.1516@xxxxxx Quote: > I'd like my prompt function to have knowledge of the last command entered, > meaning the one that produced output before the next command line prompt > is displayed. > > I attempted to use the automatic variable $^ in the prompt function and I > have discovered that the value of $^ is still its older value, not the > command that just executed. > > How else can I get the string that represents the last command entered at > the command prompt in a way that it can be used by the prompt function? > > - Larry |
| My System Specs |
| 07-31-2009 | #3 (permalink) |
| | Re: prompt function and the last command entered That works. Thanks. Do you think it is a bug that $^ is not yet bound to the value of the last command at the time that the prompt function is executed? From: help about_Automatic_Variables $^ Contains the first token in the last line received by the session But function prompt{$^} is always one line behind. - Larry Marco Shaw [MVP] wrote: Quote: > If I follow: > PS>function prompt { (get-history -count 1|select -exp commandline)+">" } > > "Larry__Weiss" <lfw@xxxxxx> wrote in message > news:OmaaRLXEKHA.1516@xxxxxx Quote: >> I'd like my prompt function to have knowledge of the last command >> entered, meaning the one that produced output before the next command >> line prompt is displayed. >> >> I attempted to use the automatic variable $^ in the prompt function >> and I have discovered that the value of $^ is still its older value, >> not the command that just executed. >> >> How else can I get the string that represents the last command entered >> at the command prompt in a way that it can be used by the prompt >> function? >> |
| My System Specs |
| 07-31-2009 | #4 (permalink) |
| | Re: prompt function and the last command entered Good question. I don't know if I'll have time to look into it myself. Marco "Larry__Weiss" <lfw@xxxxxx> wrote in message news:udO2c1cEKHA.4220@xxxxxx Quote: > That works. Thanks. > > Do you think it is a bug that $^ is not yet bound to the value of the last > command at the time that the prompt function is executed? > > From: help about_Automatic_Variables > $^ Contains the first token in the last line received by the session > > But > function prompt{$^} > is always one line behind. > > - Larry > > > Marco Shaw [MVP] wrote: Quote: >> If I follow: >> PS>function prompt { (get-history -count 1|select -exp commandline)+">" } >> >> "Larry__Weiss" <lfw@xxxxxx> wrote in message >> news:OmaaRLXEKHA.1516@xxxxxx Quote: >>> I'd like my prompt function to have knowledge of the last command >>> entered, meaning the one that produced output before the next command >>> line prompt is displayed. >>> >>> I attempted to use the automatic variable $^ in the prompt function and >>> I have discovered that the value of $^ is still its older value, not the >>> command that just executed. >>> >>> How else can I get the string that represents the last command entered >>> at the command prompt in a way that it can be used by the prompt >>> function? >>> |
| My System Specs |
| 07-31-2009 | #5 (permalink) |
| | Re: prompt function and the last command entered I need to figure out how to file questions like that with the PowerShell team. I imagine there is a website to do that somewhere. - Larry Marco Shaw [MVP] wrote: Quote: > Good question. I don't know if I'll have time to look into it myself. > > "Larry__Weiss" <lfw@xxxxxx> wrote in message > news:udO2c1cEKHA.4220@xxxxxx Quote: >> That works. Thanks. >> >> Do you think it is a bug that $^ is not yet bound to the value of the >> last command at the time that the prompt function is executed? >> >> From: help about_Automatic_Variables >> $^ Contains the first token in the last line received by the session >> >> But >> function prompt{$^} >> is always one line behind. >> >> >> Marco Shaw [MVP] wrote: Quote: >>> If I follow: >>> PS>function prompt { (get-history -count 1|select -exp >>> commandline)+">" } >>> >>> "Larry__Weiss" <lfw@xxxxxx> wrote in message >>> news:OmaaRLXEKHA.1516@xxxxxx >>>> I'd like my prompt function to have knowledge of the last command >>>> entered, meaning the one that produced output before the next >>>> command line prompt is displayed. >>>> >>>> I attempted to use the automatic variable $^ in the prompt function >>>> and I have discovered that the value of $^ is still its older value, >>>> not the command that just executed. >>>> >>>> How else can I get the string that represents the last command >>>> entered at the command prompt in a way that it can be used by the >>>> prompt function? >>>> |
| My System Specs |
| 07-31-2009 | #6 (permalink) |
| | Re: prompt function and the last command entered For bugs and/or suggestions: https://connect.microsoft.com/PowerShell "Larry__Weiss" <lfw@xxxxxx> wrote in message news:#AQJwOgEKHA.5780@xxxxxx Quote: > I need to figure out how to file questions like that with the PowerShell > team. I imagine there is a website to do that somewhere. |
| My System Specs |
| Thread Tools | |
| |
| Similar topics to: prompt function and the last command entered | ||||
| Thread | Forum | |||
| A near prompt function I created... | PowerShell | |||
| customized prompt function | PowerShell | |||
Make a command prompt run a command as soon as it opens? | General Discussion | |||
| echo out interactive parameters that were entered for a command | PowerShell | |||
| Command prompt "COPY" command not working in brand new Windows Vis | Vista file management | |||