diff options
author | tdro <tdro@users.noreply.github.com> | 2023-06-06 21:02:51 -0400 |
---|---|---|
committer | tdro <tdro@users.noreply.github.com> | 2023-06-06 21:02:51 -0400 |
commit | 3fae4c9b1631fed9ce8ac8c73c78d47477dfc6ed (patch) | |
tree | 5af4685f92867373bb2385f5d58960c34689723e | |
parent | 61a85654daab28edb7ab3b527854487c7b9ac775 (diff) | |
download | dotfiles-3fae4c9b1631fed9ce8ac8c73c78d47477dfc6ed.tar.gz dotfiles-3fae4c9b1631fed9ce8ac8c73c78d47477dfc6ed.tar.bz2 dotfiles-3fae4c9b1631fed9ce8ac8c73c78d47477dfc6ed.zip |
.local/bin/plumber: Add reverse
Handle 2 item list in jumble
Let vim know how to auto format
-rwxr-xr-x | .local/bin/plumber | 36 | ||||
-rwxr-xr-x | .local/bin/plumber-dmenu | 2 | ||||
-rw-r--r-- | .vim/vimrc | 1 |
3 files changed, 30 insertions, 9 deletions
diff --git a/.local/bin/plumber b/.local/bin/plumber index 0bc53b3..e2c186d 100755 --- a/.local/bin/plumber +++ b/.local/bin/plumber @@ -25,6 +25,8 @@ defmodule ArgParser do letterize: "text->letterize", lorem_paragraph: "lorem->paragraph", lorem_title: "lorem->title", + reverse_letters: "reverse->letters", + reverse_words: "reverse->words", singleline: "text->singleline", slugize: "text->slugize", ] @@ -58,13 +60,23 @@ defmodule ArgParser do TextPlumber.singleLineOf(opts[:text]) |> IO.binwrite() opts[:option] == options[:jumbleize] -> - String.split(opts[:text]) + String.split(opts[:text] |> String.replace(~r/[[:punct:]]+/, "")) |> Enum.map(&String.codepoints/1) |> Enum.map(&TextPlumber.jumble/1) |> Enum.map(&Enum.join/1) |> Enum.join(" ") |> IO.binwrite() + opts[:option] == options[:reverse_words] -> + TextPlumber.reverse(opts[:text]) |> IO.binwrite() + + opts[:option] == options[:reverse_letters] -> + String.split(opts[:text]) + |> Enum.map(&String.codepoints/1) + |> Enum.map(&Enum.reverse/1) + |> Enum.join(" ") + |> IO.binwrite() + opts[:option] == options[:dictionary] -> TextPlumber.dictionOfFirstWordIn(opts[:text]) TextPlumber.firstWordOf(opts[:text]) |> IO.binwrite() @@ -121,6 +133,10 @@ defmodule TextPlumber do String.split(text) |> List.first() end + def reverse(text) do + String.split(text) |> Enum.reverse |> Enum.join(" ") + end + def titleCaseOf(text) do text |> String.split() |> Enum.map(fn word -> :string.titlecase(word) end) |> Enum.join(" ") end @@ -156,15 +172,17 @@ defmodule TextPlumber do def jumble(list) do if length(list) == 1 do - list + list else - head = Enum.take(list, 1) - tail = Enum.take(list, -1) - head ++ (list - |> Enum.drop(-1) - |> Enum.drop(1) - |> Enum.shuffle) - ++ tail + head = Enum.take(list, 1) + tail = Enum.take(list, -1) + list = list |> Enum.drop(-1) |> Enum.drop(1) + + if length(list) == 2 do + head ++ (list |> Enum.reverse()) ++ tail + else + head ++ (list |> Enum.shuffle()) ++ tail + end end end diff --git a/.local/bin/plumber-dmenu b/.local/bin/plumber-dmenu index fba449d..bb50a03 100755 --- a/.local/bin/plumber-dmenu +++ b/.local/bin/plumber-dmenu @@ -6,6 +6,8 @@ case->titleize case->upper lorem->paragraph lorem->title +reverse->letters +reverse->words text->camelize text->date8601 text->jumbleize @@ -349,6 +349,7 @@ augroup AutoCommands autocmd FileType sh set formatprg=shfmt\ - autocmd FileType typescriptreact set formatprg=deno\ fmt\ - autocmd FileType typescript set formatprg=deno\ fmt\ - + autocmd FileType elixir set formatprg=mix\ format\ - autocmd FileType python set formatprg=black\ --quiet\ - autocmd FileType scheme set formatprg=emacs-batch-indent\ scheme autocmd FileType css set formatprg=prettier\ --parser\ css\ --stdin-filepath\ % |