diff --git a/lib/tasks/docker.rake b/lib/tasks/docker.rake new file mode 100644 index 0000000..82f48fa --- /dev/null +++ b/lib/tasks/docker.rake @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'macos' + +task :docker => :'brew:formulae_and_casks' do + docker_dir = File.expand_path('~/.docker') + + if macos? + fish_function = Pathname('~/.config/fish/functions/docker.fish').expand_path + fish_function.dirname.mkpath + fish_function.write <<~FISH + # This file was created automatically, do not edit it directly. + + function docker --wraps docker + if contains -- -h $argv || contains -- --help $argv || test (count $argv) = 0; else + if ! pgrep Docker >&- + open -jga Docker + end + + while true + set -l ping_status (curl --fail --unix-socket ~/.docker/run/docker.sock 'http://localhost/_ping' 2>&-) + + if test "$ping_status" = OK + break + else + sleep 1 + end + end + end + + command docker $argv + end + FISH + end +end diff --git a/~/.config/fish/functions/docker.fish b/~/.config/fish/functions/docker.fish deleted file mode 100644 index 29bcaeb..0000000 --- a/~/.config/fish/functions/docker.fish +++ /dev/null @@ -1,19 +0,0 @@ -function docker --wraps docker - if contains -- -h $argv || contains -- --help $argv || test (count $argv) = 0; else - if ! pgrep Docker >&- - open -jga Docker - end - - while true - set -l ping_status (curl --fail --unix-socket ~/.docker/run/docker.sock 'http://localhost/_ping' 2>&-) - - if test "$ping_status" = OK - break - else - sleep 1 - end - end - end - - command docker $argv -end