hostname for bash prompt
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
I noticed changing my hostname doesn't affect bash prompt under WSL, and I'm wondering if that can be changed --
I'ved changed:
sudo hostname wsl
I also changed /etc/hostname to "wsl" and changed /etc/hosts as well.
But my hostname in bash prompt never changed.
As per bash prompt user manual
\h
The hostname, up to the first ‘.’.
So I think, for normal case, it is read from either /etc/hostname or /etc/hosts.
Describe the solution you'd like
Any of the above changing of my hostname method can affect bash prompt.
For reason behind that, "I have 6 different wsl instances for different purposes. Most of the times I can't figure out which instance I'm currently in."
Describe alternatives you've considered
I know the official solution is to change the host system's name from System --> Change Settings --> Change, but I'd like to identify my WSL distribution in different sessions, e.g. UbuntuA, UbuntuB and UbuntuC.
Additional context
I know "WSL doesn't allow you to set a hostname separately from the computer".
and I know from #125 that "Changing the hostname from Bash is currently not supported"
but if you do a search on "WSL Change hostname", you can see that it is a common request, meaning most people have the same desire as this.
Please consider. thx!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source files or tests. Start with the Bash prompt manual and prior issue #125, then investigate how WSL supplies the hostname to Bash; done requires a maintainer-defined approach for identifying separate distributions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, linux
- Domain
- cli, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100