|
|
better highlight
Wow thanks wallybear!
I do not use Geektool, but I like your clever awk scripts just the same. Why use perl when awk will do :) I will have to create a little script from your post. From the command-line I have a little shell script snippet I use in my scripts for text standout:
This is a bourne shell snippet of course. What does this snippet do? The test redirects STDOUT to STDIN and tests to see if it is a terminal. This will do the right thing when the command is invoked in a pipeline depending on whether this was the last command or not.
In the case of a terminal do the Over the years I have learned a few tricks here. What you really want is:
I have seen some really horrible terminal DBs, and the environment variable does not hurt if you are using a historical curses either.
Also, I used to do a test of the exit status of the Phew, now onto the other case, not a terminal. In that case I assume that you are doing a pipe, using a pager, or a hardcopy. I just do the underline for hardcopy device. The trick to getting a backspace into a file is to do this command from a shell:
Now type Ctrl+V Ctrl+H Return Ctrl+D
Then just copy and paste the odd character where ever you need it in whatever editor you happen to use for the ^H BS character. Another thing that is useful is to use bold mode. On old daisy-wheel printers this was naturally character backspace character but the simple snippet I have above will not do here because you have to duplicate each character and that depends on what it actually is. Specifically, A is A^HA while B is B^HB.
Now in
Inline in a shell script just do the appropriate quoting and "$rev" and "$sgr0". To get this to work right in all cases you need to escape every character you wish to standout because the old hardcopy trick only affects one character. That is often the simplest thing to do and does not make a difference for simple shell scripts. Of course you can be fancy and check to see if the length of rev is non-zero and do other more complicated things like grouping all of the standout character in one rev/sgr0 pair in the case of a terminal if you care to.
I typically invoke these in an
Now what if you do not want any standout characters, say you are outputting to a log file. That is simple enough, just put a col -bx at the end of your pipeline. That will strip-off the standout characters. That col command is very handy, it is a quick way to get nicely readable text files from a man command without all the embellishment in case you do not like the pretty printing in postscript output, and you do not have to care about whether it is a historical roff or GNU roff on the system you are using. Also, piping into the less command gives very good results, with whatever you wanted in standout mode appearing either as reverse video or underlined depending on your terminal configuration.
Finally I just noticed this about the posted hint that was the start of this long comment. My hunch is that the 'echo backticks' are extraneous in the original hint posted by wallybear :) |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.18 seconds |
|