• 周四. 10 月 3rd, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Linux modifies terminal output format and color

King Wang

1 月 3, 2022

Modification method

stay ~/.bashrc Add… Later PS1='[\u@\h \W]\$'

Format specification

PS1 The definitions of the commonly used parameters are as follows :

  • \d: Representative date , The format is weekday month date, for example :“Mon Aug 1”
  • \H : Full host name
  • \h : Just take the first name of the host
  • \t : The display time is 24 Hour format , Such as :HH:MM:SS
  • \T : The display time is 12 Hour format
  • \A : The display time is 24 Hour format :HH:MM
  • \u : The account name of the current user
  • \v :BASH Version information for
  • \w: Full working directory name
  • \W : utilize basename Get the working directory name , So only the last directory will be listed
  • \# : The first orders
  • \$: Prompt character , If it is root when , The prompt is :# , The average user is :$

Color definition

PS1=’[[\e[ The font color ; Background color m] ’

The font color background Color
30 40 black
31 41 Red
32 42 green
33 43 yellow
34 44 Blue
35 45 Purplish red
36 46 Blue
37 47 white

Common formats

  • Purple font , Simple style
PS1='[\[\e[35;40m\]\u@\h \W]$ '
  • tart
PS1=$'\\[\E[1m\E[34m\\]┌─[\\[\E[1m\E[32m\\]\\u@\h \\[\E[1m\E[33m\\]\\w\\[\E[1m\E[34m\\]]\n\\[\E[1m\E[34m\\]└──── pibigstar \\[\E[1m\E[33m\\]#\[\E[0;10m\\] '

发表回复