5

Recently I've made something in my .bashrc so that I can inquiry unknown words online easily with my bash without open a browser.

I chose w3m as my agent utility, the problem is, its default color theme seems unreadable under our black colour background terminal. I can use its -M option to make it more readable.

But I'm still wondering, is there a way to change its colour set, may be in some config file I can change some parameters to do that?

PS: I'm using iterm2 on OSX.

My alias for this word inquiry is:

function dee {w3m"http://www.oxfordlearnersdictionaries.com/definition/american_english/$1"; } 
export -f dee

So, you can use dee stack to search the definition of stack after you put the above stuff in your bashrc.

Zen
  • 7,287
  • 18
  • 50
  • 72
  • Cool! Could you show us your "w3m-based-inquiry-unknown-words" script? – JJoao Dec 31 '14 at 14:10
  • It's quite easy, you know that many web dict use a fix path + words name to search a particular word. So for example you can add the stuff below in your bashrc so you can use `dee + word` to search for particular word definition – Zen Jan 04 '15 at 09:15
  • @JJoao, I've added the config in my question – Zen Jan 04 '15 at 09:21

2 Answers2

3

From w3m FAQ:

w3m starts with black characters on black background. How do I change this?

When compiled with colour support, w3m assumes a white background and therefore displays black characters.
You may either change the background colour of your terminal (e.g. with the -bg option in a xterm) or take these steps:

    invoke w3m with 'w3m -M' (for monochrome),
    type 'o' for getting to the options screen
    Mark 'Display with colour' as ON and choose an arbitrary colour. Click on [OK].

And

How do I change the colour of anchor-/image-/form links?

Type 'o' within w3m to get the 'options' screen. You can change these settings there.
fredtantini
  • 4,153
  • 1
  • 14
  • 21
  • So this display with colour option only accepts one colour? – Zen Dec 31 '14 at 10:46
  • And when typing `w3m -o`, I saw a list of print out options, find nowhere to click to change. – Zen Dec 31 '14 at 10:47
  • 1
    Ah, I got it, I need to do `w3m -M 'http://something.com'` – Zen Dec 31 '14 at 10:57
  • The thing is that I've visited that site by web before I ask this question. But I used `color` as searching keyword, so I missed your part! – Zen Dec 31 '14 at 11:11
0

This is not an answer to your question but an alternative way of doing "dee"

$ cat ~/bin/endict
#!/usr/bin/perl -0

my $q = shift  or die("Usage $0 word\n");
my $d = 'http://www.oxfordlearnersdictionaries.com/definition/american_english';

$_ = `w3m -dump "$d/$q"`;                         # get the definition
s/.*?\n(Definition of .*?)\s*• © 201.*/$1\n/s;    # remove head/foot
print                                             # ... clean it more... print

Usage example:

$ endict cello
Definition of cello noun from the Oxford Advanced American Dictionary

[instrument]
[bt-enlarge]

cello

noun
/ˈtʃɛloʊ/
 
plural cellos (also formal violoncello)
 
a musical instrument with strings, shaped like a large violin. The player sits
down and holds the cello between his or her knees.
Search Results

  • cello noun
  • cellist noun

[English (UK)]
JJoao
  • 11,887
  • 1
  • 22
  • 44