题
我敢肯定有一个答案,这本手册中的屏幕,但我无法找到它! 我想通过GNU屏幕中除了.bashrc中一个文件催生到源bash外壳,它已经运行。
我不能把对.bashrc中文件的调用,因为在我们网站上的.bashrc文件会在登录时自动重新生成。
任何想法?
编辑:
我建立这个小脚本(screen_bash.sh):
bash --rcfile ~/.screen_bashrc
然后加入
shell $HOME/screen_bash.sh
要我.screenrc
在〜/ .screen_bashrc文件是
<my_setup_stuff>
export SHELL=bash
在SHELL = bash中是必要的,以便像vim程序可以正确启动子壳。
解决方案
你想这个文件被打开一个新的窗口,屏幕每一次采购?如果是这样,壳命令允许您覆盖是什么当你创建一个新的屏幕窗口(默认情况下它只是$ SHELL)运行。您可以设置这是你选择的一个脚本,在最后运行你的shell。
其他提示
screen bash --rcfile yourfile.rc
yourfile.rc
应源.bashrc
。
修改:这并没有真正做你想做的,我才意识到你可能希望它应用到的所有的外壳由屏幕开始
我之前就已经这样做,但现在我意识到,这是更好地为系统初始化服务运行。你可以找到我的脚本连接到这个bug报告。希望这将可在屏幕的Gentoo的ebuild的一部分。我会保持它最新的 github上。
start() {
for SCREENRC in /etc/screen.d/* ; do
SESSION="$(basename $SCREENRC)"
## I don't think there may be a security issue,
## provided that users will not be have write
## permission in /etc/screen.d/ and if anyone
## gained access to mod the session file, they
## are in already anyhow!
BELONGS="$(stat $SCREENRC --printf=%U)"
MYSHELL="$(getent passwd $BELONGS | cut -d: -f7)"
COMMAND="/usr/bin/screen -- -U -D -m -c ${SCREENRC} -S ${SESSION} -t ${SESSION}"
## Why on earth would one write this ???
#HOMEDIR="$(getent passwd $BELONGS | cut -d: -f6)"
ebegin "Starting screen session ${SESSION} for ${BELONGS}"
PIDFILE="/var/run/screen.${BELONGS}.${SESSION}.pid"
start-stop-daemon \
--env TERM="rxvt" \
--env HOME="~${BELONGS}" \
--env SCREEN_SESSION=${SESSION} \
--user $BELONGS \
--chdir "~${BELONGS}" \
--make-pidfile \
--background \
--pidfile=${PIDFILE} \
--exec ${COMMAND}
eend $?
done
}
stop() {
## Perhaps we should determin this by pidfiles ...
## but this way is not bad either!
for SCREENRC in /etc/screen.d/* ; do
SESSION="$(basename $SCREENRC)"
BELONGS="$(stat $SCREENRC --printf=%U)"
PIDFILE="/var/run/screen.${BELONGS}.${SESSION}.pid"
PROCESS="$(cat ${PIDFILE})"
if [ -e /proc/${PROCESS}/status ]; then
grep -i "Name:" /proc/${PROCESS}/status | grep -iq "screen" || continue
ebegin "Stopping screen session ${SESSION} for ${BELONGS} (PID: ${PROCESS})"
## There other things we can try here ...
## perhaps add /etc/screen.d/$SESSION.stop
## It will CERTAINly kill the righ screen!
CERTAIN="${PROCESS}.${SESSION}"
env TERM="urxvt" \
start-stop-daemon \
--user ${BELONGS} \
--exec /usr/bin/screen -- -S $CERTAIN -X quit
eend $?
fi
rm -f $PIDFILE
done
}
不隶属于 StackOverflow