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

First basic configuration

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-10-2008   #1 (permalink)
Thorsten Kampe
Guest


 

First basic configuration

Hi,

I'm new to PowerShell and I'd like to do some basic configuration for
the shell:

1. I would like to set up my prompt as in

user@xxxxxx[current_working_directory]>

where "current_working_directory" should be just the directory (not
the full path to the directory) and in dark cyan (on black) and ">"
should be in light cyan (the rest should be just standard white on
black).

Is that doable and what would the prompt function look like?

2. I'd like to assign ^D to do "exit"... Is that doable?

3. What do I have to do to get a persistent history?


Thorsten

My System SpecsSystem Spec
Old 01-10-2008   #2 (permalink)
Shay Levi
Guest


 

Re: First basic configuration


Hi Thorsten,


1. You can't use lightCyan as a console color, possible color values are:
Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta
, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White.

Include this function in your $profile and restart the shell:

function prompt{
write-host -NoNewLine -foreground cyan "$env:username@$env:computername[$(split-path
-leaf $pwd)]>"
" `b "
}


2. You can't.

3. See http://blogs.msdn.com/powershell/arc...01/653194.aspx



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> Hi,
>
> I'm new to PowerShell and I'd like to do some basic configuration for
> the shell:
>
> 1. I would like to set up my prompt as in
>
> user@xxxxxx[current_working_directory]>
>
> where "current_working_directory" should be just the directory (not
> the full path to the directory) and in dark cyan (on black) and ">"
> should be in light cyan (the rest should be just standard white on
> black).
>
> Is that doable and what would the prompt function look like?
>
> 2. I'd like to assign ^D to do "exit"... Is that doable?
>
> 3. What do I have to do to get a persistent history?
>
> Thorsten
>

My System SpecsSystem Spec
Old 01-10-2008   #3 (permalink)
Thorsten Kampe
Guest


 

Re: First basic configuration

* Shay Levi (Thu, 10 Jan 2008 21:05:37 +0000 (UTC))
Quote:

> 1. You can't use lightCyan as a console color, possible color values are:
> Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta
> , DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White.
>
> Include this function in your $profile and restart the shell:
>
> function prompt{
> write-host -NoNewLine -foreground cyan "$env:username@$env:computername[$(split-path
> -leaf $pwd)]>"
> " `b "
> }
Doesn't work: I get this output
cmdlet split-path at command pipeline position 1
Supply values for the following parameters:
Path[0]:

I press ENTER and then:
PS>

It also seems that you can only colour one whole line (and not parts
of it)...?
Interesting but kind of pointless. First, I have to remember to leave
the shell with bye (instead of "exit"), then I have to remember to
type "get-history" and this just displays the history - what is that
useful for - instead of going into the history buffer (Cursor up and
down).


Thorsten
My System SpecsSystem Spec
Old 01-10-2008   #4 (permalink)
Shay Levi
Guest


 

Re: First basic configuration

Specify the -path parameter:

....computername[$(split-path -path $pwd -Leaf)]..

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> * Shay Levi (Thu, 10 Jan 2008 21:05:37 +0000 (UTC))
>
Quote:

>> 1. You can't use lightCyan as a console color, possible color values
>> are:
>> Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta
>> , DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta,
>> Yellow, White.
>> Include this function in your $profile and restart the shell:
>>
>> function prompt{
>> write-host -NoNewLine -foreground cyan
>> "$env:username@$env:computername[$(split-path
>> -leaf $pwd)]>"
>> " `b "
>> }
> Doesn't work: I get this output
> cmdlet split-path at command pipeline position 1
> Supply values for the following parameters:
> Path[0]:
> I press ENTER and then:
>
> It also seems that you can only colour one whole line (and not parts
> of it)...?
> > Interesting but kind of pointless. First, I have to remember to leave
> the shell with bye (instead of "exit"), then I have to remember to
> type "get-history" and this just displays the history - what is that
> useful for - instead of going into the history buffer (Cursor up and
> down).
>
> Thorsten
>


My System SpecsSystem Spec
Old 01-10-2008   #5 (permalink)
Shay Levi
Guest


 

Re: First basic configuration


Quote:

> It also seems that you can only colour one whole line (and not parts of
it)...?


function prompt{
write-host -NoNewLine -fore cyan "$env:username@$env:computername["
write-host -NoNewLine -fore DarkCyan -back black "$(split-path -leaf $pwd)"
write-host -NoNewLine -fore cyan "]>"
" `b "
}



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> * Shay Levi (Thu, 10 Jan 2008 21:05:37 +0000 (UTC))
>
Quote:

>> 1. You can't use lightCyan as a console color, possible color values
>> are:
>> Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta
>> , DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta,
>> Yellow, White.
>> Include this function in your $profile and restart the shell:
>>
>> function prompt{
>> write-host -NoNewLine -foreground cyan
>> "$env:username@$env:computername[$(split-path
>> -leaf $pwd)]>"
>> " `b "
>> }
> Doesn't work: I get this output
> cmdlet split-path at command pipeline position 1
> Supply values for the following parameters:
> Path[0]:
> I press ENTER and then:
>
> It also seems that you can only colour one whole line (and not parts
> of it)...?
> > Interesting but kind of pointless. First, I have to remember to leave
> the shell with bye (instead of "exit"), then I have to remember to
> type "get-history" and this just displays the history - what is that
> useful for - instead of going into the history buffer (Cursor up and
> down).
>
> Thorsten
>

My System SpecsSystem Spec
Old 01-10-2008   #6 (permalink)
Thorsten Kampe
Guest


 

Re: First basic configuration

* Shay Levi (Thu, 10 Jan 2008 21:50:16 +0000 (UTC))
Quote:
Quote:

> > It also seems that you can only colour one whole line (and not parts of
> it)...?
>
> function prompt{
> write-host -NoNewLine -fore cyan "$env:username@$env:computername["
> write-host -NoNewLine -fore DarkCyan -back black "$(split-path -leaf $pwd)"
> write-host -NoNewLine -fore cyan "]>"
> " `b "
> }
Thanks, got it now exactly as I wanted it... Thanks

function prompt
{
write-host -NoNewLine "$env:username@$env:computername["
write-host -NoNewLine -fore DarkCyan "$(split-path -leaf $pwd)"
write-host -NoNewLine "]"
write-host -NoNewLine -fore cyan ">"
" `b "
}


Thorsten
My System SpecsSystem Spec
Old 01-10-2008   #7 (permalink)
Karl Prosser[MVP]
Guest


 

Re: First basic configuration

Powershell Plus has this sort of functionality, we have some basic
hidden apis to bind.. but what would the ideal syntax be for you. I mean
how would you like to bind hotkeys to specific code etc?

-Karl
My System SpecsSystem Spec
Old 01-11-2008   #8 (permalink)
Jon
Guest


 

Re: First basic configuration

For those who weren't aware, you can also use ctrl-break to exit
PowerShell.

--
Jon

My System SpecsSystem Spec
Old 01-11-2008   #9 (permalink)
Bob Landau
Guest


 

Re: First basic configuration

I suppose it could be done either via the application hosting Powershell via
a dialog box or command line. One possibility would be

Add-Shortcut [-shortcutType] {<Scriptblock>| <Function>} [[-key] <char>]
[[-value] <object>


"Karl Prosser[MVP]" wrote:
Quote:

> Powershell Plus has this sort of functionality, we have some basic
> hidden apis to bind.. but what would the ideal syntax be for you. I mean
> how would you like to bind hotkeys to specific code etc?
>
> -Karl
>
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
configuration Graziella Vista mail 5 07-02-2008 11:54 AM
configuration Graziella Vista mail 1 04-23-2008 04:07 PM
have window vista basic.understand basic don't have fax & scan jay sureka Vista print fax & scan 4 01-07-2008 01:02 PM
WLAN in Vista Basic LOSE configuration everytime I shut down laptop lorexx70 Vista General 4 09-15-2007 04:12 PM
PC Configuration nlcautela Vista installation & setup 4 06-23-2006 04:36 AM


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