我在终端上输入命令时,每行都会显示一个占用大量空间的提示符 "names-MacBook-Pro"。有没有办法去掉或缩短它?
您的提示符是由环境变量PS1
设置的。它是由系统在/private/etc/bashrc
中设置的,但通常由用户在其主目录中的点文件中进行修改。
使用此命令检查当前设置:
echo $PS1
通过在您的~/.bash_profile
(或先前定义它的任何位置)中设置变量来修改它:
export PS1="$"
通过执行以下操作从您的dotfiles中重新加载设置:
source ~/.bash_profile
$
。
PS1
: 主提示符字符串。默认值为\s-\v\$
。PS2
: 次要提示符字符串。默认为>
PS3
: select
命令的提示信息PS4
: 在执行跟踪期间,每个Bash显示的命令前打印。在需要表示多层间接引用时,将复制PS4
的第一个字符。默认值为+
\a : An ASCII bell character (07)
\d : The date in “Weekday Month Date” format (e.g., “Tue May 26”)
\D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
\e : An ASCII escape character (033)
\h : The hostname up to the first ‘.’
\H : The hostname
\j : The number of jobs currently managed by the shell
\l : The basename of the shell's terminal device name
\n : Newline
\r : Carriage return
\s : The name of the shell, the basename of $0 (the portion following the final slash)
\t : The current time in 24-hour HH:MM:SS format
\T : The current time in 12-hour HH:MM:SS format
\@ : The current time in 12-hour am/pm format
\A : The current time in 24-hour HH:MM format
\u : The username of the current user
\v : The version of Bash (e.g., 2.00)
\V : The release of Bash, version + patch level (e.g., 2.00.0)
\w : The current working directory, with $HOME abbreviated with a tilde
\W : The basename of the current working directory, with $HOME abbreviated with a tilde
\! : The history number of this command
\# : The command number of this command
\$ : If the effective UID is 0, a #, otherwise a $
\nnn : the character corresponding to the octal number nnn
\\ : A backslash
\[ : Begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
\] : end a sequence of non-printing characters
export PS1="$ "
。 - Taylor D. Edmistonecho $PS1
,declare
,set
... - Sinjai