通过查询,找到一种简单的处理方式,就是讲如下代码加到~/.bashrc的最后位置。

(一)修改title名字

1 title 通过添加来实现

vim ~/.bashrc

  1. function set-title() {
  2. if [[ -z "$ORIG" ]]; then
  3. ORIG=$PS1
  4. fi
  5. TITLE="\[\e]2;title的名字\a\]"
  6. PS1=${ORIG}${TITLE}
  7. }
  8. set-title

2 直接改~/.bashrc文件。

  1. case "$TERM" in
  2. xterm*|rxvt*)
  3. PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@title的名字: \w\a\]$PS1"
  4. ;;
  5. *)
  6. ;;
  7. esac

在这里插入图片描述

(二)修改命令行的名字

vim ~/.bashrc

  1. if [ "$color_prompt" = yes ]; then
  2. PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\命令行的名字\[033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  3. else
  4. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  5. fi

source ~/.bashrc
在这里插入图片描述