博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Fedora 27 命令行提示符修改
阅读量:6985 次
发布时间:2019-06-27

本文共 3262 字,大约阅读时间需要 10 分钟。

在Fedora 27中要修改命令行提示符,可以编辑文件/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.# Prevent doublesourcingif [ -z "$BASHRCSOURCED" ]; then  BASHRCSOURCED="Y"  # are we an interactive shell?  if [ "$PS1" ]; then    if [ -z "$PROMPT_COMMAND" ]; then      case $TERM in      xterm*|vte*)        if [ -e /etc/sysconfig/bash-prompt-xterm ]; then            PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm        elif [ "${VTE_VERSION:-0}" -ge 3405 ]; then            PROMPT_COMMAND="__vte_prompt_command"        else            PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${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 "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'        fi        ;;      *)        [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default        ;;      esac    fi    # Turn on parallel history    shopt -s histappend    history -a    # Turn on checkwinsize    shopt -s checkwinsize    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \\$\[\033[00m\] "    # You might want to have e.g. tty in prompt (e.g. more virtual machines)    # and console windows    # If you want to do so, just add e.g.    # if [ "$PS1" ]; then    #   PS1="[\u@\h:\l \W]\\$ "    # fi    # to your custom modification shell script in /etc/profile.d/ directory  fi  if ! shopt -q login_shell ; then # We're not a login shell    # Need to redefine pathmunge, it gets undefined at the end of /etc/profile    pathmunge () {        case ":${PATH}:" in            *:"$1":*)                ;;            *)                if [ "$2" = "after" ] ; then                    PATH=$PATH:$1                else                    PATH=$1:$PATH                fi        esac    }    # By default, we want umask to get set. This sets it for non-login shell.    # Current threshold for system reserved uid/gids is 200    # You could check uidgid reservation validity in    # /usr/share/doc/setup-*/uidgid file    if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then       umask 002    else       umask 022    fi    SHELL=/bin/bash    # Only display echos from profile.d scripts if we are no login shell    # and interactive - otherwise just process them to set envvars    for i in /etc/profile.d/*.sh; do        if [ -r "$i" ]; then            if [ "$PS1" ]; then                . "$i"            else                . "$i" >/dev/null            fi        fi    done    unset i    unset -f pathmunge  fifi# vim:ts=4:sw=4

第45行修改为:

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \\$\[\033[00m\] "

即可。这里是我已经修改过的。

然后重新登录。

修改后的效果如下:

lwk@redora ~ $ sudo vim /etc/bashrc lwk@redora ~ $ cd /optlwk@redora /opt $

转载于:https://blog.51cto.com/qwfys200/2071405

你可能感兴趣的文章
从运维的角度理解Iaas、Paas、Saas云计算
查看>>
使用动画播放文件夹中的图片
查看>>
logging模块
查看>>
C# 将string 转换为二维码图片,然后转为base64字符串编码 。
查看>>
软件工程概论03
查看>>
js截取最后一个斜杠之后的内容
查看>>
Java程序安装失败
查看>>
解决网络请求的依赖关系
查看>>
设计模式(4)建造者模式/生成器模式(Builder)
查看>>
hdu 1036 (I/O routines, fgets, sscanf, %02d, rounding, atoi, strtol) ...
查看>>
开闭原则
查看>>
Silverlight 4常用StringFormat格式总结
查看>>
think in uml-关系
查看>>
androidSDK配置环境变量
查看>>
BZOJ 1003 物流运输 最短路+dp
查看>>
leetcode 63. Unique Paths II
查看>>
在Android Studio进行“简单配置”单元测试(Android Junit)
查看>>
编写测试:VC下获取文件大小的4种方法
查看>>
MongoDB的安装
查看>>
C语言断言
查看>>