{"id":27233828,"url":"https://github.com/mdgrs-mei/dynamictitle","last_synced_at":"2025-04-10T15:20:22.919Z","repository":{"id":154971549,"uuid":"612652790","full_name":"mdgrs-mei/DynamicTitle","owner":"mdgrs-mei","description":"A PowerShell module for advanced console title customizations.","archived":false,"fork":false,"pushed_at":"2023-07-19T01:04:05.000Z","size":85,"stargazers_count":71,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T16:47:39.000Z","etag":null,"topics":["console","powershell","terminal"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdgrs-mei.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-03-11T15:31:40.000Z","updated_at":"2024-12-09T00:10:28.000Z","dependencies_parsed_at":"2024-01-15T16:51:36.749Z","dependency_job_id":null,"html_url":"https://github.com/mdgrs-mei/DynamicTitle","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdgrs-mei%2FDynamicTitle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdgrs-mei%2FDynamicTitle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdgrs-mei%2FDynamicTitle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdgrs-mei%2FDynamicTitle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdgrs-mei","download_url":"https://codeload.github.com/mdgrs-mei/DynamicTitle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248243230,"owners_count":21071054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console","powershell","terminal"],"created_at":"2025-04-10T15:20:22.054Z","updated_at":"2025-04-10T15:20:22.906Z","avatar_url":"https://github.com/mdgrs-mei.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# DynamicTitle\n\n[![GitHub license](https://img.shields.io/github/license/mdgrs-mei/DynamicTitle)](https://github.com/mdgrs-mei/DynamicTitle/blob/main/LICENSE)\n[![PowerShell Gallery](https://img.shields.io/powershellgallery/p/DynamicTitle)](https://www.powershellgallery.com/packages/DynamicTitle)\n[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/DynamicTitle)](https://www.powershellgallery.com/packages/DynamicTitle)\n\n[![Pester Test](https://github.com/mdgrs-mei/DynamicTitle/actions/workflows/pester-test.yml/badge.svg)](https://github.com/mdgrs-mei/DynamicTitle/actions/workflows/pester-test.yml)\n    \n[![Hashnode](https://img.shields.io/badge/Hashnode-2962FF?style=for-the-badge\u0026logo=hashnode\u0026logoColor=white)](https://mdgrs.hashnode.dev/building-your-own-terminal-status-bar-in-powershell)\n\n*DynamicTitle* is a PowerShell module for advanced console title customizations.\n\n![DynamicTitle](https://github.com/mdgrs-mei/DynamicTitle/assets/81177095/e606e65b-6a42-4e0c-987a-4df3e2f412f3)\n\n\u003c/div\u003e\n\nThe module provides you with the ability to set the console title from a background thread. Unlike the prompt string, it can show information without blocking or being blocked by the main thread.\n\n## Requirements\n\nThis module has been tested on:\n\n- Windows 10, Windows 11, Ubuntu 20.04 and macOS\n- Windows PowerShell 5.1 and PowerShell 7.3\n\n## Installation\n\n*DynamicTitle* is available on the PowerShell Gallery. You can install the module with the following command:\n\n```powershell\nInstall-Module -Name DynamicTitle -Scope CurrentUser\n```\n\n## Basic Usage\n\nThis one-liner shows a live-updating clock on the title bar. The specified ScriptBlock is called periodically at a certain interval on a background thread. The module sets the console title to the string that is returned by the ScriptBlock.\n\n```powershell\nStart-DTTitle {Get-Date}\n```\n![LiveClock](https://github.com/mdgrs-mei/DynamicTitle/assets/81177095/048aa512-a654-40e9-8187-2d2018eff9b9)\n\nIf an array is returned from the script block, they are shown with a vertical scrolling.\n\n```powershell\nStart-DTTitle {'🌷 Hello', '🌼 World'}\n```\n\n![VerticalScroll](https://github.com/mdgrs-mei/DynamicTitle/assets/81177095/d48edd3a-5063-48e4-a231-5a1d80ea5489)\n\nIf the title width is fixed by your terminal app or you want to limit the width, you can specify `HorizontalScrollFrameWidth` parameter. The title text Horizontally scrolls when its length is longer than the parameter.\n\n```powershell\nStart-DTTitle {\n    '🍷 Showing a long text as a title 🍸'\n} -HorizontalScrollFrameWidth 25\n```\n\n![HorizontalScroll](https://github.com/mdgrs-mei/DynamicTitle/assets/81177095/375bf799-6db3-4fd6-a2a0-4313335a9fe7)\n\n## Jobs\n\nAlthough the ScriptBlock specified to `Start-DTTitle` runs on another thread to avoid blocking, sometimes you need to get information from the main thread such as Current Directory, or you might need another thread to get some information that takes long time to process. For this purpose, the module provides you with three types of job objects. In either case, you can get the job output in a thread-safe way like this:\n\n```powershell\n$output = Get-DTJobLatestOutput $job\n```\n\n### CommandPreExecutionCallback Job\n\nWith this job, you can register a ScriptBlock that is called right before the command entered on the console is executed. The command string is passed as `$args[0]`. This job is useful to get the command running on the main thread or the command start time.\n\n```powershell\n$job = Start-DTJobCommandPreExecutionCallback -ScriptBlock {\n    param($command)\n    $command, (Get-Date)\n}\n\nStart-DTTitle {\n    param($job)\n    $commandString, $commandStartDate = Get-DTJobLatestOutput $job\n    # ...\n} -ArgumentList $job\n```\n\n### PromptCallback Job\n\nPromptCallback job registers a ScriptBlock that is called right before the Prompt function is called. This job can be used to get the current directory for example.\n\n```powershell\n$job = Start-DTJobPromptCallback -ScriptBlock {Get-Location}\n\nStart-DTTitle {\n    param($job)\n    $currentDirectory = Get-DTJobLatestOutput $job\n    # ...\n} -ArgumentList $job\n```\n\n### BackgroundThreadTimer Job\n\nBackgroundTimerJob starts a new thread and calls a ScriptBlock periodically at the specified interval on the thread. It is good for tasks that take long time to finish so as not to block the title update thread.\n\n```powershell\n$job = Start-DTJobBackgroundThreadTimer -ScriptBlock {\n    # Get weather\n    Invoke-RestMethod https://wttr.in/?format=\"%c%t\"\n} -IntervalMilliseconds 60000\n\nStart-DTTitle {\n    param($job)\n    $weather = Get-DTJobLatestOutput $job\n    # ...\n} -ArgumentList $job\n```\n\n## Legacy Application Mode\n\nWhen command line applications are executed on the main thread, the host saves the title string before calling the application and resets it when the application returns. This behavior sometimes causes a blink on the title as you are changing the title on a background thread.\n\n`Enter-DTLegacyApplicationMode` calls `$host.NotifyBeginApplication()` to notify the host that the subsequent commands are all legacy command line applications, and therefore the title reset behavior on every command call is suppressed. Note that this workaround stops all the state restore from the command line applications which may cause some other issues.\n\n```powershell\nStart-DTTitle {Get-Date}\nEnter-DTLegacyApplicationMode\n# Calling command line applications here does not cause a blink on the title.\ngit status -s\n# ...\nExit-DTLegacyApplicationMode\n# This call causes a blink.\ngit status -s\n```\n\n## Terminal Settings Recommendations\n\n- If you are using Windows Terminal, there is a setting called `Tab width mode`. Setting it to `Title length` or `Compact` should be better for longer titles.\n\n- [Hyper](https://github.com/vercel/hyper) terminal allows you to change the appearance of the title by css, such as font and size. It's a good fit for this module if you want the title to stand out or want to use special emojis.\n\n## Examples\n\nExamples are included in the module. You can play an example DynamicTitle with `Start-DTExample` function. The tab completion for the `Name` parameter helps you find available examples.\n\n```powershell\nStart-DTExample -Name CommandExecutionTime\n```\n\n`Get-DTExamplesPath` returns the path where the example scripts are stored.\n\n```powershell\nPS D:\\\u003e Get-ChildItem (Get-DTExamplesPath)\n\nMode                 LastWriteTime         Length Name\n----                 -------------         ------ ----\n-a---           3/26/2023  1:56 PM           4095 AllInOne.ps1\n-a---           3/26/2023  1:56 PM           1810 CommandExecutionTime.ps1\n-a---           3/26/2023  1:56 PM           1956 GitStatus.ps1\n-a---           3/26/2023  1:56 PM           1512 StatusBar.ps1\n```\n\n## Get-Help\n\n`Get-Command` can list all the available functions in the module:\n\n```powershell\nGet-Command -Module DynamicTitle\n```\n\nTo get the detailed help of a function, try:\n\n```powershell\nGet-Help Start-DTTitle -Full\n```\n\n## Changelog\n\nChangelog is available [here](https://github.com/mdgrs-mei/DynamicTitle/blob/main/CHANGELOG.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdgrs-mei%2Fdynamictitle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdgrs-mei%2Fdynamictitle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdgrs-mei%2Fdynamictitle/lists"}