发布日期:2016-11-17 16:44:15

Between the quotation marks of export PS1=” “, you can add the following lines to customize your Terminal prompt:

  • \d – Current date
  • \t – Current time
  • \h – Host name
  • \# – Command number
  • \u – User name
  • \W – Current working directory (ie: Desktop/)
  • \w – Current working directory with full path (ie: /Users/Admin/Desktop/)

(Note if you just want to use a custom bash prompt one-off or to test out the appearance of changes before setting them in the bash profile, you can simply use the export commands, the change will take effect immediately with the export command but will be abandoned when that Terminal session is ended.)

通过export设置只针对当前session。退出session后就会失效。

So, let’s take a few examples. Perhaps you want your Terminal prompt to display the User, followed by the hostname, followed by the directory, then the appropriate .bashrc entry would be:

export PS1="\u@\h\w $ "

发表评论