Windows Vista Forums

First basic configuration
  1. #1


    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

  2. #2


    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



    > 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

  3. #3


    Thorsten Kampe Guest

    Re: First basic configuration

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

    > 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

  4. #4


    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



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

    >> 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

  5. #5


    Shay Levi Guest

    Re: First basic configuration



    > 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



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

    >> 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

  6. #6


    Thorsten Kampe Guest

    Re: First basic configuration

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

    > > 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

  7. #7


    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

  8. #8


    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

  9. #9


    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:

    > 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

First basic configuration problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
OT: HDD Configuration Rob Vista hardware & devices 5 25 Jan 2008
have window vista basic.understand basic don't have fax & scan jay sureka Vista print fax & scan 4 07 Jan 2008
WLAN in Vista Basic LOSE configuration everytime I shut down laptop lorexx70 Vista General 4 15 Sep 2007
Ram Configuration Jamin Vista installation & setup 6 21 Jan 2007
PC Configuration nlcautela Vista installation & setup 4 23 Jun 2006