Shell appending unknown integer to hostname in prompt (zsh) on mac
I recently customized the prompt in my terminal to be more like the one from parrot os, which I really like. I have read over the documentation many times on how to use the markers/variables in the shell prompt and for a while I had it perfectly the way I wanted it, just like this format:
┌─[user@hostname]-[~/current/directory]
└─╼>
But recently the prompt has been adding a mysterious integer with a dash right after the hostname, like so:
┌─[user@hostname-18]-[~/current/directory]
└─╼>
It started with 17, then increased to 18. Now it stays on 18 almost all the time except when I open another terminal instance in which case it jumps to 26. Does anyone know what this number is indicating or why it is appearing here? I have checked to make sure I don't have any other open terminals/shells/emulators. Here is the code from my .zshrc file that I used to customize the prompt:
unsetopt PROMPT_SP
PROMPT="┌─[%n@%m]-[%~]"$'\n'"└─╼> "
How can I disable that seemingly random number? I have no idea what it is indicating.
Sounds like that number is, in fact, your hostname. Run hostname
or uname -n
to check.
macOS will do this when it detects a name conflict on your LAN – i.e. it sees that there's another host responding to Bonjour (mDNS) queries for hostname.local
. (It could be a Linux host running Avahi, too.)
If the numbers just increase indefinitely, this might mean that macOS is reaching itself looping back through another interface. (For example, it sends out a query through Wi-Fi and receives it back through wired Ethernet; it responds through Ethernet and the reply travels back through Wi-Fi, making it think it found another device.)