TOP cygwin Linux



cygwin

.bashrc

cygwin
export PS1='\[\e]0;\[\e[31m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
vine
export PS1="\[\033[1;36m\][\u@\h \W]$\[\033[0m\] "

color

ref:Bash カラープロンプト
黒色(Black)0;30
青色(Blue)0;34
緑色(Green)0;32
水色(Cyan)0;36
赤色(Red)0;31
紫色(Purple)0;35
明灰色(Light Gray)0;37
暗灰色(Dark Gray)1;30
Light Blue1;34
Light Green1;32
Light Cyan1;36
Light Red1;31
Light Purple1;35
黄色(Yellow)1;33
白色(White)1;37

プロンプトを 赤色 にしたい場合は

"\[\033[0;31m\][\u@\h:\W]$ " 

背景色

背景色が青で文字が赤の場合は
"\[\033[44;1;31m\][\u@\h:\W]$ "

属性を無効にする

"\[\033[0m\][\u@\h:\W]$ "

Escape


\aベル(ビープ音)をならす(ASCII のベル文字 07)
\d"曜日 月 日"の形式の日付
\D{format}the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
\ean ASCII escape character (033)
\hホスト名(最初の . までの名前)
\Hホスト名
\jthe number of jobs currently managed by the shell
\lthe basename of the shell's terminal device name
\n改行
\r復帰
\sthe name of the shell, the basename of $0 (the portion following the final slash)
\t時刻 HH:MM:SS 形式(24時間) H = Hour = 時、M = Minutes = 分、S = Seconds = 秒
\T時刻 HH:MM:SS 形式(12時間)
\@時刻 am/pm をつけたもの。Lang=Jaの場合 HH:MM (午前|午後)となる。
\Athe current time in 24-hour HH:MM format
\u現在のユーザー名
\vbash のバージョン(e.g., 2.00)
\Vbash のバージョン・リリース番号など詳細(e.g., 2.00.0)
\w現在のディレクトリ(フルパス)
\W現在のディレクトリ名
\!コマンドのヒストリー番号
\#コマンドのコマンド番号(ログイン後何回実行したか)
\$UID が 0 であれば『 # 』、それ以外は『 $ 』
\nnnthe character corresponding to the octal number nnn
\\バックスラッシュ
\[表示されない文字列(エスケープシーケンス/端末制御シーケンス)を埋め込む
\]表示されない文字列の終わり

カーソルの位置

カーソルの位置をセット\[\033[<row>;<column>f\]
現在のカーソル位置を保存\[\033[s\]
位置を復元する\[\033[u\]
右上のコーナーに時計を表示しますPS1=">\[\033[s\]\[\033[1;\$*1f\]\$(date +%H:%M)\[\033[u\]"

PROMPT_COMMAND

ref:[PS1とPROMPT_COMMAND, GNU screenでの活用も>http://rcmdnk.github.io/blog/2013/03/21/prompt-com...]]

tput

Change the prompt color using tput
$ export PS1="\[$(tput bold)$(tput setb 4)$(tput setaf 7)\]\u@\h:\w $ \[$(tput sgr0)\]"

tput Color Capabilities:

tput setab [1-7]Set a background color using ANSI escape
tput setb [1-7]Set a background color
tput setaf [1-7]Set a foreground color using ANSI escape
tput setf [1-7]Set a foreground color

tput Text Mode Capabilities:

tput boldSet bold mode
tput dimturn on half-bright mode
tput smulbegin underline mode
tput rmulexit underline mode
tput revTurn on reverse mode
tput smsoEnter standout mode (bold on rxvt)
tput rmsoExit standout mode
tput sgr0Turn off all attributes

Color Code for tput:

0Black
1Red
2Green
3Yellow
4Blue
5Magenta
6Cyan
7White

Xterm ターミナルのタイトルバーの表示

printf "\e]2;Hello World!\a"
||

** PROMPT_COMMAND	
=||
PROMPT_COMMAND='printf "\e]0;%s@%s:%s\a" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'

エスケープシーケンス

\e]0; ~ \aタイトル名、アイコン名の変更
\e]1; ~ \aアイコン名の変更
\e]2; ~ \aタイトル名変更

管理人/副管理人のみ編集できます