Differences

This shows you the differences between the selected revisions of the page.

2020-07-15 2020-07-15
restoring previous required version (martin) Bug 1888: Display session name and operation status in console title of Keep Local Directory up to Date extension (martin)
Line 25: Line 25:
# @description  Periodically scans for changes in a remote directory and ^ # @description  Periodically scans for changes in a remote directory and ^
#                  reflects them on a local directory #                  reflects them on a local directory
-# @version      7+# @version      8
# @homepage    ~~SELF~~ # @homepage    ~~SELF~~
# @require      WinSCP 5.16 # @require      WinSCP 5.16
Line 80: Line 80:
        throw $e         throw $e
    }     }
 +}
 +
 +function SetConsoleTitle ($status)
 +{
 +    $Host.UI.RawUI.WindowTitle = "$($sessionOptions.ToString()) - $status"
} }
Line 99: Line 104:
        Write-Host "Connecting..."         Write-Host "Connecting..."
 +        SetConsoleTitle "Connecting"
        $session.Open($sessionOptions)         $session.Open($sessionOptions)
Line 104: Line 110:
        {         {
            Write-Host -NoNewline "Looking for changes..."             Write-Host -NoNewline "Looking for changes..."
 +            SetConsoleTitle "Looking for changes"
            try             try
            {             {
Line 118: Line 125:
                {                 {
                    Write-Host "Synchronizing $($differences.Count) change(s)..."                     Write-Host "Synchronizing $($differences.Count) change(s)..."
 +                    SetConsoleTitle "Synchronizing changes"
                    Beep                     Beep
Line 161: Line 169:
            }             }
-            Write-Host "Waiting for $interval seconds, press Ctrl+C to abort..."+            SetConsoleTitle "Waiting"
            $wait = [int]$interval             $wait = [int]$interval
            # Wait for 1 second in a loop, to make the waiting breakable             # Wait for 1 second in a loop, to make the waiting breakable
            while ($wait -gt 0)             while ($wait -gt 0)
            {             {
 +                Write-Host -NoNewLine "`rWaiting for $wait seconds, press Ctrl+C to abort... "
                Start-Sleep -Seconds 1                 Start-Sleep -Seconds 1
                $wait--                 $wait--
            }             }
 +            Write-Host
            Write-Host             Write-Host
        }         }
Line 175: Line 185:
    finally     finally
    {     {
 +        Write-Host # to break after "Waiting..." status
        Write-Host "Disconnecting..."         Write-Host "Disconnecting..."
        # Disconnect, clean up         # Disconnect, clean up
Line 184: Line 195:
    $continueOnError = $True     $continueOnError = $True
    HandleException $_     HandleException $_
 +    SetConsoleTitle "Error"
} }

Last modified: by martin