按下M将w3m
启动第一个外部浏览器,2M第二个。虽然将内置命令绑定EXTERN
到另一个键很容易,但是否可以将第二个命令绑定到另一个键?
答案1
而不是使用外部浏览器(在 ~/.w3m/configs 中)。你必须使用奇怪的热键,很难记住每个热键的作用 2M、3M、4M ...等或 2-Esc-Shift-M、3-Esc-Shift-M、4-Esc-Shift-M .. 。ETC。总共也限制为 9 个
您可以在键盘映射文件中绑定热键($EDITOR ~/.w3m/keymap)
这是一些例子:
# EXTERN_LINK = under cursor
# EXTERN = current page
# yank url to clipboard
keymap yy EXTERN_LINK 'tmux set-buffer'
keymap YY EXTERN 'tmux set-buffer'
keymap yx EXTERN_LINK 'printf %s | xsel -b'
keymap YX EXTERN 'printf %s | xsel -b'
# open url in gui browser
keymap xw EXTERN_LINK '$BROWSER'
keymap XW EXTERN '$BROWSER'
keymap xn EXTERN_LINK '$BROWSER_PRIVATE'
keymap XN EXTERN '$BROWSER_PRIVATE'
# macros for smart search
keymap sd COMMAND "TAB_GOTO https://duckduckgo.com/lite/; NEXT_LINK; GOTO_LINK; SUBMIT"
keymap sg COMMAND "TAB_GOTO https://google.com; GOTO_LINE 6; NEXT_LINK; GOTO_LINK; SUBMIT"
keymap sy COMMAND "TAB_GOTO https://yewtu.be; NEXT_LINK; GOTO_LINK"
keymap so COMMAND "TAB_GOTO https://search.yahoo.com; GOTO_LINE 19; NEXT_LINK; GOTO_LINK"
使用宏切换设置:例如 hit\n将隐藏/显示行号。更多的选择$ w3m -显示选项
keymap \\\? COMMAND "HELP; SEARCH ^User-Defined; CENTER_V" # show user custom hotkeys binding
keymap \\\f COMMAND "HELP; SEARCH ^Input Line Editing Mode; CENTER_V" # show field hotkeys binding
keymap \\\c COMMAND "SET_OPTION color=toggle ; RESHAPE"
keymap \\\u COMMAND "SET_OPTION mark_all_pages=toggle ; RESHAPE" # Treat URL-like strings as links in all pages
keymap \\\l COMMAND "SET_OPTION display_link_number=toggle ; SET_OPTION show_lnum=toggle ; RESHAPE" # toggle hinting mode / line numbers
keymap \\\h COMMAND "SET_OPTION display_link_number=toggle ; RESHAPE" # toggle hinting mode
keymap \\\n COMMAND "SET_OPTION show_lnum=toggle ; RESHAPE" # toggle line numbers
keymap \\\b COMMAND "SET_OPTION display_borders=toggle ; RESHAPE" # toggle table borders
keymap \\\i COMMAND "SET_OPTION display_image=toggle ; RELOAD" # toggle image display
keymap \\\e COMMAND "SET_OPTION user_agent='' ; RELOAD" # empty user agent
keymap \\\A COMMAND "SET_OPTION user_agent='Opera/9.80 (S60; SymbOS; Opera Mobi/SYB-1107071606; U; en) Presto/2.8.149 Version/11.10' ; RELOAD"
如果比简单的一行更复杂,您甚至可以编写脚本
# yank page title
keymap \\\y EXTERN_LINK ~/.w3m/cgi-bin/yanktitle_cursorurl.cgi # yank title (cursor url)
例如:$编辑器 ~/.w3m/cgi-bin/yanktitle_cursorurl.cgi
#!/usr/bin/env sh
# DESC: yank page title to X11 clipboard and tmux clipboard
# DEPEND: w3m wget gawk (xsel or tmux)
# get url from w3m envoriment variables (e.g !env | less)
# URL="$W3M_URL" # current page url
URL="$W3M_CURRENT_LINK" # current link on cursor
# yank page title
TITLE=$(wget -qO- "$URL" | gawk -v IGNORECASE=1 -v RS='</title' 'RT{gsub(/.*<title[^>]*>/,"");print;exit}')
printf "%s" "$TITLE" | xsel -b
printf "%s" "$TITLE" | tmux load-buffer -
答案2
不,这是不可能的。只有一个 EXTERN 命令,它根据前面的数字参数调用第一个、第二个或第三个浏览器。 W3m 没有宏功能:您无法将按键绑定到命令序列。
2M
您可以使用外部宏工具:当您在 w3m 中时发送密钥。这需要宏工具知道您何时处于 w3m 中。一种方法是始终在专用屏幕或 tmux 配置中运行 w3m(而不是其他)。