diff options
author | katherine <shmibs@airen-no-jikken.icu> | 2018-12-06 11:54:26 -0700 |
---|---|---|
committer | katherine <shmibs@airen-no-jikken.icu> | 2018-12-06 11:54:26 -0700 |
commit | d168ec3c5e04efb5f401cfcbe60c021093cd465b (patch) | |
tree | c0f85841b00f27d8d8b6b0b72df8491188326d24 /.iex.exs | |
parent | 8a1a6e410499cbc5c0685287847b290be7ccbba8 (diff) | |
download | dotfiles-d168ec3c5e04efb5f401cfcbe60c021093cd465b.tar.gz |
synchronise common prompts
the same across shell, iex, utop, but colour-coded and with a which
thing and version hint
Diffstat (limited to '.iex.exs')
-rw-r--r-- | .iex.exs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/.iex.exs b/.iex.exs new file mode 100644 index 0000000..fcd3931 --- /dev/null +++ b/.iex.exs @@ -0,0 +1,57 @@ +defmodule IExConfigInit do + + def init do + user = System.get_env "USER" + + hostname = case :inet.gethostname do + {:ok, s} -> s + _ -> "?" + end + + dir = case Elixir.File.cwd do + {:ok, s} -> s + _ -> "?" + end + + home = System.get_env "HOME" + + dir = if home do + dir = case Regex.compile("^" <> home) do + {:ok, r} -> Regex.replace r, dir, "~" + _ -> dir + end + dir + else + dir + end + + Application.put_env(:elixir, :ansi_enabled, true) + + IEx.configure( + colors: [enabled: true], + default_prompt: [ + # "\e[1A", + "\e[G", # ANSI CHA, move cursor to column 1 + :bright, + :white, + "┌[", + :magenta, + (if user, do: user <> "@", else: ""), + "elixir-", + Elixir.System.version, + "@", + hostname, + " ", + :blue, + dir, + :white, + "]\n", + "└:", + :reset + ] |> IO.ANSI.format |> IO.chardata_to_string + ) + end + +end + +IExConfigInit.init |