使用终端:改善控制台的外观

我是喜欢使用终端机的人之一。 我认为 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

我们打开一个终端,我们可以看到更改😀

出现在: 人类.


发表您的评论

您的电子邮件地址将不会被发表。 必填字段标有 *

*

*

  1. 负责数据:MiguelÁngelGatón
  2. 数据用途:控制垃圾邮件,注释管理。
  3. 合法性:您的同意
  4. 数据通讯:除非有法律义务,否则不会将数据传达给第三方。
  5. 数据存储:Occentus Networks(EU)托管的数据库
  6. 权利:您可以随时限制,恢复和删除您的信息。

  1.   路德

    首先,感谢您的博客以及一个问题,除了文本和背景的颜色之外,是否可以自定义xterm或lxterminal?
    谢谢

  2.   爱德华多

    GENIALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL 🙂

    一周前,当我在另一个博客中阅读此主题时,我尝试了此方法,但是由于必须添加到该主题中的引号存在问题 的.bashrc 我无法使用它。 现在,它首先对我来说是正确的。

    谢谢。

    1.    KZKG ^ Gaara

      很高兴知道它确实满足了您的要求😉
      问候

  3.   塔雷贡

    :]如果它能达到我想像中的效果,那么非常好... weeee,我本周末安装

    1.    KZKG ^ Gaara

      实际上我改进了它,呵呵...我涂了更多的腮红,看起来好多了,我将发表一篇帖子,发表我的改进和修改内容😉

      编辑:不要把它放进去 .bash_ps2 换个说法: http://paste.desdelinux.net/paste/6

      1.    爱德华多

        我在第13和34行出现错误。

        1.    elav <°Linux

          我们已经2岁了

      2.    勇气

        操,另一个黑暗的程序员...

        1.    KZKG ^ Gaara

          我把代码留在这里,我不知道为什么它给他们一个错误... 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

  4.   新手

    很好,我刚刚测试了它,而且可以100%使用ubuntu 11.10

    问候!!

  5.   抢劫

    好吧,我在第13和34行上也遇到了错误

    第13行:搜索匹配的``时出现意外的EOF
    第34行:语法错误:预计文件末尾

    我用linux mint 11 lxde值钱。

    的问候!

  6.   吉姆·金尔金

    它对普通用户可以100%起作用,但是当您成为超级用户后,它就停止工作,它什么也没做。 我想这很容易,但是我不知道该怎么做,有什么解决办法吗?

    1.    KZKG ^ Gaara

      你在你的东西 的.bashrc,您还必须将其放入 /root/.bashrc
      参加考试,告诉我们你好吗🙂

      问候😀

      1.    吉姆·金尔金

        它运行完美,在问之前我不知道我是如何尝试过的。 谢谢

        1.    KZKG ^ Gaara <°Linux

          不用担心worry

  7.   天使

    嘿朋友,如果您能帮助我,请尝试一下,但是圆圈没有出现,它仍然是黑色的,我使用了fedora19,如果出现的话,时间轴...仍然非常感谢您的贡献🙂

  8.   米格尔

    在debian上这工作相同吗?