3

I want to start a process [mpd] when I open up terminal, and check if it's already running when I open a second tab so it won't try to run it again. This is what I used to have on my .bashrc:

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

I suppose is something like this, or maybe using test -f, but I can't figure out how to make it work:

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

[this is located on my config.fish file].

miguelopezv
  • 790
  • 2
  • 8
  • 28

1 Answers1

5

You could add to your config.fish.

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

Or if you are using fish >= 2.3.0 to ~/.config/fish/conf.d/* for a better separation of concerns.

Jorge Bucaran
  • 5,588
  • 2
  • 30
  • 48