4 月 132014
 

原文(source): http://blog.longwin.com.tw/2012/11/bash-prompt-set-generator-2012/

Linux 使用 Bash shell 可以自訂 prompt 的格式(設定 Shell 的 PS1 變數), 先把自己現在和以前有做過的一些設定列出來~

  • PS1=’\u@\h:\w\$ ‘
  • PS1=’\[\u@\h:\e[32m\w\e[0m$ \]’
  • PS1=’${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ‘
  • PS1=’${debian_chroot:+($debian_chroot)}\A/$? \[\033[01;32m\][\u@\h] \[\033[01;34m\]\w \$ \[\033[00m\]’

Bash prompt PS1 產生器

有個網站把常用的功能, 做成簡單的網站服務, 拖拉就可以動態產生結果~

註: 拖拉 +選擇顏色 + cp ‘export PS1=”\h:\W \u\$ “‘ 這些產生出來的資料到 .bash_profile 或 .bashrc 裡面就可以囉~

其他的 Prompt 設定

  • 整合 Git branch 顯示的 PS1 設定: PS1=”\u@\h:\w\$(git_branch)\$ “
  • MySQL 也可以設定 PS1, ex: export MYSQL_PS1=”(\u@\h) [\d]> “

相關網頁

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

CAPTCHA Image
Play CAPTCHA Audio
Reload Image