Leopard terminal prompt


Od kar sem se zacel igrati z BSDjem mi je zelo vsec in uporaben prompt, ki se uporablja pri freeBSDju… Napisal bom en mini-guide kako lahko spreminjamo prompt v terminalu v Leopardu..

Trenuten prompt je sledec:

Hackint0sH:~ mihap$

Kar zna biti precej motece, ko se postavimo v kaksen direktorij, ker ne vemo vec kje se nahajamo, kot kateri user delamo ipd…:

Hackint0sH:uucp mihap$

Kje v dir strukturi se nahajamo? Kdo smo? Je mihap mapa? Mogoce Hackint0sH?

Ok, uporabimo lahko naprimer prompt od freeBSDja ki je imho malce bolj citljiv

[mihap@Hackint0sH ~]

Sedaj se postavimo v isti direktorij kor prej:

[mihap@Hackint0sH /var/log/uucp]

torej, mihap na rac Hackintosh v dir /var/log/uucp, plain and simple.

Kako spremenimo prompt?


http://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files

Pomemben je predvsem sledeci del:

When Bash is invoked as an interactive login shell, or as a non-interactive shell with the –login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

Ok, pri OsXu je malce drugace, saj se vmes vrine /etc/bashrc (mislim da zato ker ima vec shellow, nisem pa povsem preprican…) :)

a) system-wide change:

sudo vi /etc/bashrc

b) per user prompt:

vi ~/.bash_profile

V obeh primerih uredimo / dodamo spodnjo vrstico:

PS1="[\u@\h \w] "

Kar pomeni:

\u     the username of the current user
\h     the hostname up to the first `.'
\w     the current working directory

se odlogiramo iz terminala ali odpremo novega in prompt se spremeni v BSD-like!

Seveda ga lahko kostumizirate in prilagodite svojim potrebam, kompletna navodila in moznosti se nahajajo tukaj.

lpm

Your IP Address is:
38.107.179.222

  1. #1 by nniinn on May 16, 2008 - 12:12

    To ne deluje. Čudak.

(will not be published)
*