Updating my bash prompt

I spend most of my days in the command line. I try to keep things as simple, closest to bare metal as possible, without installing a ton of non-system stuff.

Usually this is what my prompt looks like:

[main:/d/code/cthugha]

Instead, this is what I was seeing:

bash: /d/code/cthugha/vcpkg/.git/HEAD: Not a directory [:/d/code/cthugha]

the first bit is the branch if I am in a git repo.

main

the second is the current directory.

/d/code/cthugha

It also shows the name of the machine if I am logged on not on the console (e.g. ssh’ed into a remote machine.)

Nothing too fancy, just display some info as I navigate around. Modified from a code I stole borrowed from someone years ago. It also has some stuff in there for dealing with Python virtualenv which thankfully I don’t really deal with much anymore.

Problem was that if I navigated to a git submodule I would see an error, and the git branch would be wrong. Took a few tweaks, but I was cleaned it up. What the issue was had to do with how git keeps track of submodules (which to be honest is not that surprising considering that submodules have always felt bolted on and have more than likely changed since I last updated my prompt) and once I fixed that it looks good.

The issue was that the code was looking for a directory that in a submodule was actually a file. Anyway, fixed that up and it all looks good.

Anyway, here is my .bash_prompt if it is any use to anyone: .bash_prompt

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.