2013年4月30日星期二

当 GNOME Terminal 3.8 不再支持透明背景时——LilyTerm

这个功能确实很有用啊,比如一边开着网页看手册,一边敲命令,只要把终端设置成半透明+置顶,就可以避免挡住网页文字;再比如同时编辑几个源代码文件,即使屏幕不够大,窗口有的叠在了一起,也不必担心看不见某个窗口的文字。
确实也有终端模拟器支持半透明背景,但是它们的透明其实是机械地复制下面窗口的内容,而不是向 Compositor 请求真正的透明,如果拖动窗口速度比较快就会看出破绽。
找了很多替代方案,最后看好 LilyTerm 这款台湾人写的终端模拟器。
需要的很多功能都有,可配置性非常非常非常强!稍微配置一下就能完美找回 GNOME Terminal 的感觉。
所有的配置都在右键菜单,配置完成别忘记选择 右键→用户配置文件→储存设置 来储存。

下面贴上我的配置文件,位于 ~/.config/lilyterm/default.conf。99.999% 的 GNOME Terminal 习惯都能找回来(包括快捷键)!
[main]

# Auto save settings when closing window.
auto_save = 0

# The version of this profile's format. DO NOT EDIT IT!
version = 0.9.9

# The default font name of vte terminal.
font_name = Monospace 11

# The default column of vte terminal.
column = 80

# The default row of vte terminal.
row = 24

# Use true opacity in vte box.
# 0: do NOT use rgba, 1: force to use rgba.
# Left it blank will enable it automatically
# if the window manager were composited.
# Disable it will disable transparent_window, too.
use_rgba = 1

# Start up with fullscreen.
fullscreen = 0

# Transparent window. Only enabled when the window manager were composited.
transparent_window = 0

# The opacity of transparent window.
window_opacity = 0.150

# The opacity of transparent window when inactive.
# Left it blank to disable this feature.
window_opacity_inactive = 0.200

# Use transparent background.
# It will use true transparent if the window manager were composited.
transparent_background = 1

# The saturation of transparent background.
background_saturation = 0.201

# Scroll the background image along with the text.
scroll_background = 0

# Sets a background image.
background_image = 

# Confirm to execute command with -e/-x/--execute option.
confirm_to_execute_command = 1

# Don't need to confirm for executing a program if it's in the whitelist,
# separate with <space>.
execute_command_whitelist = 

# Launching executed command in a new tab instead of opening a new window.
execute_command_in_new_tab = 1

# If a program is running on foreground,
# Don't need to confirm for terminating it if it's in the whitelist,
# separate with <space>.
foreground_program_whitelist = bash dash csh ksh tcsh zsh screen

# If a program is running in background,
# Don't need to confirm for terminating it if it's in the whitelist,
# separate with <space>.
background_program_whitelist = bash dash csh ksh tcsh zsh su

# Confirm before pasting texts to vte terminal.
confirm_to_paste = 1

# If the program is running on foreground,,
# Don't need to confirm for pasting texts to it if it's in the whitelist,
# separate with <space>.
paste_texts_whitelist = editor vi vim elvis nano emacs emacs23 nano joe ne mg ssh

# Confirm to close multi tabs.
confirm_to_close_multi_tabs = 0

# Shows [Transparent Background], [Background Saturation]
# [Transparent Window] and [Window Opacity] on right click menu.
show_background_menu = 1

# Shows [Change the foreground color]
# and [Change the background color] on right click menu.
show_color_selection_menu = 1

# The normal text color used in vte terminal.
# You may use black, #000000 or #000000000000 here.
foreground_color = #000000000000

# Sets the background color for text which is under the cursor.
# You may use black, #000000 or #000000000000 here.
cursor_color = #808080808080

# The background color used in vte terminal.
# You may use black, #000000 or #000000000000 here.
background_color = #ffffffffffff

# Shows [Increase window size], [Decrease window size],
# [Reset to default font/size] and [Reset to system font/size]
# on right click menu.
show_resize_menu = 1

# The ratio when resizing font via function key <Ctrl><+> and <Ctrl><->.
# 0: the font size is +/- 1 when resizing.
font_resize_ratio = 0.000

# The ratio when resizing window via right click menu.
# 0: the font size is +/- 1 when resizing window.
window_resize_ratio = 0.000

# When user double clicks on a text, which character will be selected.
word_chars = -A-Za-z0-9_.+!@&=/~%

# The lines of scrollback history. -1 means unlimited (vte >= 0.22.3).
scrollback_lines = -1

# Shows scroll_bar or not.
# 0: Never shows the scroll_bar; 1: Always shows the scroll_bar.
# Left it blank: Hide when fullscreen, or scrollback_lines = 0.
show_scroll_bar =

# The position of scroll_bar.
# 0: scroll_bar is on left; 1: scroll_bar is on right.
scroll_bar_position = 1

# Shows input method menu on right click menu.
show_input_method_menu = 0

# Shows change page name menu on right click menu.
show_change_page_name_menu = 1

# Shows exit menu on right click menu.
show_exit_menu = 1

# Enable hyperlink in vte terminal.
enable_hyperlink = 1

# Sets whether or not the cursor will blink in vte terminal.
# 0: Follow GTK+ settings for cursor blinking.
# 1: Cursor blinks.
# 2: Cursor does not blink.
cursor_blinks = 0

# Shows copy/paste menu on right click menu.
show_copy_paste_menu = 1

# Embed the copy/paste menu to the main menu.
embedded_copy_paste_menu = 1

# Sets whether or not the terminal will beep
# when the child outputs the "bl" sequence.
audible_bell = 1

# Sets whether or not the terminal will flash
# when the child outputs the "bl" sequence.
visible_bell = 0

# Sets whether or not the window's urgent tag will be set
# when the child outputs the "bl" sequence.
urgent_bell = 1

# Which string the terminal should send to an application
# when the user presses the Delete or Backspace keys.
# 0: VTE_ERASE_AUTO
# 1: VTE_ERASE_ASCII_BACKSPACE
# 2: VTE_ERASE_ASCII_DELETE
# 3: VTE_ERASE_DELETE_SEQUENCE
# 4: VTE_ERASE_TTY
erase_binding = 2

# Sets the shape of the cursor drawn.
# 0: VTE_CURSOR_SHAPE_BLOCK
# 1: VTE_CURSOR_SHAPE_IBEAM
# 2: VTE_CURSOR_SHAPE_UNDERLINE
cursor_shape = 0

# The default locale used when initing a vte terminal.
# You may use "zh_TW", "zh_TW.Big5", or "zh_TW.UTF-8" here.
default_locale = 

# The locales list on right click menu, separate with <space>.
# You may use "ja_JP", "ja_JP.EUC-JP", or "ja_JP.UTF-8" here.
# You may want to use "UTF-8" here if you have no locale data installed.
# Left it blank will disable locale and encoding select menu items.
locales_list = 

# Sets what type of terminal attempts to emulate.
# It will also set the TERM environment.
# Unless you are interested in this feature, always use "xterm".
emulate_term = xterm

# The environment 'VTE_CJK_WIDTH' used when initing a vte terminal.
# 0: get via environment; 1: use narrow ideograph; 2: use wide ideograph.
VTE_CJK_WIDTH = 1

# The geometry of window when starting.
# A reasonable example value is "80x24+0+0",
# witch means "WIDTH x HEIGHT {+-} XOFFSET {+-} YOFFSET", and NO SPACE in it.
# Notice that it will overwrite the default column and row settings above.
geometry = 


[page]

# The max character width of page name.
page_width = 16

# Show the tabs bar or not.
# 0: Never shows the tabs ; 1: Always shows the tabs bar.
# Left it blank: Hide when fullscreen, or tabs number = 1.
show_tabs_bar =

# The position of tabs bar.
# 0: Top, 1: bottom.
tabs_bar_position = 0

# The label of tabs will fill the tab bar.
fill_tabs_bar = 0

# The page name used for a new page.
page_name = Terminal

# The page names list used for new pages, separate with <space>.
page_names = Terminal

# Reuse the page name in the page names list.
reuse_page_names = 1

# Shows a (number no) on the page name.
page_shows_number = 1

# Shows the foreground running command on the page name.
page_shows_current_cmdline = 1

# Shows the terminal's idea of what the window's title should be.
page_shows_window_title = 1

# Shows current directory on the page name.
page_shows_current_dir = 1

# Check if the running command is root privileges.
check_root_privileges = 1

# Shows current encoding on the page name.
page_shows_encoding = 1

# Bold the text of current page name.
bold_current_page_name = 1

# Bold the text of action page name.
bold_action_page_name = 1

# Shows the page name of current page on window title.
window_title_shows_current_page = 1

# Append a package name (- LilyTerm) to the window title.
window_title_append_package_name = 1

# Shows a close button [X] on current tab.
show_close_button_on_tab = 1

# Shows a close button [X] on all tabs.
show_close_button_on_all_tabs = 0

# Use colorful text on page.
use_color_page = 1

# The color used for showing Window Title on page name.
# You may use black, #000000 or #000000000000 here.
page_win_title_color = #9A6401

# The color used for showing Running Command on page name.
# You may use black, #000000 or #000000000000 here.
page_cmdline_color = #1C1CDC

# The color used for showing Current Dir on page name.
# You may use black, #000000 or #000000000000 here.
page_dir_color = #215E3E

# The color used for showing Custom Tab Name on page name.
# You may use black, #000000 or #000000000000 here.
page_custom_color = #9C0A81

# The color used for showing Root Privileges on page name.
# You may use black, #000000 or #000000000000 here.
page_root_color = #BE0020

# The color used for showing Normal Text on page name.
# You may use black, #000000 or #000000000000 here.
page_normal_color = #333333


[key]

# Disable/Enable hyperlinks, function keys and right click menu.
# Left it blank to disable this function key.
disable_key_binding = 

# Add a new tab.
# Left it blank to disable this function key.
new_tab_key = Shift+Ctrl T

# Close current tab.
# Left it blank to disable this function key.
close_tab_key = Shift+Ctrl W

# Rename the page name of current tab.
# Left it blank to disable this function key.
edit_label_key = 

# Find the strings matching the search regex.
# Left it blank to disable this function key.
find_key = Shift+Ctrl F

# Find the previous string matching the search regex.
# Left it blank to disable this function key.
find_key_prev = Shift+Ctrl G

# Find the next string matching the search regex.
# Left it blank to disable this function key.
find_key_next = Shift+Ctrl H

# Switch to prev tab.
# Left it blank to disable this function key.
prev_tab_key = Ctrl Page_Up

# Switch to next tab.
# Left it blank to disable this function key.
next_tab_key = Ctrl Page_Down

# Switch to first tab.
# Left it blank to disable this function key.
first_tab_key = 

# Switch to last tab.
# Left it blank to disable this function key.
last_tab_key = 

# Move current page forward.
# Left it blank to disable this function key.
move_tab_forward = Shift+Ctrl Page_Up

# Move current page backward.
# Left it blank to disable this function key.
move_tab_backward = Shift+Ctrl Page_Down

# Move current page to first.
# Left it blank to disable this function key.
move_tab_first = 

# Move current page to last.
# Left it blank to disable this function key.
move_tab_last = 

# Switch to #1 tab directly.
# Left it blank to disable this function key.
switch_to_tab_1 = Alt 1

# Switch to #2 tab directly.
# Left it blank to disable this function key.
switch_to_tab_2 = Alt 2

# Switch to #3 tab directly.
# Left it blank to disable this function key.
switch_to_tab_3 = Alt 3

# Switch to #4 tab directly.
# Left it blank to disable this function key.
switch_to_tab_4 = Alt 4

# Switch to #5 tab directly.
# Left it blank to disable this function key.
switch_to_tab_5 = Alt 5

# Switch to #6 tab directly.
# Left it blank to disable this function key.
switch_to_tab_6 = Alt 6

# Switch to #7 tab directly.
# Left it blank to disable this function key.
switch_to_tab_7 = Alt 7

# Switch to #8 tab directly.
# Left it blank to disable this function key.
switch_to_tab_8 = Alt 8

# Switch to #9 tab directly.
# Left it blank to disable this function key.
switch_to_tab_9 = Alt 9

# Switch to #10 tab directly.
# Left it blank to disable this function key.
switch_to_tab_10 = Alt 0

# Switch to #11 tab directly.
# Left it blank to disable this function key.
switch_to_tab_11 = 

# Switch to #12 tab directly.
# Left it blank to disable this function key.
switch_to_tab_12 = 

# Open a new window with current dir.
# Left it blank to disable this function key.
new_window = Shift+Ctrl N

# Select all the text in the Vte Terminal box.
# Left it blank to disable this function key.
select_all = 

# Copy the text to clipboard.
# Left it blank to disable this function key.
copy_clipboard = Shift+Ctrl C

# Paste the text in clipboard.
# Left it blank to disable this function key.
paste_clipboard = Shift+Ctrl V

# Paste the text in the primary clipboard.
# Left it blank to disable this function key.
paste_clipboard in primary = Shift Insert

# Increase the font size of current tab.
# Left it blank to disable this function key.
increase_font_size = Shift+Ctrl plus

# Decrease the font size of current tab.
# Left it blank to disable this function key.
decrease_font_size = Ctrl minus

# Reset the font of current tab to original size.
# Left it blank to disable this function key.
reset_font_size = Ctrl 0

# Try to maximum the window to use all available space on your display.
# Left it blank to disable this function key.
max_window = F11

# Asks to place window in the fullscreen/unfullscreen state.
# Left it blank to disable this function key.
full_screen = Alt Return

# Emulate a mouse scroll up event on Vte Terminal box.
# Left it blank to disable this function key.
scroll_up = Shift Page_Up

# Emulate a mouse scroll down event on Vte Terminal box.
# Left it blank to disable this function key.
scroll_down = Shift Page_Down

# Asks to scroll up 1 line on Vte Terminal box.
# Left it blank to disable this function key.
scroll_up_1_line = Shift Up

# Asks to scroll down 1 line on Vte Terminal box.
# Left it blank to disable this function key.
scroll_down_1_line = Shift Down


[color]

# The main ansi color theme used in vte.
# Possible values are linux, xterm, rxvt, and tango.
# or left it blank to use the default settings form libvte.
theme = tango

# Invert the ansi colors, like invert the darkred to red, darkblue to bule.
invert_color = 0

# The brightness for ansi colors used in terminal.
brightness = 0.200

# The brightness for ansi colors used in terminal when inactive.
# Left it blank to disable this feature.
inactive_brightness = 0.200

# The ANSI color code for Normal Black
# You may use black, #000000 or #000000000000 here.
Color0 = 

# The ANSI color code for Normal Red
# You may use black, #000000 or #000000000000 here.
Color1 = 

# The ANSI color code for Normal Green
# You may use black, #000000 or #000000000000 here.
Color2 = 

# The ANSI color code for Normal Yellow
# You may use black, #000000 or #000000000000 here.
Color3 = 

# The ANSI color code for Normal Blue
# You may use black, #000000 or #000000000000 here.
Color4 = 

# The ANSI color code for Normal Magenta
# You may use black, #000000 or #000000000000 here.
Color5 = 

# The ANSI color code for Normal Cyan
# You may use black, #000000 or #000000000000 here.
Color6 = 

# The ANSI color code for Normal White
# You may use black, #000000 or #000000000000 here.
Color7 = 

# The ANSI color code for Bright Black
# You may use black, #000000 or #000000000000 here.
Color8 = 

# The ANSI color code for Bright Red
# You may use black, #000000 or #000000000000 here.
Color9 = 

# The ANSI color code for Bright Green
# You may use black, #000000 or #000000000000 here.
Color10 = 

# The ANSI color code for Bright Yellow
# You may use black, #000000 or #000000000000 here.
Color11 = 

# The ANSI color code for Bright Blue
# You may use black, #000000 or #000000000000 here.
Color12 = 

# The ANSI color code for Bright Magenta
# You may use black, #000000 or #000000000000 here.
Color13 = 

# The ANSI color code for Bright Cyan
# You may use black, #000000 or #000000000000 here.
Color14 = 

# The ANSI color code for Bright White
# You may use black, #000000 or #000000000000 here.
Color15 = 


[command]

# The parameters of the APPLICATION should be separated with <tab>, if any.
#
# method = {0,1,2}
# 0: Open the hyperlink in new tab.
#    Use it if the command were using CLI, like w3m.
# 1: Open the hyperlink with gdk_spawn_on_screen_with_pipes().
#    Use it if the command were using GUI, like firefox.
# 2: Open the hyperlink in new window,
#    Use it if you not sure.
#
# VTE_CJK_WIDTH = {0,1,2}
# 0: get via environment
# 1: use narrow ideograph
# 2: use wide ideograph.
#
# The ENVIRONS will apply to the application, separated with <tab>, too.
#
# The LOCALE will apply to the application as locale environs.
# You may use "zh_TW", "zh_TW.Big5", or "zh_TW.UTF-8" here.
# Left it blank to use the locale environs from current page.

# The web browser using for http(s)://
web_browser = xdg-open
web_method = 1
web_VTE_CJK_WIDTH = 0
web_environ = 
web_locale = 

# The ftp client using for ftp(s)://
ftp_client = xdg-open
ftp_method = 1
ftp_VTE_CJK_WIDTH = 0
ftp_environ = 
ftp_locale = 

# The file manager using for file:// and [Open current directory with file manager]
file_manager = xdg-open
file_method = 1
file_VTE_CJK_WIDTH = 0
file_environ = 
file_locale = 

# The email client using for user@host
email_client = xdg-open
email_method = 1
email_VTE_CJK_WIDTH = 0
email_environ = 
email_locale = 


P.S. 发现一个很贴心的功能,如果复制了几百行文字不小心选了粘贴,会提醒你是否真的要贴。从这可见 LilyTerm 的开发人员的细心,和 GNOME 开发团队形成鲜明对比啊!(当然我不否认 GNOME 3.8 也带来了很多贴心的小功能。)

2013年4月13日星期六

解决 wget 中文文件名乱码

wget 从服务器下载文件经常遇到中文文件名变成乱码的问题。
Google 了一下,网上有人写了一个 patch 来解决这个问题。
其实不必要像那样修改源代码,wgetman 页面里就有解决方法。
正解是参数 --restrict-file-names=nocontrol

Update: +筱百合 提供了他的 ~/.wgetrc 文件,方便大家借鉴:
# 不要乱转义中文
--restrict-file-names=nocontrol
# 使用重定向后的文件名
--trust-server-names=on
--content-disposition=on