I am trying to shuffle the content of my clipboard. I would copy the name of one country to my system clipboard, fire my Keyboard Maestro macro, and then paste the shuffled content to the frontmost window.
As, with Keyboard Maestro, one can only shuffle lines and not words, I tried some shell script. With no luck
I'm good with text manipulation, but I'm not sure what you are trying to do. It sounds like you are trying to randomly permute all the characters in the clipboard (based on the code you submitted.) Is that right? But then you mention "countries" and I'm not sure how that's relevant to the task of shuffling text.
I see you are using the "shuf" command. That's not part of macOS. You are also using two variables, "Shuffle" and "word", but it's not clear to me what those variables are meant to contain.
Can you explain what you mean by that? Based on that statement, you are trying to shuffle words, not "all the characters of the clipboard."
I can't write a macro to help if I don't know what you want.
Here's a macro that will take an input containing words separate by spaces or newlines and randomly re-organize all the words onto separate lines. I'm not sure if that's what you want, but that's my best guess as to what you want.
@Airy thank you very much for your help. I should have added a exemple of what I wanted to get.
I am just trying to create a faster way to create anagrams (of words, country names, ...). So, I need to shuffle the letters (not characters) of a word.
I would like to copy, for example, the word "australia" to my system clipboard. Then the Keyboard Maestro macro would shuffle this word and copy the value of the shuffled australia, for exemple "usaratail", to my system clipboard.
Keyboard Maestro has a Shuffle Lines Filter action. So all you have to do is break the characters in to lines, and then shuffle them and then put it back together.
Keyboard Maestro also has an action which lets you extract a string from a string, and if you do this right, you can "shuffle" a string quite easily. Here's my solution. It will let you specify a word, and it will generate three random shuffles, each one splitting the word seven times (I find that 7 seems to be pretty effective) and then displays the output.
Expanding on @peternlewis's answer (oh, the temerity!) you can "For Each" the clipboard contents and shuffle each word independently, appending each result to an "output" variable:
I am lost for words. I came looking for one solution. Now, thanks to @ComplexPoint and @peternlewis, @Nige_S and @Airy I have many solutions that do fit my needs. Thank you so much!