Depending on what exactly you want to accomplish, here's a few ideas in AppleScript using your Terminal styles. These are more robust than tput
, because this gets reset by colored prompts. etc (at least for me).
This sets all tabs running Python (no SSH server available for testing right now) to Homebrew, the others to Ocean:
tell application "Terminal"
repeat with w from 1 to count windows
repeat with t from 1 to count tabs of window w
if processes of tab t of window w contains "Python" then
set current settings of tab t of window w to (first settings set whose name is "Homebrew")
else
set current settings of tab t of window w to (first settings set whose name is "Ocean")
end if
end repeat
end repeat
end tell
save as script and run as osascript Name.scpt
anytime you want to re-color your shells (of course you can wrap this as a shell script or something).
If you want to display all long-running processes differently, use the following condition:
if busy of tab t of window w is true then
Or, you can set the style of a single tab, manually selected:
on run argv
tell application "Terminal" to set current settings of tab (item 1 of argv as number) of front window to first settings set whose name is (item 2 of argv)
end run
Run it like this:
osascript StyleTerm.scpt 3 Homebrew
-> Third tab of frontmost Terminal window gets Homebrew style!
If you want to modify background windows, replace "front window" with a parenthesized expression like just after "tab".
If you always want to modify the selected "current tab", use selected tab
instead of tab (item 1 of argv as number)
.
Add the following to your .bash_profile
if the first solution is too manual labour for you:
PROMPT_COMMAND='osascript "/path/to/Name.scpt"'
Now it gets executed before every prompt (only problem: not after starting something, i.e. ssh
. But this topic isn't about fancy bash tricks anyway. This is just a pointer.)
You can change your shell colors in Terminal's preferences.
With these settings, you get these colors (not usually using colored ls
, so I don't care):
I don't understand what the issue is here. Colored command output is active by default. The only thing you can/need to do yourself is give normal and bold text different default colors, and actually use the colored variants (e.g. ls -G
) of your commands.
For vim: :syntax on
in vim
. Or append syntax on
to .vimrc
.
Best Answer
As Ignacio already said, OS X grep is a bit outdated (it's version 2.5.1). You can install the latest GNU grep though.
As always, you can install most missing Linux tools on OS X through Homebrew:
This will install
ggrep
so as not to override your existinggrep
. If you want to change that, see the info message:Further, you can enable a color option and exclude some directories by default, which may make it more useful:
Add this to your
~/.bash_profile
or whatever shell configuration you are using.