-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refresh Git widgets periodically #5036
Comments
@Darker21 by automatically, do you mean on an interval? There's no way to reload only the git part, as the prompt is a string. We could however reload the prompt on an interval in case it wasn't reloaded on for a predefined timeout. This would only work for shells that have a way to reload the prompt, which is a few I believe. What shell do you use? I might be able to craft something that work together with you before adding that to our shell scripts and configuration. |
An interval was what I had in mind, I'm using PowerShell within Windows Terminal. |
@Darker21 you could try adding this logic AFTER initialising oh-my-posh, this wasn't tested yet as I'm not on my laptop ATM. # Create a timer object with a specific interval and a starttime
$timer = New-Object -Type Timers.Timer
$timer.Interval = 3000 # milliseconds, in this case 3 seconds
# Register an event for every passed interval
Register-ObjectEvent -InputObject $timer -EventName Elapsed -SourceIdentifier "Timer.Elapsed" -Action {
# reload the prompt using PSReadLine
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
} | Out-Null
function Start-Timer {
# stop the timer when it's running
if ($timer.Enabled) {
$timer.Stop()
}
# Start the timer
$timer.Start()
}
New-Alias -Name 'Set-PoshContext' -Value 'Start-Timer' -Scope Global -Force |
That's what I was looking for, it's working as expected, thanks for that |
@Darker21 I might add this natively so I'm leaving this open in the meantime. Or maybe the snippet helps someone do a contribution. It's a cool feature to have. No stale prompts. |
I think it would be a good addition and could open up possibilities for other prompt options such as the Spotify one currently (#4732) open to 'refresh' and provide 'real time' updates |
Hello, I need this exact feature (be able to set a reload interval in ms), for a different purpose I am using zsh as my shell, I am not sure how to reload oh-my-posh, I tried Would love this as a feature, but in the meantime, if you can please provide me with a script/command to reload oh-my-posh, that'd be great |
It’s interesting. For some reason, on my PC, the command line blinks instead of refreshing. |
Code of Conduct
What would you like to see changed/added?
Was wondering if it would be possible to update the git widgets details automatically rather than having to enter a new line to refresh the state shown on the widgets (i.e. file changes, incoming changes, outgoing commits).
Not sure if this is 100% possible but would be a nice feature to have for people like myself using the terminal in IDE's such as VS Code who prefer the terminal to the extensions for git
The text was updated successfully, but these errors were encountered: