Customize Shell prompt

Source: Internet
Author: User

Presumably in the command-line mode for a long time, all look tired of that monotonous and ugly cue, the individual think also accounted for some bit, if the command long words will break.

Want to change into

CD ~/touch  bash_profilevim. Bash_profile

OS X environment, key syntax \[ color \]prompt parameter \[$reset\] For example:\[ $red\]\ t\[$reset\]

reset=$ (tput sgr0) Green2) Yellow3) Blue4) Magenta 5 ) Cyan6) PS1="\[$magenta \]\u\[$reset \] at \[$blue \]\h\[$reset \] in \[$ yellow\]\w\n\[$reset \]\[$green \]\$\[$reset \]"export PS1

: Wq Save Away

source. bash_profile

How to use the Tput command

Prompt parameters:

  • \a : An ASCII Bell character (07)
  • \d : The date in ' Weekday Month date ' format (e.g., "Tue May 26")
  • \d{format} : The format is passed to Strftime (3) and the result was inserted into the prompt string; An empty format results in a locale-specific time representation. The braces is required
  • \e : An ASCII escape character (033)
  • \h : The hostname up to the first '. '
  • \h : the hostname
  • \j : The number of jobs currently managed by the Shell
  • \l : The basename of the shell ' s terminal device name
  • \ n : NewLine (line wrapping)
  • \ r : Carriage return
  • \s : The name of the shell, the basename of $ (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
  • \a : The current time in 24-hour hh:mm format
  • \u : The username of the current user
  • \v : The version of Bash (e.g., 2.00)
  • \v : The release of bash, version + patch level (e.g., 2.00.0)
  • \w : The current working directory, with $HOME abbreviated with a tilde
  • \w : The basename of the current working directory, with $HOME abbreviated with a tilde
  • \! : 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, which could be used to embed a terminal control sequence into the prompt
  • \] : End a sequence of non-printing characters

Article reference, article reference 2

Customize Shell prompt

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.