diff --git a/documentation/kitfile.markdown b/documentation/kitfile.markdown index d79b228..80479d6 100644 --- a/documentation/kitfile.markdown +++ b/documentation/kitfile.markdown @@ -116,3 +116,8 @@ Available commands are: * symlink _SOURCE_ _DESTINATION_ Creates a symbolic link at _DESTINATION_ that points to _SOURCE_. + +* start _APPLICATION_ + + Starts _APPLICATION_ in the background to stop it from stealing focus + while `kitout` is still running. diff --git a/kitout.sh b/kitout.sh index b47ffea..344fdff 100755 --- a/kitout.sh +++ b/kitout.sh @@ -134,6 +134,7 @@ function process_kitfile { brewfile) brewfile "$argument" ;; install) install_file $argument ;; symlink) symlink $argument ;; + start) start "$argument" ;; remind) remind "$argument" ;; cron_entry) add_to_crontab "$argument" ;; @@ -269,6 +270,10 @@ function symlink { fi } +function start { + open -g -a "$1" +} + function add_to_crontab { local line="$*" local tab="$(mktemp '/tmp/kitout.crontab.XXXXX')" diff --git a/tests/start.bats b/tests/start.bats new file mode 100644 index 0000000..9699d60 --- /dev/null +++ b/tests/start.bats @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +@test cron_entry { + ! contacts_is_running + + run ./kitout.sh tests/start.kitfile + + [ $status -eq 0 ] + contacts_is_running +} + +function contacts_is_running { + ps x | grep '[/]Contacts.app/' +} + +function setup_file { + teardown +} + +function teardown { + pid=$(contacts_is_running | cut -d' ' -f1 ) + [ -n "$pid" ] && kill $pid || true +} diff --git a/tests/start.kitfile b/tests/start.kitfile new file mode 100644 index 0000000..98ca190 --- /dev/null +++ b/tests/start.kitfile @@ -0,0 +1 @@ +start Contacts