未在屏幕内设置终端标题

问题描述 投票:0回答:1

当前,我正在screen命令中设置终端标题,但是bash脚本给了我:

无法执行'source / etc / profile && title.set root @ test':没有这样的文件或目录

而且我可以直接从命令行成功运行以上命令,这是我的脚本:

在/ usr / local / bin中/秒

#!/bin/bash
if [ $1 ]
then
    screen -D -R $1 -m "source /etc/profile && title.set `whoami`@$1"
else
    screen -R
fi

/ etc / profile中

...
# Source global bash config
if test "$PS1" && test "$BASH" && test -z ${POSIXLY_CORRECT+x} && test -r /etc/bash.bashrc; then
        . /etc/bash.bashrc
fi

function title.set() {
      if [[ -z "$ORIG"  ]]; then
          ORIG=$PS1
      fi
      TITLE="\[\e]2;$*\a\]"
      PS1=${ORIG}${TITLE}

}
# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP

# Man is much better than us at figuring this out
unset MANPATH
...

那么这里怎么了?

bash terminal gnu-screen
1个回答
0
投票

关键字source是bash 内置命令,即,对于<< exec >>不一定需要实际文件的东西(另一个内置命令)。您只能exec是文件文件,例如bash,例如这样的文件:screen -D -R $1 -m bash -c "source /etc/profile && title.set `whoami`@$1"

© www.soinside.com 2019 - 2024. All rights reserved.