主机名和当前工作路径在Linux终端中未显示。

huangapple go评论53阅读模式
英文:

The hostname and current work path is not displayed in Linux terminal

问题

我在我的Linux机器上激活了某些东西,导致屏幕只显示(base)而不是(base) [user@host path]$。当我取消激活它时,屏幕仍然是空白的,这不正常。我想恢复正常的屏幕。我已经搜索了解决方案,但没有找到有用的内容。我不确定这个问题与什么相关,所以无法搜索相关的关键词。我该如何修复这个问题?

当前屏幕:

(base) python foo.py

期望的屏幕:

(base) [user@host path]$ python foo.py
英文:

I have activated something on my Linux machine which caused the screen to only display (base) instead of (base) [user@host path]$. When I deactivate it, the screen remains blank which is not normal. I want to restore the normal screen. I have searched for solutions but haven't found anything helpful. I am not sure what this issue is related to so I am not able to search for relevant keywords. How can I fix this?

Current screen:

(base) python foo.py

Desired screen:

(base) [user@host path]$ python foo.py

答案1

得分: 0

你需要查找在你所引用的shell脚本中重载了你的提示符(shell variable)的位置。通常这个变量的名称是$PS1。
你可以使用以下方式查看其定义:

echo $PS1

并且你可以使用以下方式修改它:

export PS1="[\u@\h: \w/]$ "  # 例如

类似的问题:https://stackoverflow.com/questions/71910898/full-file-path-on-bash-prompt。

英文:

You have to look for the place where your prompt shell variable is overloaded in the shell script that you sourced. The variable name is usually $PS1.
You can see its definition using :

echo $PS1

And you can modify it using :

export PS1="[\u@\h: \w/]$"  # for example

Similar question: https://stackoverflow.com/questions/71910898/full-file-path-on-bash-prompt .

huangapple
  • 本文由 发表于 2023年6月16日 15:33:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76487910.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定