Move flashing prompt sign away from left edge of PowerShell window

Discuss other programming languages besides AutoHotkey
User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Move flashing prompt sign away from left edge of PowerShell window

14 Sep 2023, 08:39

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

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

Code: Select all

pppp
[where each >>p<< represent a white pause]

Where is that splitting >>:<< sign coming from? And more importantly: how to get rid of it?
User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

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

06 Jan 2024, 06:14

This works

Write-Host "`r" # This clears the line
$Prompt = " " * 3 + " " # This last separate single white space can be entirely removed or changed into some other sign / text
Write-Host $Prompt -NoNewline
Read-Host


Well- kind off. Because even if I put this at the very top of a larger script or make the whole PS1 file consist of only this code then I still get to see the initial prompt sign(s) being right next to the left edge of PowerShell window [until the code reaches the point of displaying the prompt sign being space away in the line ready for input from user]

So does anyone have some other ideas how to move every prompt sign from the left edge; from the get-go and without using external files with profiles of some kind?

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 115 guests