Подтвердить что ты не робот

Измените префикс приглашения Bash в терминале OS X

У меня массивная подсказка, которая выводит имена моего терминала "MacBook-Pro" в той же строке, где команда вводится в каждой строке.

Есть ли способ удалить это или сделать его короче?

4b9b3361

Ответ 1

Ваше приглашение задается переменной окружения PS1. Это устанавливается системой в /private/etc/bashrc, но обычно она изменяется пользователем в ваших dotfiles в вашем домашнем каталоге.

Проверьте, что в настоящее время установлено с помощью этой команды:

echo $PS1

Измените его, установив переменную в ~/.bash_profile (или там, где вы ее определили ранее):

export PS1="$"

Перезагрузите настройки из ваших точечных файлов, выполнив следующие действия:

source ~/.bash_profile

Это сделает ваше новое приглашение оболочки просто $


Быстрые переменные

  • PS1: строка первичного приглашения. Значение по умолчанию: \s-\v\$ .
  • PS2: строка вторичного приглашения. По умолчанию используется >
  • PS3: запрос команды select
  • PS4: Отпечатано перед каждой командой Bash отображается во время трассировки выполнения. Первый символ PS4 реплицируется несколько раз, если необходимо, для указания нескольких уровней косвенности. По умолчанию используется +

Синтаксис (из Bash manual)

\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 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