【fedora】 PS1 Setting for Bash
一、【PS1】设置( PS1='[\[\033[1;31m\]\u@\h:\W\[\033[00m\]]$ ' )
# position: /etc/bashrc
# date: 20250416
if [[ $USER = "root" ]]
then
PS1='[\[\033[1;31m\]\u@\h:\W\[\033[00m\]]# '
else
PS1='[\[\033[1;31m\]\u@\h:\W\[\033[00m\]]$ '
fi
[wit@fedora:tmp]$ cat ~/.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]; then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
. "$rc"
fi
done
fi
unset rc
PS1='[\[\033[1;31m\]\u@\h:\W\[\033[00m\]]$ '
二、参考资料
1、 PS1 -- man bash; /PROMPTING; /PS1
本文由 lnlidawei 原创、整理、转载,本文来自于【博客园】; 整理和转载的文章版权归属【原创作者】; 转载或引用时【请保留文章的来源信息】:https://www.cnblogs.com/lnlidawei/p/18778799

浙公网安备 33010602011771号