Page 1 of 1

Move flashing prompt sign away from left edge of PowerShell window

Posted: 14 Sep 2023 07:35
by DOSadnie
Is there a way to move the prompt sign in PowerShell [an also CMD] window more toward middle / right side of a it? So that a new empty line would flash it prompt sign as not being adjacent to the left edge of the window when awaiting for input from user?

This almost does what I need

Code: Select all

# -The countdown function
function Start-Countdown {
    $Countdown = 2
    while ($Countdown -gt 0) {
        Write-Host ("Countdown: $Countdown seconds") -NoNewline
        Start-Sleep -Seconds 1
        $Countdown--
        Write-Host "`r" -NoNewline
    }
}

# Start the countdown
Start-Countdown

# Clear the countdown line
Write-Host "`r"

# Modifications of prompt
$Prompt = " " * 2 + ""
Write-Host $Prompt -NoNewline

# Wait for input from user
Read-Host ""
as it shows
ppp:p_
instead of
pppp_
[where each >>p<< represent a white pause]

Where is that splitting >>:<< sign coming from? And more importantly: how to get rid of it?

Re: Move flashing prompt sign away from left edge of PowerShell window

Posted: 21 Sep 2023 01:46
by DOSadnie
I have managed to co come up with a partial solution

This script

Code: Select all

$COUNTDOWN = 3

Write-Host
Write-Host "   Endng in"
Write-Host
Write-Host "   $COUNTDOWN"
Write-Host
Write-Host "   seconds"
Write-Host

Start-Sleep -Seconds $COUNTDOWN
 
Write-Host
Write-Host
Write-Host "   Script has been executed"
Write-Host

Write-Host "`r"   # This clears the line

$Prompt = " " * 2 + " "   # That separate single white space at the end of this line can be entirely removed or changed into whatever sign or text is desired
Write-Host $Prompt -NoNewline

Read-Host
will leave user with the third / last prompt line / sign being moved away from the left edge of the window - but so far I have been unsuccessful with making look like so all of the prompt signs [the initial one and the second during the countdown in this new example from this post]

Re: Move flashing prompt sign away from left edge of PowerShell window

Posted: 22 Oct 2023 09:02
by DOSadnie
Does anyone have any ideas about how to do this?

Re: Move flashing prompt sign away from left edge of PowerShell window

Posted: 22 Oct 2023 09:30
by ShadowThief
Are you just looking for prompt $S$S$P$G?

Re: Move flashing prompt sign away from left edge of PowerShell window

Posted: 18 Nov 2023 11:45
by DOSadnie
If you mean replacing line

Code: Select all

$Prompt = " " * 2 + " "
with either

Code: Select all

$Prompt = "$S$S$P$G"
$Prompt = $S$S$P$G
$Prompt $S$S$P$G
then this does not work

Re: Move flashing prompt sign away from left edge of PowerShell window

Posted: 28 Dec 2023 03:24
by DOSadnie
DOSadnie wrote:
18 Nov 2023 11:45
If you mean replacing line
[...]
Well, did you?

Re: Move flashing prompt sign away from left edge of PowerShell window

Posted: 18 Feb 2024 03:39
by DOSadnie
I made basic tests files with just

Code: Select all

prompt $S$S$S$P$G
Read-Host

Code: Select all

function prompt {
    "$(' ' * 3)$(Get-Location)> "
}
Read-Host

Code: Select all

function prompt {
    Write-Host (" " * 3) -NoNewline
    return " $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
}
Read-Host
but they all were showing to me the prompt sign adjacent next to left edge of PS window


How else can I try to move the prompt to the right?

Re: Move flashing prompt sign away from left edge of PowerShell window

Posted: 18 Feb 2024 09:00
by Squashman
Seems to work just fine for me.

Code: Select all

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Squashman> function prompt {Write-Host (" " * 10) -NoNewline}
          PS>function prompt {Write-Host (" " * 15) -NoNewline}
               P> function prompt {Write-Host (" " * 20) -NoNewline}
                    PS>