代码之家  ›  专栏  ›  技术社区  ›  Olivier Pons

壳牌一号班轮别名怎么办?

  •  0
  • Olivier Pons  · 技术社区  · 6 年前

    这是我生活的一小部分 ~/.bashrc .

    if [ -t 1 ]
    then
        # standard output is a tty
        # do interactive initialization
        # make bash autocomplete with up arrow
        bind '"\e[A":history-search-backward'
        bind '"\e[B":history-search-forward'
    fi
    

    现在我想在一行中将其转换为别名,如下所示:

    alias op_prompt="if [ -t 1 ] then (bind '"\e[A":history-search-backward'; bind '"\e[B":history-search-forward'; fi)"
    

    这不是正确的语法,我不明白何时何地不添加转义符(“ \ ").

    bind 在一个 if 一切合一 alias

    1 回复  |  直到 6 年前
        1
  •  2
  •   William Pursell    6 年前

    op_prompt() {
        if test -t 1; then
            bind '"\e[A":history-search-backward'
            bind '"\e[B":history-search-forward'
        fi
    }