【Mac】マウスクリックだけでターミナルを開いて好きなコマンドを実行するショートカット

あらかじめ登録しておいたよく使うコマンド群を選択クリックして実行します。

キーボードなしで使えます。

 

💻 AppleScript


Mac 上のターミナルアプリ「iTerm」を起動して、

  ↓

キーボードから文字を入力して実行する。

という操作をスクリプトで実装しています。


on run argv
  set cmd to (item 1 of argv)
  tell application "iTerm"
    create window with default profile
    delay 2
    tell current session of current window
      write text cmd
    end tell
  end tell
end run

どのアプリでも起動したあと、どんな文字でも入力できるので、使い回しができるスクリプトだと思います。

 

💻 ショートカット

上のスクリプトをショートカット内に入れます。

よく使う「引数などのついた」コマンドたちはリスト化して選択できるようにしておきます。

【Mac】マウスクリックだけでターミナルを開いて好きなコマンドを実行するショートカット

Apple ショートカットは簡単なダイアログや選択リストがあらかじめ用意されているので便利ですね。

 

💻 まとめ

しかし、AppleScript ってドキュメントが少ないです。

tell - end tell は入れ子で書いた方が分かりやすいです。



【ChatGPT】Git comit message (コミットメッセージ) をサクッと簡単に作る macOS ショートカットと OPENAI プロンプト 🤖

Git のコミットメッセージに


- 英語で書くか日本語で書くか
- 絵文字を入れるか入れないか
- prefix を付けるか付けないか

という面倒な話はすべて解決します。

以下の動画のようなショートカットツールです。



 

🤖 プロンプト

ここがポイントです。


Create 10 git commit messages in English for the following changes in the following format. The emoji should be one of the github-shortcode characters that matches your changes.

Format: "emoji :github-shortcode: prefix:commit-message" 
Change Description: "アプリ起動時間のの短縮"

これをベースに会社や上司やプロジェクトの環境によって書き換えればいけます。


- 10
- English
- emoji
- shortcode
- prefix

ここらが変更対象の単語となるでしょう。

 

🤖 ChatGPT API

ChatGPT API を使うには課金登録して OPENAI_API_KEY が必要です。

macOS/iOS ショートカットアプリは、コンポーネントに


- WEB クライアント
- JSON パーサー

の機能を含む「Get Content of URL」という部品があらかじめ用意されています。

しかも、


- リクエストメソッド
- リクエストヘッダー
- リクエストボディ

を GUI からノーコードで設定できるので便利です。

 

🤖 ダウンロード

ショートカットは無料で公開できて、だれでもダウンロードして利用することがきます。


👉 Git Commit Message 😄 hatena-bookmark

[編集] から OPENAI_API_KEY を貼り付けると利用可能になります。

 

🤖 まとめ

ChatGPT API を使うには課金登録が必要ですが、この程度の利用ではいくらコミットしてもジュース1本分の金額には届きません。

実際に使いながら WEB API クライアントのプログラミング実装の基本を学ぶにも最適な教材になると思います。

今回は、厳格なプログラム作成に集中したあとに、ふんわりとしたコミットメッセージ作成はなんとなくつらく思えるので作ってみました。

この記事は、以下のプロジェクトのプロンプトにインスパイアされています。


    Refer to the provided git diff or code snippet and provide a suitable commit message.

    When reviewing the diff or code, focus on identifying the main purpose of the changes.
    Are they fixing a bug, adding a new feature, improving performance or readability, or something else?
    Use this information to craft a concise and detailed gitmoji commit message that clearly describes what the provided code or diff does.

    Describe the change to the best of your capabilities in one short sentence. Don't go into too much detail.

    When reviewing a diff, pay attention to the changed filenames and extract the context of the changes.
    This will help you create a more relevant and informative commit message.
    Here are some examples of how you can interpret some changed filenames:
      - Files or filepaths that reference testing are usually related to tests.
      - Markdown files are usually related to documentation.
      - Config file adjustments are usually related to configuration changes.

    Here is a list of gitmoji codes and their descriptions of what they mean when they are used: """
    ${gitmojis}
    """

    Try to match the generated message to a fitting emoji using its description from the provided list above.
    So go look in the descriptions and find the one that best matches the description.

    Always start your commit message with a gitmoji followed by the message starting with a capital letter.
    Never mention filenames or function names in the message.

    Don't do this:
      - :bug: Fix issue in calculateTotalPrice function
      - :zap: Improve performance of calculateTopProducts function
      - :lipstick: Refactor styling for calculateCartTotal function
      - :memo: Update documentation for getProductById function

    Do this:
      - :bug: Fix issue with shopping cart checkout process
      - :zap: Improve performance of search functionality
      - :lipstick: Refactor styling for product details page
      - :memo: Update documentation for API endpoints

    ${
      context
        ? `
          Refer to the provided additional context to assist you with choosing a correct gitmoji
          and constructing a good message: """
          ${context}
          """
        `
        : ''
    }

    Here is the provided git diff or code snippet: """
    ${prepareDiff(diff, minify)}
    """

👉 Generate your gitmoji commit message 👋 hatena-bookmark



【Android】公式エミュレーターがしれっと軽かったので Goole Play Store を入れて使う方法📱

「エミュレーターは遅い」てのは昔の話ですか。

入れて見たら十分使える感じ。

Pixel6 の SDK 33 を入れました。

 

📱 Google Play Store を入れる

エミュレーターに同梱されている設定ファイルを書き換えます。

[Show on Disk] からエミュレーターのファイル群を開きます。

[config.ini] を開きます。

2カ所編集してを保存します。


PlayStore.enabled = false

  ↓

PlayStore.enabled = true


image.sysdir.1 = system-images/android-33/google_apis/x86_64/

  ↓

image.sysdir.1 = system-images/android-33/google_apis_playstore/x86_64/

エミュレーターを再起動すると、Google Play Store がインストールされています。

 

📱 まとめ

いつのまにかエミュレーターも進化してたのですね!

Google Play Store を入れれば、さらに便利に使えます。