Fedora 27 命令行提示符修改

在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 doublesourcing
if [ -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;%[email protected]%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%[email protected]%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\]\[email protected]\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="[\[email protected]\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
  fi

fi
# vim:ts=4:sw=4

第45行修改为:

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

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

然后重新登录。

修改后的效果如下:

[email protected] ~ $ sudo vim /etc/bashrc
[email protected] ~ $ cd /opt
[email protected] /opt $

原文地址:http://blog.51cto.com/qwfys200/2071405

时间: 2024-08-26 02:53:32

Fedora 27 命令行提示符修改的相关文章

Linux命令行提示符设置

我们使用Linux系统时接触最多的是它的命令行窗口,很多时候我们都需要在命令行上输入命令,在输入的命令前都会有提示符,一般系统默认的提示符形式是:[[email protected] 工作目录]$. 其实,我们可以为自己订制个性化的命令行提示符,Linux系统提示符是用系统变量PS1来定义的,只要按规则修改PS1系统变量的值随意修改命令行提示符. 通过命令echo $PS1查看PS1的值,即PS1="[\[email protected]\h: \w \t]\$ ".修改PS1的值后,

[转]Windows中的命令行提示符里的Start命令执行路径包含空格时的问题

转自:http://www.x2009.net/articles/windows-command-line-prompt-start-path-space.html 当使用Windows 中的命令行提示符执行这段指令时(测试Start命令执行带空格的路径的程序或文件问题),第一行Start会成功执行,跳出记事本程序,而第二行,会 Start跳出一个新的命令提示符,标题上写着路径,但是不会执行任何命令,第三行Start命令行提示符会提示C:\Program文件不存在,提示无 法执行. start

定制bash命令行提示符

Bash中内置了PS1/PS2/PS3/PS4及PROMPT_COMMAND共5个变量,其中PS1用于命令行提示符. 默认为 [[email protected] lxh]# echo $PS1[\[email protected]\h \W]\$ 可对其设置自定义颜色及显示样式. export PS1='\[\e[0;32m\][\[email protected]\h \w \$]\[\e[m\]' 其中\033可用\e替换,二者效果一样 export PS1='\[\033[01;32m\

.bat批处理脚本让cmd命令行提示符cd到工作目录 (转)

打开cmd,检查命令行提示符所在的默认位置(目录),进入该目录用notepad++创建一个文件,输入 @echo offrem 这个符号表示该行是注释.rem 进入f盘,需要先切换盘符,成功后才能进入该盘下的目录f:cd \myworkspace\echo Job is done 然后保存文件,命名为 gtd.bat 直接变成了可执行的批处理脚本. 然后在cmd的命令行提示下执行该脚本(如下): gtd.bat 命令行提示符于是就进入目录f:/myworkspace/ 来自: http://ww

Linux终端护眼颜色和命令行提示符设置

终端护眼颜色设置: 背景颜色:#73989C  (宝蓝色) 文本颜色:#092833 命令行提示符设置: # vim ~/.bashrc 末尾加一行: PS1='[\[\e[32m\]\[email protected]\h\[\e[m\]: \[\e[36m\]\W\[\e[m\]]\$ ' 效果: PS1的常用参数以及含义: \d :代表日期,格式为weekday month date,例如:"Mon Aug 1" \H :完整的主机名称 \h :仅取主机名中的第一个名字 \t :

个性定制你的 Git 命令行提示符

1, 让BASH 命令行显示当前支线 以及 显示提交状态 并且使用不同颜色高亮区分 效果图: 进入到git的工作目录后,显示当前所在支线名称 如果有已跟踪 未暂存的版本,那么使用红色* 提示 如果有已跟踪 未提交的版本,那么使用**** 提示 切换到其他支线后 提示符能打印当前支线名称 切换到非Git工作目录后,不影响其他操作. 定制原理:主要就是修改 PS1 变量(如果不知道PS1是什么,那么请先了解). 修改bashrc  不管是全局的,还是当前用户的 function get_git_br

在 Android studio 中 配置Gradle 做到 “根据命令行提示符生成指定versionCode, versionName,指定apk的打包输出路径”

需求: 1. 使用 Android studio ,使用 gradle 进行构建 2. 在实际开发中,我们需要使用jenkins进行打包.就需要配置我们的 gradle 脚本以支持参数化的方式. 3. 想获得一个可配置打包脚本的方法,允许 配置人员根据需要修改 服务器地址,versionCode, versionName 等 4. 隔离的源代码的配置,使用者在 jenkins里进行配置. 概述: 先展示我配置好的 参数,可以在命令提示行下执行,如下: gradle assembleBeta -P

命令行清空/修改 本地安全策略(组策略)->本地策略->用户权限分配->拒绝从网络访问此计算机 列表

命令行清空“拒绝从网络访问此计算机”选项列表,可通过SECEDIT /configure 命令实现 1.创建配置文件,将下面代码另存为一个文件,文件名可自定义(如:c:\cfg.inf) 1 [version] 2 signature="$CHICAGO$" 3 4 [Privilege Rights] 5 SeDenyNetworkLogonRight = 2.在CMD中执行命令,应用配置文件内容(使配置生效) secedit /configure /db a.db /cfg c:\

Linux启动时显示Grub命令行及修改

1.在启动Linux系统时,如果/boot/grub/grub.cfg文件损坏或者不存在时,启动Linux时,就会有Grub命令行的提示. 如下操作,将系统自带的grub.cfg文件改名. 2.重新启动系统后,发现和自己预想的一样,没有出现引导菜单. 3.在grub命令提示符下,可以使用一些命令加载内核和文件系统,设置根目录的分区. 有的grub使用 linux /boot/vmlinuz-xx 有的grub使用kernel /boot/vmlinuz-xx,可自己输入一个首字母,按TAB键查看