学习啦 > 学习电脑 > 电脑安全 > 系统安全 > Linux中如何设置命令提示字符

Linux中如何设置命令提示字符

时间: 黎正888 分享

学习啦在线学习网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中如何设置命令提示字符

时间: 黎正888 分享

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

7" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'

  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中如何设置命令提示字符相关文章:

1.Linux如何设置命令提示字符

2.如何在windows系统中使用linux的命令

3.Linux怎么更改命令提示符信息

4.win7系统如何以管理员身份打开命令字符

5.Linux下如何使用sed命令替换字符串

2114111