
當某些網站以純文字形式顯示鏈接,或者我想用谷歌搜尋頁面中的某些單字時,我需要這個快捷方式。
右鍵單擊選單即可執行此操作;但我只想使用更有效的鍵盤。
現在我使用Cmd-C
, Cmd-T
, Cmd-V
,Enter
來做到這一點。
答案1
有一個內建服務可以在預設應用程式中開啟選定的文字 URL。它要求 URL 有一個方案,並且不會回退到 Google 搜尋或任何其他內容。
您也可以建立開啟 URL 或 Google 搜尋頁面的自訂服務:
input="$(cat)"
input="${input%\n}" # remove a possible trailing newline
if [[ "$input" =~ '://' ]]; then
open "$input"
else
open "http://www.google.com/search?q=$(echo -En "$input" |
ruby -e 'require "cgi"; print CGI.escape($<.read.chomp)')"
fi
答案2
打開Automator.app並創建一個新的“服務”。選擇“服務接收所選文字”,然後選擇“Google Chrome”作為應用程式。
然後,將「執行 AppleScript」從左側窗格拖曳到右側並貼上:
on run {input, parameters}
tell application "Google Chrome"
set myTab to make new tab at end of tabs of window 1
set URL of myTab to input
end tell
return input
end run
然後,儲存此服務,並為其命名,例如「在 Google Chrome 中開啟選定的文字」。
最後,前往系統偏好設定 » 鍵盤 » 鍵盤快速鍵並查看“服務”下的內容。在這裡,為您的新服務建立一個快捷方式,例如Cmd-Shift-O。
目前這確實不是用於搜索,因為 Chrome 不會將文字視為開啟的 URL。看@Lri的解決方案為了這。
答案3
可以做得更簡單:
選擇文字。
將文字拖曳到網址列。
按Enter。
答案4
為了讓 2014 年或以後查看此問題的人受益,Google Chrome 實現了此功能。