我是喜歡使用終端機的人之一。 我認為 GNU / Linux的 在某一時刻,他們不能沒有它,因為那滿是字母的窗口使我們的生活更加輕鬆,對嗎?
但是我們可以使它看起來比默認值更漂亮。 可以從以下位置查看(並下載)此示例 侏儒神色。 接下來,我將向您展示的提示是使我們的終端具有以下外觀:
如您所見, 執行命令 並放在每個訂單之間 時間線 隨著系統時間。
我該怎麼辦?
我們打開一個文本編輯器 (例 gedit中) 然後將其放入其中:
# Fill with minuses
# (this is recalculated every time the prompt is shown in function prompt_command):
fill="--- "
reset_style='\[\033[00m\]'
status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
prompt_style=$reset_style
command_style=$reset_style'\[\033[1;29m\]' # bold black
# Prompt variable:
PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\u@\h:\w\$'"$command_style "
# Reset color for command output
# (this one is invoked every time before a command is executed):
trap 'echo -ne "\e[0m"' DEBUG
function prompt_command {
# create a $fill of all screen width minus the time string and a space:
let fillsize=${COLUMNS}-9
fill=""
while [ "$fillsize" -gt "0" ]
do
fill="-${fill}" # fill with underscores to work on
let fillsize=${fillsize}-1
done
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
bname=`basename "${PWD/$HOME/~}"`
echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
;;
*)
;;
esac
}
PROMPT_COMMAND=prompt_command
我們將其保留在我們的內部 /家 名稱 .bash_ps2 例如。 然後我們打開 的.bashrc 並且我們添加:
if [ -f "$HOME/.bash_ps2" ]; then
. "$HOME/.bash_ps2"
fi
我們打開一個終端,我們可以看到更改😀
出現在: 人類.
首先,感謝您的博客和一個問題,除了文本和背景的顏色之外,是否有可能自定義xterm或lxterminal?(它們是我使用最多的終端)。
謝謝!
GENIALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL 🙂
一周前,當我在另一個博客中閱讀此主題時,我嘗試了此方法,但是由於必須添加到該主題中的引號存在問題 的.bashrc 我無法使用它。 現在,它首先對我來說是正確的。
謝謝。
很高興知道它確實滿足了您的要求😉
問候
:]很棒,如果它能完成我想像中的... ... weeee,我這個週末就安裝install
實際上我改進了它,呵呵...我塗了更多的腮紅,看起來好多了,我將發表一篇帖子,發表我的改進和修改內容
編輯:不要把它放進去 .bash_ps2 換個說法: http://paste.desdelinux.net/paste/6
我在第13和34行出現錯誤。
我們已經2歲了
操,另一個黑暗的程序員...
我把代碼留在這裡,我不知道為什麼它給他們一個錯誤... o_0U對我來說很好:
# Fill with minuses
# (this is recalculated every time the prompt is shown in function prompt_command):
fill="--- "
reset_style='\[\033[00m\]'
status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
prompt_style=$reset_style
command_style=$reset_style'\[\033[1;29m\]' # bold black
# Prompt variable:
PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m$
# Reset color for command output
# (this one is invoked every time before a command is executed):
trap 'echo -ne "\e[0m"' DEBUG
function prompt_command {
# create a $fill of all screen width minus the time string and a space:
let fillsize=${COLUMNS}-9
fill=""
while [ "$fillsize" -gt "0" ]
do
fill="-${fill}" # fill with underscores to work on
let fillsize=${fillsize}-1
done
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
bname=`basename "${PWD/$HOME/~}"`
echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
;;
*)
;;
esac
}
PROMPT_COMMAND=prompt_command
很好,我剛剛測試了它,而且可以100%使用ubuntu 11.10
問候!!
好吧,我在第13和34行上也遇到了錯誤
第13行:搜索匹配的``時出現意外的EOF
第34行:語法錯誤:預計文件末尾
我用linux mint 11 lxde值錢。
的問候!
它對普通用戶可以100%起作用,但是當您成為超級用戶後,它就停止工作,它什麼也沒做。 我想這很容易,但是我不知道該怎麼做,有什麼解決辦法嗎?
你在你的東西 的.bashrc,您還必須將其放入 /root/.bashrc
參加考試,告訴我們你好嗎🙂
問候😀
它運作完美,在問之前我不知道我是如何嘗試過的。 謝謝
不用擔心worry
嘿朋友,如果您能幫助我,請嘗試一下,但是圓圈沒有出現,它仍然是黑色的,我使用fedora19,如果出現時間軸,則......仍然非常感謝您的貢獻🙂
在debian上這工作相同嗎?