انجمن‌های فارسی اوبونتو

کمک و پشتیبانی => انجمن عمومی => نویسنده: شایان در 27 تیر 1387، 11:04 ب‌ظ

عنوان: سوال در مورد متغیر محیطی PS1
ارسال شده توسط: شایان در 27 تیر 1387، 11:04 ب‌ظ
سلام
همان‌طور که احتمالاً‌ می‌دانید متغیر محیطی PS1 درون فایل‌های متفاوتی تنظیم می‌شود. حداقل در سیستم من در فایل‌های etc/bash.bashrc/ و bashrc./~ .
درون این فایل‌ها PS1 به صورت‌های زیر تغییر می‌کند

PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi


حالا سه    تا سوال:
۱- وقتی که درون ترمینال دستوری می‌نویسیم و بعد PS1 چاپ می‌شود، کدام فایل اجرا میشود. به عبارت دیگر دستور چاپ کردن PS1 در یک حلقه‌ی بی‌نهایت کدام فایل است.
۲- این debian_chroot دقیقا چیست؟
۳- به جز u\ و h\ و w\ چه عبارت‌های مشابه دیگری قابل استفاده هستند؟

با تشکر
عنوان: پاسخ به: سوال در مورد متغیر محیطی PS1
ارسال شده توسط: کرگدن در 28 تیر 1387، 12:12 ق‌ظ

۳-

\a an ASCII bell character (07)
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")
\e an ASCII escape character (033)
\h the hostname up to the first `.'
\H the hostname
\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
\u the username of the current user
\v the version of bash (e.g., 2.00)
\V the release of bash, version + patchlevel (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
\] end a sequence of non_printing characters

و متغیر های محلی

۲-

همون chroot برای debian هست که در اینجا خالی هست و مقداری نداره

To use the chroot environments set up on the Debian machines run the dchroot program. In each chroot, there is a file /etc/debian_chroot, the contents of which will tell you which chroot you are in (see /etc/profile for an example of how to add this to your prompt).


۱- نمی دونم :دی

اینو باید تو سورس های  بش جستجو کنی :)
چون فایلش معلوم نیست ولی پروسس و فایل اصلی بش هست ( شاید کمیک کنه :) )
عنوان: پاسخ به: سوال در مورد متغیر محیطی PS1
ارسال شده توسط: شایان در 28 تیر 1387، 01:41 ب‌ظ
ممنون از راه‌نمایی‌تان
دوستان نظری در مورد سوال اولم ندارند؟
راستی یک سوال دیگر،
متغیر محیطی  PROMPT_COMMAND در کدام فایل تنظیم می‌شود؟