{"thread":{"id":"62391","subject":"bash prompt evaporates in subdirectories","startedAt":"2024-10-22T15:13:01Z","lastAt":"2024-10-24T20:23:50Z","messageCount":10,"participants":["Matěj Cepl","Taylor Blau","avih"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"505835","messageId":"D52FCQ2F409N.1S5Q8XRAX5YU7@cepl.eu","threadId":"62391","inReplyTo":null,"subject":"bash prompt evaporates in subdirectories","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2024-10-22T15:02:55Z","receivedAt":"2024-10-22T15:13:01Z","isPatch":false,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\ncd subdirectory/\n\nWhat did you expect to happen? (Expected behavior)\nbash prompt would be still active and showing the status of my checkout (possibly even limited to the current subdirectory, but it is not necessary)\n\nWhat happened instead? (Actual behavior)\nPart of the bash prompt related to git (e.g., current branch) evaporates\n\nWhat's different between what you expected and what actually happened?\nI would like to have current branch and status even in subdirectories\n\nAnything else you want to add:\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.47.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nlibcurl: 8.10.1\nOpenSSL: OpenSSL 3.1.4 24 Oct 2023\nzlib: 1.3.1\nuname: Linux 6.11.3-1-default #1 SMP PREEMPT_DYNAMIC Fri Oct 11 06:48:36 UTC 2024 (7881e90) x86_64\ncompiler info: gnuc: 14.2\nlibc info: glibc: 2.40\n$SHELL (typically, interactive shell): /usr/bin/bash\nBash version: GNU bash, version 5.2.37(1)-release (x86_64-suse-linux)\n\n[Enabled Hooks]\n"},{"id":"505838","messageId":"ZxfKbsapf3MAUmcy@nand.local","threadId":"62391","inReplyTo":"D52FCQ2F409N.1S5Q8XRAX5YU7@cepl.eu","subject":"Re: bash prompt evaporates in subdirectories","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-22T15:53:18Z","receivedAt":"2024-10-22T15:53:20Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Tue, Oct 22, 2024 at 05:02:55PM +0200, Matěj Cepl wrote:\n> What did you expect to happen? (Expected behavior)\n>\n> bash prompt would be still active and showing the status of my\n> checkout (possibly even limited to the current subdirectory, but it is\n> not necessary)\n\nAre you using the prompt from contrib/completion/git-prompt.sh? If so, I\nCC'd a couple of folks who have worked recently on that script.\n\nI assume they may find it helpful to know a little more about your\nsetup, including possibly if you have a bisection where the prompt\nstopped working for you when in sub-directories.\n\nThanks,\nTaylor\n"},{"id":"506009","messageId":"D53YJ81WH001.2KRT4KHARKLC4@cepl.eu","threadId":"62391","inReplyTo":"ZxfKbsapf3MAUmcy@nand.local","subject":"Re: bash prompt evaporates in subdirectories","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2024-10-24T10:17:26Z","receivedAt":"2024-10-24T10:17:34Z","isPatch":false,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"On Tue Oct 22, 2024 at 5:53 PM CEST, Taylor Blau wrote:\n> Are you using the prompt from contrib/completion/git-prompt.sh? If so, I\n> CC'd a couple of folks who have worked recently on that script.\n>\n> I assume they may find it helpful to know a little more about your\n> setup, including possibly if you have a bisection where the prompt\n> stopped working for you when in sub-directories.\n\nUnfortunately, I have recently switched from fish (where\neverything works right), so I don’t know when exactly the break happened.\n\nUsing openSUSE/MicroOS-based system with all the work done in\ndistrobox containers (with openSUSE/Tumbleweed inside).\n\nNot sure, what else I can say, or how to better debug.\n\nBest,\n\nMatěj\n-- \nhttp://matej.ceplovi.cz/blog/, @mcepl@floss.social\nGPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8\n \nTy zlý dávaj’ ty hodný pryč. // Those evil ones put away those good ones.\n  -- Magda Ceplová\n\n"},{"id":"506019","messageId":"1101848017.3146876.1729770380522@mail.yahoo.com","threadId":"62391","inReplyTo":"D53YJ81WH001.2KRT4KHARKLC4@cepl.eu","subject":"Re: bash prompt evaporates in subdirectories","fromName":"avih","fromEmail":"avihpit@yahoo.com","sentAt":"2024-10-24T11:46:20Z","receivedAt":"2024-10-24T12:26:49Z","isPatch":false,"sender":{"key":"avihpit@yahoo.com","avatar":"https://avatars.githubusercontent.com/u/2164962?v=4"},"body":" > On Tue Oct 22, 2024 at 5:53 PM CEST, Taylor Blau wrote:\n> > Are you using the prompt from contrib/completion/git-prompt.sh? If so, I\n> > CC'd a couple of folks who have worked recently on that script.\n> >\n> > I assume they may find it helpful to know a little more about your\n> > setup, including possibly if you have a bisection where the prompt\n> > stopped working for you when in sub-directories.\n>\n> Unfortunately, I have recently switched from fish (where\n> everything works right), so I don’t know when exactly the break happened.\n>\n> Using openSUSE/MicroOS-based system with all the work done in\n> distrobox containers (with openSUSE/Tumbleweed inside).\n>\n> Not sure, what else I can say, or how to better debug.\n\nYou can help by providing the following:\n\n- What is the \"innermost\" distro where this happens? Thumbleweed?\n  which version?\n\n- Which git version do you have installed? How did you install it?\n\n- How did you install the git-prompt support?\n\n- Which shell do you use? (bash? zsh? something else?)\n\n- How is the (git) prompt set in your shell startup file? (~/.bashrc,\n  or ~/.profile, etc). If you don't know exactly, then can you please\n  attach your shell startup files?\n\n- Can you provide a sample repository to clone which reproduces the\n  issue? for instance, you can pick a small repo from github.\n\n- What are the steps to reproduce the issue? is it enough to \"cd\"\n  into an existing sub-dir at the git dir? or is it only broken\n  when creating an unrelated sub-dir and \"cd\" into it? better yet,\n  provide a 1:... 2:... 3:... steps which reproduce the issue for\n  you, and which others can try to follow.\n\nI tried the following:\n\n1. Download the latest Thumbleweed snapshot and boot in a VM:\n   https://download.opensuse.org/tumbleweed/iso/openSUSE-Tumbleweed-XFCE-Live-x86_64-Snapshot20241022-Media.iso\n\n2. In a terminal (default shell is bash 5.2.37(1)):\n   sudo zypper install git  # 2.47.0-1.1\n   sudo zypper install bash-git-prompt\n\n3. The above does NOT install git-prompt.sh which is maintained\n   together with git at the contrib dir. In its README.md:\n   \n     This prompt is a port of the \"Informative git prompt for zsh\"\n     which you can find https://github.com/olivierverdier/zsh-git-prompt\n\n    so I did not try to set it up. If you have an issue with that\n    package then you should report it to the package maintainer.\n\n4.  Download git-prompt.sh from the git contrib dir:\n      curl -o ~/git-prompt.sh https://raw.githubusercontent.com/git/git/refs/tags/v2.47.0/contrib/completion/git-prompt.sh\n      chmod +x ~/git-prompt.sh\n\n5. Add the following lines at the end of ~/.bashrc :\n   \n     . ~/git-prompt.sh\n     PS1='\\w$(__git_ps1)\\n\\$ '\n\n6. Start a new bash shell or new terminal.\n\n7. Clone a sample repo (/shameless plug) and \"cd\" into it:\n     git clone https://github.com/avih/shlolcat\n     cd shlolcat  # the prompt correctly includes \"(master)\"\n\n9. \"cd\" into a subdir:\n     cd c-lolcat  # the prompt still correctly includes \"(master)\"\n\n9. Create an arbitrary additional sub-dir and \"cd\" into it:\n     mkdir xxx\n     cd xxx  # the prompt still correctly includes \"(master)\"\n\n\nSo I can't reproduce such issue with git-prompt.sh which is part\nof the \"git\" repo at contrib/completion/git-prompt.sh .\n\nCheers,\navih\n    \n"},{"id":"506040","messageId":"936191304.3152890.1729773328893@mail.yahoo.com","threadId":"62391","inReplyTo":"1101848017.3146876.1729770380522@mail.yahoo.com","subject":"Re: bash prompt evaporates in subdirectories","fromName":"avih","fromEmail":"avihpit@yahoo.com","sentAt":"2024-10-24T12:35:28Z","receivedAt":"2024-10-24T12:45:40Z","isPatch":false,"sender":{"key":"avihpit@yahoo.com","avatar":"https://avatars.githubusercontent.com/u/2164962?v=4"},"body":" On Thursday, October 24, 2024 at 02:46:21 PM GMT+3, avih <avihpit@yahoo.com> wrote:\n> ...\n>\n> I tried the following:\n>\n> ...\n>\n> 2. In a terminal (default shell is bash 5.2.37(1)):\n>    sudo zypper install git  # 2.47.0-1.1\n>    sudo zypper install bash-git-prompt\n>\n> 3. The above does NOT install git-prompt.sh which is maintained\n>    together with git at the contrib dir. In its README.md:\n>    ...\n>\n> 4.  Download git-prompt.sh from the git contrib dir:\n>       curl -o ~/git-prompt.sh https://raw.githubusercontent.com/git/git/refs/tags/v2.47.0/contrib/completion/git-prompt.sh\n>       chmod +x ~/git-prompt.sh\n\n> 5. Add the following lines at the end of ~/.bashrc :\n>      . ~/git-prompt.sh\n>      PS1='\\w$(__git_ps1)\\n\\$ '\n\nActually, \"sudo zypper install git\" does install the correct script\nat /usr/share/bash-completion/completions/git-prompt.sh\n\nAdditionally, that \"git\" package adds /etc/bash-completion.d/git-prompt\nwhich does source this script automatically on shell startup, therefore\nstep 4 (the curl thing) is not required, and git-prompt.sh is already\nloaded automatically, and so only one line instead of two should be\nadded to ~/.bashrc (as a minimal example):\n\n  PS1='\\w$(__git_ps1)\\n\\$ '\n\nThe rest is the same. Still can't reproduce it with this script.\n\navih\n"},{"id":"506042","messageId":"D542P2ZTHIUJ.2GEJYE41VTC0J@cepl.eu","threadId":"62391","inReplyTo":"1101848017.3146876.1729770380522@mail.yahoo.com","subject":"Re: bash prompt evaporates in subdirectories","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2024-10-24T13:33:09Z","receivedAt":"2024-10-24T13:33:12Z","isPatch":false,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"On Thu Oct 24, 2024 at 1:46 PM CEST, avih wrote:\n> - What is the \"innermost\" distro where this happens? Thumbleweed?\n>   which version?\n\nYes, Tumbleweed (actually MicroOS uses Tumbleweed packages as\nwell), which is a rolling distro and I updated (almost) daily, so\nit is hard to say which version.\n\n> - Which git version do you have installed? How did you install it?\n\nmitmanek:~ $ rpm -qf \"$(which git)\"\ngit-core-2.47.0-1.1.x86_64\nmitmanek:~ $ \n\n> - How did you install the git-prompt support?\n\nUsing the git-prompt.sh from the package, but it seems to be the same as the upstream one in contrib/\n\nmitmanek:~ $ rpm -qf /bin/bash\nbash-5.2.37-14.2.x86_64\nmitmanek:~ $ rpm -qf /usr/share/bash-completion/completions/git-prompt.sh\ngit-core-2.47.0-1.1.x86_64\nmitmanek:~ $ diff -u \\\n    /usr/share/bash-completion/completions/git-prompt.sh \\\n    <(curl -L -s https://github.com/git/git/raw/refs/heads/master/contrib/completion/git-prompt.sh)\nmitmanek:~ $ \n\n> - Which shell do you use? (bash? zsh? something else?)\n\nbash with ble.sh (freshly updated, but the problem can be reproduced even without it)\n\n> - How is the (git) prompt set in your shell startup file? (~/.bashrc,\n>   or ~/.profile, etc). If you don't know exactly, then can you please\n>   attach your shell startup files?\n\n* /etc/bash.bashrc is\n  https://mcepl.fedorapeople.org/tmp/bash.bashrc (the\n  standard openSUSE one with the addition of loading\n  /etc/profile.d/distrobox_profile.sh)\n* /etc/profile is https://mcepl.fedorapeople.org/tmp/profile\n  (git is not mentioned anywhere in /etc/profile.d)\n* /etc/bash_completion.d/git-prompt is\n  https://mcepl.fedorapeople.org/tmp/git-prompt (so, yes\n  git-prompt may be attempted to be loaded twice)\n* /etc/profile.d/distrobox_profile.sh is\n  https://mcepl.fedorapeople.org/tmp/distrobox_profile.sh\n* ~/.bashrc is https://mcepl.fedorapeople.org/tmp/bashrc\n* ~/.config/blesh/init.sh is\n  https://mcepl.fedorapeople.org/tmp/init.sh\n\n> - Can you provide a sample repository to clone which reproduces the\n>   issue? for instance, you can pick a small repo from github.\n\nBasically any git repository which has more than one\nlevel of directories, I spent most of my time in\nhttps://git.sr.ht/~mcepl/m2crypto, so when I do `cd src` the git\nstatus evaporates.\n\n> - What are the steps to reproduce the issue? is it enough to \"cd\"\n>   into an existing sub-dir at the git dir? or is it only broken\n>   when creating an unrelated sub-dir and \"cd\" into it? better yet,\n>   provide a 1:... 2:... 3:... steps which reproduce the issue for\n>   you, and which others can try to follow.\n\nYes, just run `cat <(curl -L -s https://mcepl.fedorapeople.org/tmp/typescript)`\n\n>    sudo zypper install bash-git-prompt\n\nI don’t have this package installed at all, using the script from git-core.\n\n>      . ~/git-prompt.sh\n>      PS1='\\w$(__git_ps1)\\n\\$ '\n\nYes, that works:\n\nmitmanek:~ $ export PS1='\\w$(__git_ps1)\\n\\$ '\n~\n$ ~/repos/m2crypto\ncd -- /home/matej/repos/m2crypto\n~/repos/m2crypto (master $)\n$ cd src\n~/repos/m2crypto/src (master $)\n$ \n\nSo, the problem is somewhere in my too complicated configuration. Any idea, where?\n\nThank you for your help so far!\n\nMatěj\n\n-- \nhttp://matej.ceplovi.cz/blog/, @mcepl@floss.social\nGPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8\n \nBooks aren’t written - they’re rewritten. Including your own. It\nis one of the hardest things to accept, especially after the\nseventh rewrite hasn’t quite done it.\n  -- Michael Crichton, alluding to Steele MacKaye (1889) article\n     where he said this about theater plays.\n"},{"id":"506043","messageId":"D543UAO2CPHI.RQIN1V1IC85A@cepl.eu","threadId":"62391","inReplyTo":"D542P2ZTHIUJ.2GEJYE41VTC0J@cepl.eu","subject":"RESOLVED [Was: Re: bash prompt evaporates in subdirectories]","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2024-10-24T14:26:59Z","receivedAt":"2024-10-24T14:27:01Z","isPatch":false,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"On Thu Oct 24, 2024 at 3:33 PM CEST, Matěj Cepl wrote:\n> On Thu Oct 24, 2024 at 1:46 PM CEST, avih wrote:\n>> - What is the \"innermost\" distro where this happens? Thumbleweed?\n>>   which version?\n\nIt was a bug in one of my scripts, https://github.com/openSUSE/osc/pull/1632/commits/294001c46ea2\n\nSorry for bothering you.\n\nMatěj\n\n-- \nhttp://matej.ceplovi.cz/blog/, @mcepl@floss.social\nGPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8\n \nOne reason that life is complex is that it has a real part and an\nimaginary part.\n    -- Andrew König\n\n"},{"id":"506044","messageId":"1945074076.3173992.1729779552281@mail.yahoo.com","threadId":"62391","inReplyTo":"D542P2ZTHIUJ.2GEJYE41VTC0J@cepl.eu","subject":"Re: bash prompt evaporates in subdirectories","fromName":"avih","fromEmail":"avihpit@yahoo.com","sentAt":"2024-10-24T14:19:12Z","receivedAt":"2024-10-24T14:50:09Z","isPatch":false,"sender":{"key":"avihpit@yahoo.com","avatar":"https://avatars.githubusercontent.com/u/2164962?v=4"},"body":" On Thursday, October 24, 2024 at 04:33:14 PM GMT+3, Matěj Cepl <mcepl@cepl.eu> wrote:\n> On Thu Oct 24, 2024 at 1:46 PM CEST, avih wrote:\n> > ...\n> > - How did you install the git-prompt support?\n>\n> Using the git-prompt.sh from the package, but it seems to be the same as the upstream one in contrib/\n\nGood.\n\n> ... using the script from git-core.\n> >      . ~/git-prompt.sh\n> >      PS1='\\w$(__git_ps1)\\n\\$ '\n>\n> Yes, that works:\n> ...\n\nGood. So this probably means there's no issue with that script,\nunless you can isolate a specific minimal example (with some config\nvars, PS1/PROMPT_COMMAND, etc) which behaves badly.\n\n> > - Which shell do you use? (bash? zsh? something else?)\n>\n> bash with ble.sh (freshly updated, but the problem can be reproduced even without it)\n\nble.sh looks pretty not-small, and I'm not familiar with it.\n\n> > - How is the (git) prompt set in your shell startup file? (~/.bashrc,\n> >   or ~/.profile, etc). If you don't know exactly, then can you please\n> >   attach your shell startup files?\n>\n> * /etc/bash.bashrc is\n> ... (generally default distro files)\n>\n> * ~/.bashrc is https://mcepl.fedorapeople.org/tmp/bashrc\n> * ~/.config/blesh/init.sh is\n>   https://mcepl.fedorapeople.org/tmp/init.sh\n>\n> ...\n>\n> So, the problem is somewhere in my too complicated configuration. Any idea, where?\n\nThese files load/use ~/.config/dotfiles/osc/osc-prompt.sh which is\nnot linked or provided, and I'm guessing is either the culprit, or\nthe issue is how you use it together with __git_ps1, which I can't\nhelp you with.\n\nYou may link it in a reply, but I likely don't have the bandwidth\nto look into it, though maybe someone else would be able to help.\n\nOr, even better, you should look into it and bisect your config.\n\nFor what it's worth, if, with that same Tumbleweed live DVD, with git\ninstalled, I add your ~/.bashrc content to mine (default), and add\nthis final line:\n \n  PS1='\\n\\w$(__git_ps1)\\n\\$ '\n \nthen it does work correctly (with your GIT_PS1_* config vars etc).\n\nBut your PS1 is:\n \n  export PS1='\\h:\\W$(__osc_prompt) \\$ '\n\nSo I'm guessing things go wrong somewhere between __osc_prompt\nand __git_ps1 invocation, but I can't tell where.\n\nAnyway, good luck.\navih\n\n"},{"id":"506045","messageId":"ZxpsytPwKM70/XqD@nand.local","threadId":"62391","inReplyTo":"D543UAO2CPHI.RQIN1V1IC85A@cepl.eu","subject":"Re: RESOLVED [Was: Re: bash prompt evaporates in subdirectories]","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-24T15:50:34Z","receivedAt":"2024-10-24T15:50:36Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Thu, Oct 24, 2024 at 04:26:59PM +0200, Matěj Cepl wrote:\n> On Thu Oct 24, 2024 at 3:33 PM CEST, Matěj Cepl wrote:\n> > On Thu Oct 24, 2024 at 1:46 PM CEST, avih wrote:\n> >> - What is the \"innermost\" distro where this happens? Thumbleweed?\n> >>   which version?\n>\n> It was a bug in one of my scripts, https://github.com/openSUSE/osc/pull/1632/commits/294001c46ea2\n>\n> Sorry for bothering you.\n\nAh, makes sense. Nice find, and not a bother at all.\n\nThanks,\nTaylor\n"},{"id":"506063","messageId":"901612009.3278712.1729800211571@mail.yahoo.com","threadId":"62391","inReplyTo":"D543UAO2CPHI.RQIN1V1IC85A@cepl.eu","subject":"Re: RESOLVED [Was: Re: bash prompt evaporates in subdirectories]","fromName":"avih","fromEmail":"avihpit@yahoo.com","sentAt":"2024-10-24T20:03:31Z","receivedAt":"2024-10-24T20:23:50Z","isPatch":false,"sender":{"key":"avihpit@yahoo.com","avatar":"https://avatars.githubusercontent.com/u/2164962?v=4"},"body":" On Thursday, October 24, 2024 at 05:19:46 PM GMT+3, avih <avihpit@yahoo.com> wrote:\n\n> So I'm guessing things go wrong somewhere between __osc_prompt\n> and __git_ps1 invocation, but I can't tell where.\n\n\nOn Thursday, October 24, 2024 at 05:27:02 PM GMT+3, Matěj Cepl <mcepl@cepl.eu> wrote:\n\n> It was a bug in one of my scripts, https://github.com/openSUSE/osc/pull/1632/commits/294001c46ea2\n\n\nGood catch. That's literally an issue in the one line which exists\nbetween __osc_prompt and the __git_ps1 invocation !\n\nDo let us know if you encounter an actual issue in the future.\n\navih\n"}]}