最近我在 .bashrc 中做了一些东西,这样我就可以使用 bash 轻松地在线查询未知单词,而无需打开浏览器。
我选择w3m
作为我的代理实用程序,问题是,它的默认颜色主题在我们的黑色背景终端下似乎无法读取。我可以使用它的-M
选项来使其更具可读性。
但我仍然想知道,有没有办法改变它的颜色设置,可能在某些配置文件中我可以改变一些参数来做到这一点?
PS:我在 OSX 上使用 iterm2。
我对这个词查询的别名是:
function dee {w3m"http://www.oxfordlearnersdictionaries.com/definition/american_english/$1"; }
export -f dee
因此, dee stack
将上述内容放入 bashrc 后,您可以使用搜索堆栈的定义。
答案1
w3m 以黑色背景上的黑色字符开头。我该如何改变这个?
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].
和
如何更改锚点/图像/表单链接的颜色?
Type 'o' within w3m to get the 'options' screen. You can change these settings there.
答案2
这不是你问题的答案,而是“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
使用示例:
$ 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)]