我安装了gnome-terminal和Guake。我想提供不同的启动消息,以在这些终端仿真器启动时显示。我应该在.bashrc中编写哪些代码才能实现?
此功能应该可以完成以下任务:
container() {
pid=$$
while true; do
pid=$(ps -h -o ppid -p $pid 2>/dev/null)
case $(ps -h -o comm -p $pid 2>/dev/null) in
(gnome-terminal) echo "Running in gnome terminal";return;;
(xterm) echo "Running in xterm";return;;
(rxvt) echo "Running in rxvt";return;;
(python) if [ ! -z "$(ps -h -o args -p $pid 2>/dev/null | grep guake)" ]; then echo "Running in Guake"; return; fi ;;
esac
[[ $(echo $pid) == 1 ]] && break
done
}
container
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句