Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
534 views
in Technique[技术] by (71.8m points)

git - MacOS Strange Terminal Prompt, Tried Resetting Terminal

Link to picture of terminal

Last login: Mon Feb 27 14:57:49 on ttys000
engr2-2-79-41-dhcp:~ <censored>$

Depending on what network I am connected to, my terminal lists odd things on every line such as "engr2-....". I accidentally did something that created this problem. Once it started occurring, git commands stopped working. I tried to delete configuration files for the terminal, but it only reset the theme of my terminal.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What you're seeing is normal, just a bit confusing. It's the computer's hostname. The standard prompt includes it in an attempt to be helpful.

In the unix command-line interface, it's normal to switch to other directories (with cd), other user accounts (with su or sudo), and even other computers (with ssh). Keeping track of where you are can get confusing, so the standard shell prompt includes where and who you are (the computer's hostname, current username, and current directory); sort of the command-line equivalent of a GPS system.

The problem is that the way it determines the computer's hostname sometimes causes more confusion than anything else. The process goes a bit like this:

Bash shell: I need to include the hostname in the command prompt. "Hey, operating system: what's the hostname of this computer we're on?"

OS: My hostname? Gosh, I wonder what that is. I know, I'll ask the DNS (domain name service) server if it has a name for my IP address. "Hey, DNS, what's the name associated with 2.2.79.41?"

DNS server: 2.2.79.41? That doesn't really have a specific name, it's just part of the pool of addresses the DHCP server hands out to computers that connect to the engineering network. Oooh, I know, I'll call it engr2-2-79-41-dhcp. It's better than nothing, right?"

...so the DNS sends that name to the OS, which passes it to the shell, which displays it in your prompt, which causes you to say "WTF is that????".

Keep in mind here: every part of this process is something trying to do the best it can to provide the best information it can. Nothing is actually wrong, it's just rather confusing if you don't know what it's doing or why.

Which brings me to your problem with git commands: this is not causing it. It is almost certainly not related to it. Ignore the weird prompt, and troubleshoot your git setup.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...