Linux中如何设置命令提示字符
Linux中如何设置命令提示字符
Linux中支持自定义command的prompt字符,下面就让学习啦小编教大家Linux中如何设置命令提示字符吧。
Linux中设置命令提示字符的方法
使用echo $PS1命令查看prompt字符
[root@golonglee ~]# echo $PS1
[\u@\h \W]$
[root@golonglee ~]#
在/etc/inittab文件中可以是初始化列表
这是vi /etc/bashrc文件的内容
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -z "$PROMPT_COMMAND" ]; then
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='printf "3]0;%s@%s:%s
Linux中如何设置命令提示字符
Linux中如何设置命令提示字符
Linux中支持自定义command的prompt字符,下面就让学习啦小编教大家Linux中如何设置命令提示字符吧。
Linux中设置命令提示字符的方法
使用echo $PS1命令查看prompt字符
[root@golonglee ~]# echo $PS1
[\u@\h \W]$
[root@golonglee ~]#
在/etc/inittab文件中可以是初始化列表
这是vi /etc/bashrc文件的内容
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -z "$PROMPT_COMMAND" ]; then
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='printf "3]0;%s@%s:%s
fi
;;
screen)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='printf "3]0;%s@%s:%s3\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
fi
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\s-\v\$ " ] && PS1="[\u@\h \W]\$ "
编辑etc目录下的bashrc文件,可以修改提示符
Linux中如何设置命令提示字符相关文章:
热门文章
热搜文章
精彩文章
- 小米wifi放大器使用指南与故障排查技巧
- 2025年显示器黑屏原因解析及解决方案汇总
- 台式电脑怎么重装系统win7详细教程
- 2025年[win11虚拟机激活]教程
- 数据恢复工具不可以恢复什么详解2025版
- win7精简版下载
- win7激活方法大全
- win11系统重装后无法分盘解决教程
- 重装系统选哪几项内容好2025年实用指南
- [win11星露谷物语mod]安装指南
- 小编为你解答游戏本3050显卡什么水平
- [qq输入法]:打字更快,输入更准,让你的手机输入体验升级!
- 格式化后数据恢复指南:2025年实用方法详解
- 青州重装系统多少钱2025年价格指南
- 手机号查询机主姓名合法吗?2025年最新法律法规解读
- U盘误删数据恢复
