هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
الهدف
Set up a comfortable working environment that stays after logout: a personal bin directory in the PATH, aliases and history settings, a coloured prompt with the time, and a few edits in vi.
قبل أن تبدأ
- Make a backup of your startup files first:
cp ~/.bashrc ~/.bashrc.bakandcp ~/.bash_profile ~/.bash_profile.bak(if it exists).
المهام
ضع علامة على المهمة عندما تنتهي منها. متصفحك فقط يتذكر ذلك.
- Make the directory
~/binand make sure it is in yourPATHin every new shell. - Add to
~/.bashrc: the aliasllforls -l --color=auto, and history settings that ignore repeated commands and keep 5000 lines. Add a comment above each line. - Load the changes into the open shell without logging out.
- Show the date in the time zone
Europe/Amsterdamfor one command only. Your normalTZmust not change. - Copy
/etc/servicesto~/services.txt. In vi: go to line 20, delete 3 lines, replace everyudpwithUDPin the whole file, and save. - Make a green prompt that shows the time (hours:minutes), the user, the host and the last part of the directory. Make it stay in new shells.
تحقّق من عملك
bash -lc 'echo $PATH' | tr ':' '\n' | grep bin
bash -ic 'type ll'
bash -ic 'echo $HISTCONTROL $HISTSIZE'
grep -c UDP ~/services.txt
bash -ic 'echo "$PS1"'PATHshows/home/USER/bin.type llsays it is an alias.HISTCONTROLisignoredupsandHISTSIZEis5000.- The prompt contains
\A,\u,\h,\Wand the colour code0;32.
تلميحات
اعرض التلميحات
PATHchanges go in~/.bash_profile(or~/.profile); aliases in~/.bashrc.source ~/.bashrcreloads the file.NAME=value commandsets a variable for one command.- In vi:
20G,3dd,:%s/udp/UDP/g,:wq. - Colours need
\[and\]around them.
الحل
اعرض الحل
- Make the directory and add it to the PATH.
- Add the aliases and history settings with comments.
cat >> ~/.bashrc << 'EOF' # my aliases alias ll='ls -l --color=auto' # history: no repeated lines, keep more export HISTCONTROL=ignoredups export HISTSIZE=5000 EOF - Load the file.
source ~/.bashrc - A temporary variable.
- Edit in vi (type the keys in vi).keys in vi
20G 3dd :%s/udp/UDP/g :wq - Make the prompt and save it.
ملاحظاتي
لا توجد ملاحظات بعد.