Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

tab and variable

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 10-17-2006   #1 (permalink)
hn
Guest


 

tab and variable

I'm trying to use tab together with variable, e.g.:
by typing $pshome<enter>, i have
c:\windows\system32\windowspowershell\v1.0

i would expect
$pshome\..\<tab> would resolve to
c:\windows\system32\windowspowershell\v1.0\..\ OR
c:\windows\system32\windowspowershell\v1.0\

but it does not, it resolves somewhere to
c:\document and settings\username\$pshome\..\...

am i using it right? Thanks!

My System SpecsSystem Spec
Old 10-17-2006   #2 (permalink)
Andrew Webb
Guest


 

RE: tab and variable

<tab> works off the contents of your current location. Expecting it to pay
attention to the current contents of PowerShell variables is probably a bit
much. I think it's really impressive that you can do this, though:-
cd hkcu: <enter>
cd <tab>, <tab>, <tab>, <tab>, <tab>,
and have it iterate through the contents of the HKCU drive.

I would say that the PowerShell team have gone far enough integrating with
the current Cmd.exe-style window, and in future releases it would be nice to
see them using their own windowed environment. What they have done thus far
(e.g. the example above) is damn impressive as it is.

Andrew Webb
My System SpecsSystem Spec
Old 10-17-2006   #3 (permalink)
hn
Guest


 

RE: tab and variable

I think by saying '<tab> works off the contents of your current location' is
correct, but the fact is the PS' tab-completion is worth more than that, I
believe you can enter:
hkcu:<tab>
without being in hkcu drive.

So PS is already pay attention to previous token, so by substition env.
variable, I don't know, maybe you are right, 'a bit too much'

"Andrew Webb" wrote:

> <tab> works off the contents of your current location. Expecting it to pay
> attention to the current contents of PowerShell variables is probably a bit
> much. I think it's really impressive that you can do this, though:-
> cd hkcu: <enter>
> cd <tab>, <tab>, <tab>, <tab>, <tab>,
> and have it iterate through the contents of the HKCU drive.
>
> I would say that the PowerShell team have gone far enough integrating with
> the current Cmd.exe-style window, and in future releases it would be nice to
> see them using their own windowed environment. What they have done thus far
> (e.g. the example above) is damn impressive as it is.
>
> Andrew Webb

My System SpecsSystem Spec
Old 10-17-2006   #4 (permalink)
Andrew Webb
Guest


 

RE: tab and variable

> I think by saying '<tab> works off the contents of your current location' is
> correct, but the fact is the PS' tab-completion is worth more than that, I
> believe you can enter:
> hkcu:<tab>
> without being in hkcu drive.


You're right! Even more impressive than I thought.

Try this:
$e<tab><tab><tab>

It will iterate through the current list of variables, listing those that
begin with 'e'. This is what it will do with variables, rather than examine
their contents - which I think answers your original question.


My System SpecsSystem Spec
Old 10-17-2006   #5 (permalink)
hn
Guest


 

RE: tab and variable

not really answer to my question, my question is why
$pshome\..\
does not expand to
c:\windows\system32\windowspowershell\

"Andrew Webb" wrote:

> > I think by saying '<tab> works off the contents of your current location' is
> > correct, but the fact is the PS' tab-completion is worth more than that, I
> > believe you can enter:
> > hkcu:<tab>
> > without being in hkcu drive.

>
> You're right! Even more impressive than I thought.
>
> Try this:
> $e<tab><tab><tab>
>
> It will iterate through the current list of variables, listing those that
> begin with 'e'. This is what it will do with variables, rather than examine
> their contents - which I think answers your original question.
>
>

My System SpecsSystem Spec
Old 10-17-2006   #6 (permalink)
Sung M Kim
Guest


 

Re: tab and variable

hn wrote:
> not really answer to my question, my question is why
> $pshome\..\
> does not expand to
> c:\windows\system32\windowspowershell\


It is because expanding the "value" of parameter is not implemented in
the TabExpanion function( located in function:TabExpansion, and to see
the definition of the function try, (ls
function:TabExpansion).definition ).

My System SpecsSystem Spec
Old 10-17-2006   #7 (permalink)
Adam Milazzo
Guest


 

Re: tab and variable

hn wrote:
> I'm trying to use tab together with variable, e.g.:
> by typing $pshome<enter>, i have
> c:\windows\system32\windowspowershell\v1.0
>
> i would expect
> $pshome\..\<tab> would resolve to
> c:\windows\system32\windowspowershell\v1.0\..\ OR
> c:\windows\system32\windowspowershell\v1.0\
>
> but it does not, it resolves somewhere to
> c:\document and settings\username\$pshome\..\...
>
> am i using it right? Thanks!


Unfortunately PowerShell doesn't support this out of the box. I already
filed a bug about it...

But you can implement it yourself by modifying the definition of the
TabExpansion function. Or, rather, you can use other people's tab
expansion scripts. I know I've seen one posted to this newsgroup that
does variable expansion and a number of other things...

Perhaps somebody can reply with a link to the script, or perhaps you can
post a new thread asking about the community's tab expansion addons.
My System SpecsSystem Spec
Old 10-18-2006   #8 (permalink)
Bruce Payette [MSFT]
Guest


 

Re: tab and variable

Correct - the tab completion code for filenames isn't expanding variables in
paths. It is possible to modify the TabCompletion function to do this with
some work. Tab-completion in V1 is very much a glass-half full experience
:-)

-bruce

--
Bruce Payette [MSFT]
Windows PowerShell Technical Lead
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scr.../hubs/msh.mspx
My book: http://manning.com/powershell


"Sung M Kim" <DontBotherMeWithSpam@gmail.com> wrote in message
news:1161104935.391170.273890@i42g2000cwa.googlegroups.com...
> hn wrote:
>> not really answer to my question, my question is why
>> $pshome\..\
>> does not expand to
>> c:\windows\system32\windowspowershell\

>
> It is because expanding the "value" of parameter is not implemented in
> the TabExpanion function( located in function:TabExpansion, and to see
> the definition of the function try, (ls
> function:TabExpansion).definition ).
>



My System SpecsSystem Spec
Old 10-20-2006   #9 (permalink)
/\\/\\o\\/\\/ [MVP]
Guest


 

Re: tab and variable

I have a series about TabExpansion on my blog :
the latestversion is :

http://mow001.blogspot.com/2006/10/p...on-part-5.html

It realy adds a lot to the TabCompletion like (WMI,alias, history, functions
etc. (even GUI form support for selecting from a list, and custom
completion) and much more.
This last version needs some preparement and getting used to, as it uses a
DataBase to work, but after that is realy powerfull I think

The former versions works as is, and might be more easy to start with :

http://mow001.blogspot.com/2006/06/p...on-part-4.html

on Codeplex :

http://www.codeplex.com/Wiki/View.as...tName=PsObject

Enjoy,

Greetings /\/\o\/\/

"Adam Milazzo" <adamm@san.rr.com> wrote in message
news:uGNVlri8GHA.4476@TK2MSFTNGP04.phx.gbl...
> hn wrote:
>> I'm trying to use tab together with variable, e.g.:
>> by typing $pshome<enter>, i have
>> c:\windows\system32\windowspowershell\v1.0
>>
>> i would expect $pshome\..\<tab> would resolve to
>> c:\windows\system32\windowspowershell\v1.0\..\ OR
>> c:\windows\system32\windowspowershell\v1.0\
>>
>> but it does not, it resolves somewhere to
>> c:\document and settings\username\$pshome\..\...
>>
>> am i using it right? Thanks!

>
> Unfortunately PowerShell doesn't support this out of the box. I already
> filed a bug about it...
>
> But you can implement it yourself by modifying the definition of the
> TabExpansion function. Or, rather, you can use other people's tab
> expansion scripts. I know I've seen one posted to this newsgroup that does
> variable expansion and a number of other things...
>
> Perhaps somebody can reply with a link to the script, or perhaps you can
> post a new thread asking about the community's tab expansion addons.



My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
variable display? Justin Rich PowerShell 3 11-28-2007 01:50 AM
Variable value question Riggs PowerShell 3 04-13-2007 09:10 AM
RE: variable identification Rob Campbell PowerShell 1 03-28-2007 04:02 AM
Set-Variable Fred J. PowerShell 3 10-25-2006 12:39 PM
How can I ensure that a variable is a built-in powershell variable? Sung M Kim PowerShell 7 09-22-2006 06:28 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51