This script will use GUI Scriping to change ‘random’ color of the text in terminal.
It will choose a random colours from 1 - 48.
If this Script could be better in any way I would like to know, so share your thoughts.
To make work in terminal you need to setup ~/.bash_profile configuration file.
Reference:
Random function was borrow from StefanK
(*
Learning GUI Scripting, To make random color of terminal text.
To make this Script working, you need this in your ~/.bash_profile
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
*)
on run
tell application id "com.apple.Terminal"
activate
tell application "System Events" to tell process "Terminal"
set frontmost to true
--> {window, window, menu bar, UI element}
-- Preferences
tell menu bar 1 to tell menu 2
get the name of every menu item
click menu item "Preferences…"
end tell
-- Profiles
tell UI element 1 to tell toolbar 1
click button "Profiles"
end tell
tell window 1 to tell group 1 to tell tab group 1
--> {radio button, radio button, radio button, radio button, radio button, radio button, checkbox, checkbox, checkbox, checkbox, checkbox, radio group, checkbox, static text, static text, color well, color well, static text, static text, color well, color well, static text, static text, button, color well, color well, color well, color well, color well, color well, color well, color well, color well, color well, color well, color well, color well, color well, color well, color well, static text, static text, static text, static text, static text, color well, static text, group, static text, static text, button, static text}
-- Custom Settings
click radio button "Text"
-- if (get the value of checkbox "Antialias text") is 0 then
-- click checkbox "Antialias text"
if (get the value of checkbox "Use bold fonts") is 0 then
click checkbox "Use bold fonts"
if (get the value of checkbox "Allow blinking text") is 0 then
click checkbox "Allow blinking text"
if (get the value of checkbox "Display ANSI colours") is 0 then
click checkbox "Display ANSI colours"
if (get the value of checkbox "Use bright colours for bold text") is 0 then
click checkbox "Use bright colours for bold text"
end if
end if
end if
end if
-- end if
-- click color well 1 --> Cursor
click color well 2 --> Text
-- click color well 3 --> Bold Text
-- click color well 4 --> Selection
-- ANSI Colours from first raw, left to second row >>>> right color well {5-20}
-- click color well 21 --> Colour & Effects
end tell
-- Color
tell window "Colours"
--> {splitter group, button, button, button, toolbar, static text}
tell toolbar 1
--> {button, button, button, button, button}
click button 5 --> Pencils
end tell
--------------------------
--> {"Colours"}
tell splitter group 1
--> {static text, radio group, slider, static text, text field, splitter, color well, checkbox, scroll area}
--------------------------
tell radio group 1
set theCount to count every radio button
--------------------------
-- Random Generator
set theList to {}
repeat until (count theList) = theCount
set r to (random number from 1 to theCount)
if theList does not contain {r} then set end of theList to r
end repeat
set theRandomNumber to first item of theList as integer
-- Click the Random number of 1 - 48
click radio button theRandomNumber
end tell
--------------------------
set colorTitle to get the name of static text 1 --> Title of the color
end tell
--------------------------
-- Close Color Window
delay 1
click button 1
end tell
--------------------------
-- Close the 'Preferences'
tell UI element 1
delay 1
click button 1
end tell
end tell
end tell
activate
display dialog "Radom colours name: " & my colorTitle
end run