RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1211103
Accepted
TWOfish
TWOfish
Asked:2021-11-28 23:32:33 +0000 UTC2021-11-28 23:32:33 +0000 UTC 2021-11-28 23:32:33 +0000 UTC

设置 xfce4-terminal

  • 772

Ubuntu 20.04 模拟上的新鲜 xfce4-terminal v0.8.9.1。- Linux 精简版 5.2

~$ echo $SHELL
/bin/bash

显示一些命令后: 学期

其中 学期

问题:

  1. 上图中的“1”和“130”是什么意思?(我没有具有此类名称的目录) 130 是以前的历史命令的一些数字吗?以某种方式与上一个命令的管道有关?和“1”?
  2. 如何使这些数字不显示,只保留通常的输出显示,但不禁用新的图形显示?

同时:在终端配置设置中,'/ home/ex/.config/xfce4/terminal/terminalrc'我找不到这个设置。

B .bashrc 缺少 $PS1,有两个循环:

# enable bash completion in interactive shells
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

...

# Powerline
if [ -f /usr/share/powerline/bindings/bash/powerline.sh ]; then
    source /usr/share/powerline/bindings/bash/powerline.sh
fi

我没有在内容中找到任何提及 $PS1的内容/usr/share/bash-completion/bash_completion,它非常庞大,我不知道发布它是否有意义,但是如果我将 .bashrc 中的第二个循环注释掉'/usr/share/powerline/bindings/bash/powerline.sh'

然后返回通常的简单文本:

~$ echo $PS1
${debian_chroot:+($debian_chroot)}\u@\h:\w\$

但是,提示的彩色图形显示随即消失。


powerline.sh 内容

cat /usr/share/powerline/bindings/bash/powerline.sh
_powerline_columns_fallback() {
    if which stty &>/dev/null ; then
        local cols="$(stty size 2>/dev/null)"
        if ! test -z "$cols" ; then
            echo "${cols#* }"
            return 0
        fi
    fi
    echo 0
    return 0
}

_powerline_tmux_pane() {
    echo "${TMUX_PANE:-`TMUX="$_POWERLINE_TMUX" tmux display -p "#D"`}" | \
        tr -d ' %'
}

_powerline_tmux_setenv() {
    TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`_powerline_tmux_pane` "$2"
    TMUX="$_POWERLINE_TMUX" tmux refresh -S
}

_powerline_tmux_set_pwd() {
    if test "$_POWERLINE_SAVED_PWD" != "$PWD" ; then
        _POWERLINE_SAVED_PWD="$PWD"
        _powerline_tmux_setenv PWD "$PWD"
    fi
}

_powerline_return() {
    return $1
}

_POWERLINE_HAS_PIPESTATUS="$(
    _powerline_return 0 | _powerline_return 43
    test "${PIPESTATUS[*]}" = "0 43"
    echo "$?"
)"

_powerline_has_pipestatus() {
    return $_POWERLINE_HAS_PIPESTATUS
}

_powerline_status_wrapper() {
    local last_exit_code=$? last_pipe_status=( "${PIPESTATUS[@]}" )

    if ! _powerline_has_pipestatus \
       || test "${#last_pipe_status[@]}" -eq "0" \
       || test "$last_exit_code" != "${last_pipe_status[$(( ${#last_pipe_status[@]} - 1 ))]}" ; then
        last_pipe_status=()
    fi
    "$@" $last_exit_code "${last_pipe_status[*]}"
    return $last_exit_code
}

_powerline_add_status_wrapped_command() {
    local action="$1" ; shift
    local cmd="$1" ; shift
    full_cmd="_powerline_status_wrapper $cmd"
    if test "$action" = "append" ; then
        PROMPT_COMMAND="$PROMPT_COMMAND"$'\n'"$full_cmd"
    else
        PROMPT_COMMAND="$full_cmd"$'\n'"$PROMPT_COMMAND"
    fi
}

_powerline_tmux_set_columns() {
    _powerline_tmux_setenv COLUMNS "${COLUMNS:-`_powerline_columns_fallback`}"
}

_powerline_init_tmux_support() {
    if test -n "$TMUX" && tmux refresh -S &>/dev/null ; then
        # TMUX variable may be unset to create new tmux session inside this one
        _POWERLINE_TMUX="$TMUX"

        trap '_powerline_tmux_set_columns' WINCH
        _powerline_tmux_set_columns

        test "$PROMPT_COMMAND" != "${PROMPT_COMMAND/_powerline_tmux_set_pwd}" \
            || _powerline_add_status_wrapped_command append _powerline_tmux_set_pwd
    fi
}

_powerline_local_prompt() {
    # Arguments:
    # 1: side
    # 2: renderer_module arg
    # 3: last_exit_code
    # 4: last_pipe_status
    # 5: jobnum
    # 6: local theme
    "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
        $2 \
        --last-exit-code=$3 \
        --last-pipe-status="$4" \
        --jobnum=$5 \
        --renderer-arg="client_id=$$" \
        --renderer-arg="local_theme=$6"
}

_powerline_prompt() {
    # Arguments:
    # 1: side
    # 2: last_exit_code
    # 3: last_pipe_status
    # 4: jobnum
    "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
        --width="${COLUMNS:-$(_powerline_columns_fallback)}" \
        -r.bash \
        --last-exit-code=$2 \
        --last-pipe-status="$3" \
        --jobnum=$4 \
        --renderer-arg="client_id=$$"
}

_powerline_set_prompt() {
    local last_exit_code=$1 ; shift
    local last_pipe_status=$1 ; shift
    local jobnum="$(jobs -p|wc -l)"
    PS1="$(_powerline_prompt aboveleft $last_exit_code "$last_pipe_status" $jobnum)"
    if test -n "$POWERLINE_SHELL_CONTINUATION$POWERLINE_BASH_CONTINUATION" ; then
        PS2="$(_powerline_local_prompt left -r.bash $last_exit_code "$last_pipe_status" $jobnum continuation)"
    fi
    if test -n "$POWERLINE_SHELL_SELECT$POWERLINE_BASH_SELECT" ; then
        PS3="$(_powerline_local_prompt left '' $last_exit_code "$last_pipe_status" $jobnum select)"
    fi
}

_powerline_setup_prompt() {
    VIRTUAL_ENV_DISABLE_PROMPT=1
    if test -z "${POWERLINE_COMMAND}" ; then
        POWERLINE_COMMAND="$("$POWERLINE_CONFIG_COMMAND" shell command)"
    fi
    test "$PROMPT_COMMAND" != "${PROMPT_COMMAND%_powerline_set_prompt*}" \
        || _powerline_add_status_wrapped_command prepend _powerline_set_prompt
    PS2="$(_powerline_local_prompt left -r.bash 0 0 0 continuation)"
    PS3="$(_powerline_local_prompt left '' 0 0 0 select)"
}

if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
    if which powerline-config >/dev/null ; then
        POWERLINE_CONFIG_COMMAND=powerline-config
    else
        POWERLINE_CONFIG_COMMAND="$(dirname "$BASH_SOURCE")/../../../scripts/powerline-config"
    fi
fi

if "${POWERLINE_CONFIG_COMMAND}" shell --shell=bash uses prompt ; then
    _powerline_setup_prompt
fi
if "${POWERLINE_CONFIG_COMMAND}" shell --shell=bash uses tmux ; then
    _powerline_init_tmux_support
fi
консоль
  • 1 1 个回答
  • 10 Views

1 个回答

  • Voted
  1. Best Answer
    DiD
    2021-11-29T02:15:30Z2021-11-29T02:15:30Z

    如果您不使用 Powerline 的功能,您可以关闭它。要保持 PROMPT 的外观,您需要添加.bashrc以下脚本。所有功能“开箱即用”(无需设置)。你可以改变一些东西,删减一些东西,添加一些东西。我根据这篇文章编译了我的提示:Bash/Prompt 定制。

    电力线提示

    #
    # Fallback prompt
    #
    
    
    PS1='\u@\h \W\$ '
    
    PROMPT_COMMAND=__UPDATE_PROMPT
    
    #
    # Prompt palete
    #
    #   0  Success color
    #   1  Failed color
    #   2  Return color
    #   3  Muted color
    #   4  User fg color
    #   5  User bg color
    #   6  Host fg color
    #   7  Host bg color
    #   8  CWD fg color
    #   9  CWD bg color
    #  10  RootUser fg color
    #  11  RootUser bg color
    #
    #
    #                 0   1   2   3   4   5   6   7   8   9  10  11
    PROMPT_PALETTE=( 32 196   7 238 255  60 232  66 232 208 255 196 )
    PROMPT_PALETTE=( 32 196   7 238 232  38 255  32 255  24 255 196 )
    PROMPT_PALETTE=( 32 196   7 238 232 225 232  77 232 227 '231;1' 196 )
    # PROMPT_PALETTE=( 32 196   7 238 232  38 255  32 255  24 255 196 )
    
    __UPDATE_PROMPT(){
        local _R=$? PP=( ${PROMPT_PALETTE[*]} )
      { [[ -v MC_SID ]] || [[ $TERM == linux ]];} && return
      RE='\[\e[0m\]'  BO='\[\e[1m\]'  INV='\[\e[7m\]' NL='\\n' 
      FG='\[\e[38;5;' BG='\[\e[48;5;' M='m\]'
      OK=$RE$FG${PP[0]:-32}$M"\\xe2\\x9c\\x85"$RE$NL
      ER='\[\e[$(($COLUMNS-5))G\]'$FG${PP[2]:-7}$M$(printf %3d\  $_R)
      ED=$RE$FG${PP[1]:-196}$M"\\xe2\\x9c\\x95"$RE$NL
      OF='\[\e[1A\]\[\e[$(($COLUMNS-1))G\]' DT='\D{%Y-%m-%dT%H:%M:%S%z}' 
      AL="\\xee\\x82\\xb2" AR="\\xee\\x82\\xb0" DO='\[\e[$(($COLUMNS-27))G\]'
      DE=$DO$FG${PP[3]:-238}$M'E: '$DT$RE$NL
      DS=$DO$FG${PP[3]:-238}$M'S: '$DT$RE$NL
      [[ $_R -eq 0 ]] && RL=$OF$OK || RL=$OF$ER$ED
      [[ $UID -eq 0 ]] && { UB="${PP[11]:-196}"; UF="${PP[10]:-255}"; } ||
          { UB="${PP[5]:-60}"; UF="${PP[4]:-255}"; }
      UL=$BG$UB$M$FG$UF$M' $USER '$FG$UB$M
      HL=$BG${PP[7]:-66}$M$AR$FG${PP[6]:-232}$M' $HOSTNAME '$FG${PP[7]:-66}$M
      PL=$BG${PP[9]:-208}$M$AR$FG${PP[8]:-232}$M$BO' $CWD '$RE$FG${PP[9]:-208}$M
      CWD=`pwd` USER=`whoami` HOSTNAME=`hostname`
      [[ ${#CWD} -ge ${#HOME} ]] && [[ $HOME == ${CWD:0:${#HOME}} ]] &&
        [[ ${#HOME} -gt 1 ]] && CWD=\~${CWD:${#HOME}}
      [[ -z $COLUMNS ]] && PS1=$UL$HL$PL$AR$RE\  && PS0= && return
      THIRD=$(echo "$COLUMNS/3" | bc) DL="\\xe2\\x80\\xa6"
      PS2=$(echo -e $FG$UB$M$INV$AL$RE\ )
      [[ $(echo " $USER  $HOSTNAME  $CWD  " | wc -c) -gt $THIRD ]] &&
        HL='' && [[ $(echo " $USER  $CWD  " | wc -c) -gt $THIRD ]] &&
        UL=$FG$UB$M && [[ $(echo "  $CWD  " | wc -c) -gt $THIRD ]] &&
        CWD=$(echo $CWD | perl -pe 's/([^\/]{2})[^\/]{2,9}[\/]/\1'$DL'\//g') &&
        PS2=$(echo -e $FG${PP[9]:-208}$M$INV$AL$RE)
      PS1=$(echo -e $RL$DE$UL$HL$PL$AR$RE\ )
      PS0=$(echo -e $DS$RE )  
      export CWD USER HOSTNAME
    }
    

    看起来有点凶。调色板是从数组中读取的 ${PROMPT_PALETTE}。
    颜色按以下顺序列出:

    1. 成功的颜色,
    2. 蘸色,
    3. 上一条命令返回的值的颜色,
    4. 时间戳颜色,
    5. 用户名字体颜色,
    6. 用户名背景颜色,
    7. 主机名字体颜色,
    8. 主机名背景颜色,
    9. 当前目录的字体颜色,
    10. 当前目录的背景色,
    11. 根用户名的字体颜色,
    12. 根用户名的背景颜色,

    颜色代码可以在维基百科上找到。

    字符代码可以在这里找到:

    • 箭头,
    • 技术符号,
    • 绘制窗户和桌子,
    • 块元素,
    • 几何形状,
    • 各种各样的事情。

    我还注意到关于 BASH 的一个很好的资源:wiki.bash-hackers.org

    • 2

相关问题

  • 格式化输出到控制台 C#

  • 如何在vim窗口中打开终端

  • 如何规定进入终端时不重置 $PATH?

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    如何从列表中打印最大元素(str 类型)的长度?

    • 2 个回答
  • Marko Smith

    如何在 PyQT5 中清除 QFrame 的内容

    • 1 个回答
  • Marko Smith

    如何将具有特定字符的字符串拆分为两个不同的列表?

    • 2 个回答
  • Marko Smith

    导航栏活动元素

    • 1 个回答
  • Marko Smith

    是否可以将文本放入数组中?[关闭]

    • 1 个回答
  • Marko Smith

    如何一次用多个分隔符拆分字符串?

    • 1 个回答
  • Marko Smith

    如何通过 ClassPath 创建 InputStream?

    • 2 个回答
  • Marko Smith

    在一个查询中连接多个表

    • 1 个回答
  • Marko Smith

    对列表列表中的所有值求和

    • 3 个回答
  • Marko Smith

    如何对齐 string.Format 中的列?

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5