3
0

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 3 years have passed since last update.

ショートカットキーでターミナルを立ち上げる!

Last updated at Posted at 2022-02-28

やりたいこと

ショートカットキーで、一発でターミナルの新規ウィンドウを立ち上げたい!

やってみる

アクションを追加

Automatorを起動すると以下の画面が出てきます。
そして以下のようにクイックアクションを選択します。
automator1.png
次にアクションを追加します。
ライブラリ→ユーティリティ→AppleScriptを実行 と順に選んでいきます。
automator2.png
そして、スクリプトのところに以下のコードを追加します。

StartUpTerminal
if application "Terminal" is running then
	tell application "Terminal"
		do script ""
		activate
	end tell
else
	tell application "Terminal"
		activate
	end tell
end if

コピペできたら、好きな名前をつけて保存します。

ショートカットの追加

システム環境設定を起動し、キーボード→ショートカット→サービス を開けると、先ほど名前をつけて保存したアクションがあります。おそらく、下の方の一般の中にあります。
automator3.png
まずは左のチェックをつけて有効にしてください。
右端にショートカットキーを登録できるので、好きなショートカットを登録します。私は"control+option+T"にしました。
同じショートカットがあって競合してしまうと、立ち上がらないかもしれないので、できるだけ被らない、そして押しやすいショートカットがいいと思います。

あとは自分の決めたショートカットを叩くことでターミナルの新規ウィンドウが立ち上がるはずです。

もっとかっこいい感じにする

automator4.png
"neofetch"コマンドをまず叩いてあげることで、すごくカッコ良くなります。かっこいいのに憧れる人は、シンプルにモチベーションを上げることができるんじゃないでしょうか。

StartUpTerminal2
if application "Terminal" is running then
	tell application "Terminal"
		do script "neofetch"
		activate
	end tell
else
	tell application "Terminal"
		reopen
		activate
		do script "neofetch" in window 1
	end tell
end if

まだコマンドをインストールしてない人はbrew install neofetchでインストールしといてください!
スクリプトを更新するなら上書き保存、新規作成するなら、先ほどと同様の手順でショートカットを追加してください。

ぜひ試してみてください!!

参考にさせていただいたURI

ありがとうございます。
https://tanisukestr.hatenablog.com/entry/2018/05/07/230857
https://ringsbell.blog.fc2.com/blog-entry-1217.html
https://superuser.com/questions/195633/applescript-to-open-a-new-terminal-window-in-current-space
https://apple.stackexchange.com/questions/224925/script-opens-two-terminal-windows

3
0
1

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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?