Skip to content

Instantly share code, notes, and snippets.

@gh640
Last active August 14, 2022 02:13
Show Gist options
  • Save gh640/7496275 to your computer and use it in GitHub Desktop.
Save gh640/7496275 to your computer and use it in GitHub Desktop.
サクラエディタ上で Ruby スクリプトを手早く実行するためのマクロです。
S_ExecCommand('ruby -Ku "$F"', 1);
@gh640
Copy link
Author

gh640 commented Aug 14, 2022

手順

  1. スクリプトを run_ruby.mac などの名前でテキストファイルに保存
  2. 1のスクリプトをマクロとして登録
  3. (オプション)2のマクロにキーボードショートカットを指定(Ctrl + b など)

補足

  • S_ExecCommand() コマンドを実行する関数
  • -Ku rubyコマンドの文字コード指定オプション -Ku は UTF-8 を指定 他の文字コードを使っている場合は適宜変更要
  • $F 開いているファイルのファイル名
  • "$F" ファイル名/パスに半角スペースが入っても問題なく動くようにするための "" 括り
  • 1 出力結果を別のウィンドに書き込むオプション

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment