PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : PROMPT verhält sich ungewöhnlich



ivl
02.06.03, 20:03
ich erhalte nach dem login bei einem user folgenden Promp, dessen Herkunft ich nicht nachvollziehen kann.
Er lautet (Namen geändert):

"user@terra:~> ;terra:~;terra:~" (dann folgt der Cursor)

Ich möchte wieder den alten haben:

"user@terra:~>"

wie geht das?

IvL.

sepp2k
02.06.03, 20:14
Welche Shell verwendest du? Für die bash:
export PS1='\u@\h:\w> '
Für die zsh:
export PS1='%n@%m:%~> '

ivl
02.06.03, 23:00
Ja, super. Vielen Dank sepp2k!

Darf ich mir die Anweisung (PS1='\u@\h:\w ') folgendermaßen interpretieren?

PS1 : die Konsole
\u : der user
@\h : @host
\w : workpath

Viele Grüße ... IvL.

sepp2k
03.06.03, 00:15
Original geschrieben von ivl
PS1 : die Konsole
\u : der user
@\h : @host
\w : workpath
PS1 ist die Umgebungs-Variable, die den Prompt festelegt. Das @ kannst du nartürlich auch weglassen. Statt \w kannst du auch \W nehmen (gibt nicht den ganzen Pfad aus). Du kannst auch alle anderen möglichen Sachen in den Prompt einbauen. Siehe dazu auch den Abschnitt über Prompting in der manpage zur bash:

PROMPTING
When executing interactively, bash displays the primary prompt PS1 when
it is ready to read a command, and the secondary prompt PS2 when it
needs more input to complete a command. Bash allows these prompt
strings to be customized by inserting a number of backslash-escaped
special characters that are decoded as follows:
\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 + patchelvel (e.g., 2.00.0)
\w the current working directory
\W the basename of the current working directory
\! 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

The command number and the history number are usually different: the
history number of a command is its position in the history list, which
may include commands restored from the history file (see HISTORY
below), while the command number is the position in the sequence of
commands executed during the current shell session. After the string
is decoded, it is expanded via parameter expansion, command substitu-
tion, arithmetic expansion, and quote removal, subject to the value of
the promptvars shell option (see the description of the shopt command
under SHELL BUILTIN COMMANDS below).

TheGrudge
06.10.03, 19:00
kann ich das auch bunt machen?
ich hätte gerne das \w in rot...

also
PS1='\u@\h[\w]\$ '

geht das?

HEMIcuda
06.10.03, 19:08
Jap. Durchaus. Dir sei das Bash-Prompt-HOWTO (http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/) ans Herz gelegt.

'cuda

TheGrudge
06.10.03, 19:36
cool, hat gefunzt!
ist zwar total umübersichtlich nun mein code:
PS1="\u@\h\[\033[33m\][\[\033[31m\]\w\[\033[33m\]]\[\033[0m\]\$ "
:D
aber es klappt!

leider ist das gelb nur in eterm gelb, in der richtigen bash (login-shell) ist es orange...
naja egal..!

Danke schön!

HEMIcuda
06.10.03, 19:40
Keine Ursache ;) Da kann man noch viele andere lustige Sachen
machen, wie z.B. Systeminfos in der oberen linken und die Uhrzeit
und das Datum in der oberen rechten Ecke anzeigen lassen. Aber
der Aufwand dafuer ist IMHO nicht gerade ohne. Ich hab's noch nicht
zufriedenstellend hingekriegt.

'cuda

Nupsi
13.06.04, 12:22
Howdy,

wie kann ich denn die Einstellung speichern? Beim öffnen einer Konsole im KDE wird mir immer nur als Prompt "bash-2.05b$" angezeigt.

Mittels "export PS1='\u@\h:\w> '" wird mir dann zwar der Pfad und der benutzername angezeigt, aber sobald ich die Konsole schließe und wieder öffne, wird mir wieder nur "bash-.05b$" angezeigt :mad:

THX und Cya
NUPSI

sepp2k
13.06.04, 13:10
Den export-Befehl in eine Datei schreiben, die beim Start der Shell gelesen wird. zB ~/.${SHELL}rc oder /etc/profile