xterm标题栏:显示带有空格的路径?

xterm标题栏:显示带有空格的路径?

解决方案:程序中存在错误。下面的睡眠说明帮助我找到了它。

有谁知道如何做到这一点?

我尝试了以下操作,但空格前的反斜杠转义在 xterm 或 Apple 终端中无法按预期工作:

  SEARCH=' '
  REPLACE='_' # XXX fix display of spaces
  PWD_SPACE="${PWD//$SEARCH/$REPLACE}"

完整上下文:

  # replace spaces with percent sign for pathnames
  # with spaces
  SEARCH=' '
  REPLACE='%20'
  PWD_URL="${PWD//$SEARCH/$REPLACE}"

  SEARCH=' '
  REPLACE='_' # XXX fix display of spaces
  PWD_SPACE="${PWD//$SEARCH/$REPLACE}"

  if [ -n "$KSH_VERSION" ]; then
    TMP_PWD=$(shortpath $PWD_SPACE)
  else
    TMP_PWD=$(shortpath_bash_trunc $PWD_SPACE)
  fi

  if [ -t 0 ]; then 
    if [ "$TERM_PROGRAM" == "Apple_Terminal" ]; then
       #titlebar "${SYS} : ${PWD##*/}"
       $ECHOE "\033]0;\007"
       $ECHOE "\033]6;\007"
       $ECHOE "\033]7;file:$PWD_URL\007"
    elif [[ "$TERM" == *"xterm"* ]]; then
       $ECHOE "\033]0;$TMP_PWD\007"
       $ECHOE "\033]6;\007"
       $ECHOE "\033]7;\007"
    fi
  fi

相关内容