Jumat, 18 November 2011

merubah dan mewarnai shell prompt di terminal ubuntu

secara default, shell prompt bawaan ubuntu berformat,

akses terminal… , dan saatnya mengoprekk.. :D

sudo gedit .bashrc

sebuah text editor akan terbuka,lalu tambahkan sebuah baris perintah di akhir line seperti berikut ini,

export PS1=" "

hasil :

code :

export PS1="aku sayang ibu > "

hasil :

code :


export PS1="sekarang pukul: \t nama saya: \u >"

hasil :

dari gambar di atas maka dapat di simpulkan,

karakter \t = menampilkan tanggal dalam format 24 jam
karakter \u = menampilkan user

untu lebih lengkpanya mengenai karakter,

\a The bell character
\d The date in the format ‘‘Day Month Date’’
\e The ASCII escape character
\h The local hostname
\H The fully qualified domain hostname
\j The number of jobs currently managed by the shell
\l The basename of the shell’s terminal device name
\n The ASCII newline character
\r The ASCII carriage return
\s The name of the shell
\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
\u The username of the current user
\v The version of the bash shell
\V The release level of the bash shell
\w The current working directory
\W The basename of the current working directory
\! The bash shell history number of this command
\# The command number of this command
\$ A dollar sign if a normal user, or a pound sign if the root user
\nnn The character corresponding to the octal value nnn
\\ A backslash
\[ Begins a control code sequence
\] Ends a control code sequence

untuk warna shell prompt,

code :

export PS1=”\[\e[0;34m\] sekarang pukul: \t \[\e[m\] \[\e[0;31m\] nama saya:\u > \[\e[m\]“

hasil :

sudah seperti pelangi kan :D

untuk kode warna :

\[\e[0;34m\] = tag pembuka, dengan warna biru
\[\e[m\] =tag penutup

\[\e[0;31m\] = tag pembuka, dengan warna merah
\[\e[m\] =tag penutup

kode warna :

Color Code
Black 0;30
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33

silahkan di explore sendiri oleh sobat blogger smua .. :)
smoga bermanfaat buat saya dan sobat blogger ..

sumber :

http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/

https://wiki.archlinux.org/index.php/Color_Bash_Prompt

Tidak ada komentar:

Posting Komentar