עם טרמינל: שיפור מראה הקונסולה

אני אחד מאותם אנשים שאוהבים להשתמש בטרמינל. אני חושב שכל משתמשי גנו/לינוקס , בשלב מסוים, לא יכולים לחיות בלעדיו, כי החלון הגדול הזה מלא בטקסט הופך את חיינו להרבה יותר קלים, נכון?

אבל אנחנו יכולים לגרום לזה להיראות קצת יותר יפה מהברירת המחדל. דוגמה לכך ניתן לראות (ולהוריד) מ- gnome-look . הטיפ שאראה לכם למטה ייתן למכשיר שלכם את המראה הבא:

כפי שניתן לראות, הפקודה שיש לבצע מסומנת וחותמת זמן עם זמן המערכת מוצבת בין כל פקודה .

איך אני עושה זאת?

נפתח עורך טקסט (לדוגמה , Gedit ) ונכניס בתוכו את הדברים הבאים:

# Fill with minuses
# (this is recalculated every time the prompt is shown in function prompt_command):

fill="--- "
reset_style='\[\033[00m\]'
status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
prompt_style=$reset_style
command_style=$reset_style'\[\033[1;29m\]' # bold black
# Prompt variable:
PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\u@\h:\w\$'"$command_style "
# Reset color for command output
# (this one is invoked every time before a command is executed):
trap 'echo -ne "\e[0m"' DEBUG
function prompt_command {
# create a $fill of all screen width minus the time string and a space:
let fillsize=${COLUMNS}-9
fill=""
while [ "$fillsize" -gt "0" ] do
fill="-${fill}" # fill with underscores to work on
let fillsize=${fillsize}-1
done
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
bname=`basename "${PWD/$HOME/~}"`
echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
;;
*)
;;
esac
}
PROMPT_COMMAND=prompt_command

אנו שומרים אותו בתיקייה /home שלנו בשם .bash_ps2 , לדוגמה. לאחר מכן אנו פותחים את קובץ ה-.bashrc שלנו ומוסיפים:

if [ -f "$HOME/.bash_ps2" ]; then
. "$HOME/.bash_ps2"
fi

אנחנו פותחים טרמינל ונוכל לראות את השינויים 

נראה ב: HumanOS.


הוסף כמקור מועדף בגוגל