Skip to content

Instantly share code, notes, and snippets.

@nivertech
Forked from rob-brown/ExecuteSigil.ex
Created October 30, 2013 19:59
Show Gist options
  • Select an option

  • Save nivertech/7239191 to your computer and use it in GitHub Desktop.

Select an option

Save nivertech/7239191 to your computer and use it in GitHub Desktop.
defmodule CommandSigil do
# I chose 't' for 'terminal'. I wanted 'c' for 'command', but it's taken.
def sigil_t(cmd, _opts) do
{ :ok, list } = String.to_char_list(cmd)
:os.cmd(list)
end
end
defmodule CommandSigil.Test do
import CommandSigil
def test_sigil do
%t"ls -l"
end
def test_sigil_with_var do
dir = "~/"
%t"ls -al #{dir}/*"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment