Skip to content

#2226: show IDEasy project, workspace and repository in the git-bash window title - #2227

Open
maybeec wants to merge 2 commits into
devonfw:mainfrom
maybeec:feature/2226-terminal-title
Open

#2226: show IDEasy project, workspace and repository in the git-bash window title#2227
maybeec wants to merge 2 commits into
devonfw:mainfrom
maybeec:feature/2226-terminal-title

Conversation

@maybeec

@maybeec maybeec commented Jul 28, 2026

Copy link
Copy Markdown
Member

This PR fixes #2226

Git Bash bakes a window title escape sequence into PS1 (see /etc/profile.d/git-prompt.sh), so the title is rewritten to MINGW64:«current-directory» on every prompt and cannot be set permanently. All git-bash tabs and windows therefore look alike in the taskbar and in Alt+Tab.

This PR removes that sequence and writes an IDEasy specific title instead, so you can see at a glance which project and workspace a shell is initialized for.

Implemented changes:

  • Added _ide_title to cli/src/main/package/functions, which writes the terminal title and degrades gracefully depending on the available context:

    Situation Title
    Inside a repository ideasy>devonfw>main>IDEasy
    Inside a workspace, outside any repository ideasy>devonfw>main
    Inside a project, outside any workspace ideasy>devonfw
    Outside any IDEasy project ideasy
  • The repository is the counterpart of icd -r, i.e. the first folder below the workspace. Consistent with the implicit -r resolution, hidden folders (e.g. .vscode) are not treated as repositories, and for a nested repository such as backend/core only the top-level folder is shown to keep the title short.

  • Workspace and repository are derived from PWD and not from the WORKSPACE variable, because ideasy env --bash always emits WORKSPACE="main" as a default - even when the current directory is completely outside IDE_ROOT. As a side effect the title also follows a plain cd, not only ide/icd.

  • Extracted _ide_path_segment as the single place that determines a path segment below a base directory. It is used for the workspace and the repository of the title as well as for the project inference in _icd_project_dir, which previously duplicated this logic. Its result is passed via a variable rather than echoed, so that no subshell is forked - _ide_title runs on every prompt and process creation is expensive on Windows.

  • The git-bash title sequence is removed from PS1 and _ide_title is hooked into PROMPT_COMMAND. Both steps are idempotent, so sourcing the functions file again (e.g. via source ~/.bashrc) does not duplicate the hook or strip PS1 twice.

  • The whole block is guarded by the existing _ide_is_msys helper plus a BASH_VERSION check, so macOS, Linux and Cygwin are not touched at all - their prompt is configured by the user or the distribution. The BASH_VERSION check is needed because the functions file is also sourced from zsh, which has no PROMPT_COMMAND (it uses precmd).

  • An existing PROMPT_COMMAND is preserved, including the array form supported since bash 5.1. The IDEasy hook is prepended so a user's own hook runs afterwards and can still override the title.

  • The PS1 rewrite only triggers when the title sequence is at the very beginning of the prompt, so a custom prompt (e.g. via the ~/.config/git/git-prompt.sh hook honored by git-bash) is left untouched.

  • Added 18 tests to cli/src/test/functions-test.sh and documented the behavior in documentation/advanced-tooling-windows.adoc.


Testing instructions

Automated:

  1. Run bash cli/src/test/functions-test.sh - this is the same entry point CI uses (.github/workflows/build-pr.yml). All tests must pass.
    Note that the zsh cases are skipped when zsh is not on the PATH (e.g. on Windows). They were verified on ubuntu:24.04 with zsh 5.9, where the suite reports 43 of 43 passed, including zsh -n parsing of the functions file.
  2. Run bash cli/src/test/icd-completion-test.sh - _icd_project_dir was refactored, so the icd completion tests must still pass.

Manual (Windows, git-bash):

  1. Open a git-bash terminal in an IDEasy project and run source ~/.bashrc.
  2. icd -r into a repository - the window/tab title shows ideasy>«your-project»>«workspace»>«repository».
  3. cd .. up into the workspace - the title shows ideasy>«your-project»>«workspace».
  4. cd into a hidden folder of the workspace (e.g. .vscode) - the title still shows ideasy>«your-project»>«workspace».
  5. icd into the project root (outside workspaces) - the title shows ideasy>«your-project».
  6. cd ~ and run ide - the title shows ideasy.
  7. Verify the visible prompt itself is unchanged: colors, $MSYSTEM, the working directory and the git branch from __git_ps1 are all still there.
  8. Verify icd -p«Tab», icd -w«Tab» and icd -r«Tab» still complete as before.

Manual (macOS/Linux, regression):

  1. Open a terminal in an IDEasy project and run source ~/.bashrc (or ~/.zshrc).
  2. Verify your prompt and window title behave exactly as before - IDEasy must not change either.

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

…w title

Git Bash rewrites the window title on every prompt via an escape sequence in
PS1, so terminal tabs and windows cannot be told apart. Remove that sequence
and write "ideasy>«project»>«workspace»" instead, degrading to
"ideasy>«project»" outside a workspace and "ideasy" outside any project.

The workspace is derived from PWD because the WORKSPACE variable always
defaults to "main", even outside of any workspace or IDEasy project.

Limited to git-bash: on macOS and Linux the prompt is configured by the user
or the distribution and must not be touched, and zsh has no PROMPT_COMMAND.
@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Jul 28, 2026
@maybeec maybeec added enhancement New feature or request windows specific for Microsoft Windows OS bash bash, zsh, git-bash (integration, scripts) usability usage should be more intuitive labels Jul 28, 2026
…egment detection

The title now also shows the repository below the workspace, e.g.
"ideasy>devonfw>main>IDEasy". Like "icd -r" hidden folders are not treated as
repositories and for a nested repository the top-level folder is shown.

Extract _ide_path_segment as the single place that determines a path segment
below a base directory and use it for the workspace and repository of the
title as well as for the project inference of _icd_project_dir. The result is
passed via a variable instead of being echoed to avoid a subshell per prompt.
@maybeec maybeec changed the title #2226: show IDEasy project and workspace in the git-bash window title #2226: show IDEasy project, workspace and repository in the git-bash window title Jul 28, 2026
@maybeec maybeec moved this from 🆕 New to Team Review in IDEasy board Jul 28, 2026
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 30397974379

Coverage increased (+0.02%) to 72.614%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 1 coverage regression across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java 1 78.33%

Coverage Stats

Coverage Status
Relevant Lines: 16997
Covered Lines: 12866
Line Coverage: 75.7%
Relevant Branches: 7603
Covered Branches: 4997
Branch Coverage: 65.72%
Branches in Coverage %: Yes
Coverage Strength: 3.21 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bash bash, zsh, git-bash (integration, scripts) enhancement New feature or request usability usage should be more intuitive windows specific for Microsoft Windows OS

Projects

Status: Team Review

Development

Successfully merging this pull request may close these issues.

Show IDEasy project, workspace and repository in the Git Bash / Windows Terminal window title

2 participants