0
3

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.

Mac OSのコマンドラインでアプリを自在に開く方法とそのユースケース

Last updated at Posted at 2020-10-09

バッチファイル .command にこのコマンドを記述するとお望みの動作が簡単に実現できます。
スクレイピングツールと一緒にバッチファイルに記述してよく使っているので激しくおすすめです。
#アプリを自在に開くコマンドの指定方法
-aの隣にアプリ名を入れます。その横にはさらに起動オプションもつけることが可能です!!

open -a "Google Chrome" https:/qiita.com

#何が便利なの?
例えば、私は以下のような文脈で最近使いました。

1.大学のポータルサイトから授業ページをスクレイピングするopu-scraping.jsを起動する
2.1.のプログラムにより受講している全ての授業ページのテキストがローカルに保存される
3.それぞれの授業ページをGitHubにPushする
4.ChromeでGitHubのリポジトリの変更履歴を開く

以上の流れを下のようにバッチファイル (.command)に記述しました

opu-watchdog.command
#!/bin/bash
cd
cd dev/opu-lss-watchdog
node opu-scraping.js
git add .
git commit -m "automatically updated"
git push -u origin master
open -a "Google Chrome" https://github.com/kantasv/opu-lss-watchdog/tree/master/logs

これをMacのDockerにショートカットを置いておき、更新確認したいときにワンクリックで所望の動作が実現できるようになりました。
スクリーンショット 2020-10-10 1.22.51.png

##デモ動画
上のバッチファイルの実際のユースケースのデモです
コマンドから自由にアプリが開けることの応用性に気づいてもらえたら幸いです。
「府大の支援システムをスクレイピングし差分をGitHubで確認する」
https://www.youtube.com/watch?v=6aHnijjcSaQ&feature=youtu.be

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?