简体   繁体   English

如何更改 Ubuntu 提示

[英]How to change the Ubuntu prompt

Hello I´m using Xubuntu and I want to change the prompt.您好,我正在使用 Xubuntu,我想更改提示。

My actual prompt is to long, if I´m in a long path like:我的实际提示很长,如果我在一条很长的路上,比如:

Document/SubFolder_1/SubFolder_2/SubFolder_x/文档/子文件夹_1/子文件夹_2/子文件夹_x/

it appear something like它看起来像

my_name@CMGBiotools-VirtualBox :~ Document/SubFolder_1/subFolder_2/SubFolder_x/$

so I just want my_name and the last folder, something like:所以我只想要 my_name 和最后一个文件夹,例如:

my_name: SubFolder_x$

If I type echo $PS1 in the terminal, this is what appears:如果我在终端中输入echo $PS1 ,则会出现以下内容:

\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

and the .bashrc looks like: .bashrc 看起来像:

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

which of those lines do I have to modified ??我必须修改哪一行?

Thanks So Much !!!非常感谢 !!!

put this in your .bashrc把它放在你的.bashrc 中

PS1="[\u: \W]\$ "
export PS1

there is a whole bunch to read Prompt Statement variables有一大堆读取提示语句变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM