Fish Shell:如果没有运行,请检查并运行进程

时间:2016-04-18 01:06:10

标签: terminal fish mpd

我想在打开终端时启动进程[mpd],并在我打开第二个选项卡时检查它是否已经运行,这样它就不会再尝试运行它了。这就是我以前在.bashrc上的内容:

#start mpd automatically if not yet running.
if [[ -z "$(pgrep mpd)" ]]; then
  mpd
fi

我想是这样的,或者可能使用test -f,但我无法弄清楚如何让它发挥作用:

# MPD
if pgrep mpd > /dev/null 
  command mpd
end

[这位于我的config.fish文件中]。

1 个答案:

答案 0 :(得分:3)

您可以添加到config.fish

if not pgrep -f mpd > /dev/null
    command mpd
end

或者如果你使用鱼> = 2.3.0~/.config/fish/conf.d/*来更好地分离问题。

相关问题