0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Mac: クリップボードの内容をブラウザで開くショートカットキーを作ると便利

Last updated at Posted at 2023-05-10

やりたいこと

どのアプリがアクティブであってもショートカットキー一発でChromeを開き、クリップボードの内容がURLならそのページを表示、そうでないならGoogleで検索。

設定手順

1. スクリプトを作成

下記のスクリプトを openurl として任意の場所に保存、 chmod +x しておく。

#!/bin/sh

# ブラウザでURL or キーワードを開く

if [ $# = 0 ]; then
    arg=`pbpaste`
else
    arg="$1"
fi

case "$arg" in
    *://*)
        open "${arg}"
        ;;
    *)
        open "https://www.google.co.jp/search?q=${arg}"
        ;;
esac

2. クイックアクション作成

Automatorを起動→クイックアクション→選択→シェルスクリプトを実行→下記内容を入力
(スクリプトのパスは保存した場所にすること)
スクリーンショット 2023-05-10 10.46.16.png

※ワークフローが受け取る項目を「入力なし」にしている。「テキスト」にするとサービスの種類が「一般」でなくなり、常に実行可能でなくなるため。

3. ショートカットの割当

システム環境設定→キーボード→キーボードショートカット→サービス→一般→openurlにキーを割り当て。
キーは何でもいいが、自分は左手だけで入力したいので Cmd+F1 にしている。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?