2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

miseを試す②プロジェクトに配置したくなるmiseタスクランナー

Last updated at Posted at 2025-07-14

これは何?

前記事ではmiseを使ってツールのバージョン管理を試してみた。

今回はmiseを使ってディレクトリごとにタスクランナーを定義することで、よく実行するコマンドを効率よく実行できるようにする手順を紹介する。


ディレクトリごとにタスクランナーは本当に必要なのか

自分も最近これらの記事を読んだ。
(Makefileをタスクランナーとして使ったことがあるので興味深かった)

これを受けて、自分は以下の場合にはタスクランナーをプロジェクトに配置しても良いと考えている。

  • 何度もコマンドを実行する
  • 複数プロジェクトで汎用的に何度も実行するわけではない

実際にやってみる

単純なタスク化

自分はObsidianで作成したファイルをGitHubで管理している。
自分以外はpushしないし、ロールバックすることもないので

  • git add
  • git commt -m "本日の日付"
  • git push -u origin main

を実行するのみで問題ない。

ちなみに~/.config/mise/mise.tomlに記載するとどのディレクトリからでも使用可能なタスクランナーを定義できる。(個人的にはmiseの機能(タスクの依存関係や確認してから実行)などを使わないのであればaliasで十分だと思っている。

~/プロジェクト名/mise.toml
[tasks.git-push]
description = "Synchronize an Obsidian vault to a GitHub repo"
run = '''
git add .
git commit -m "feat: 2025-07-13"
git push -u origin main
'''
alias = "gp"

miseのいいところとしてはこちらの記事でも触れられている通り、mise runすると使用可能なタスクランナーが一覧表示され、選択するだけでコマンドが実行できることである。
そのため、Makefileと異なり、コマンド名を忘れてしまっている場合でも、使用可能なタスクを確認は不要である。

mise run                                 130
Tasks
Select a task to run
❯ git-push  Synchronize an Obsidian vault to a GitHub repo
❯ その他のツール  hogehoge
/ 
esc clear filter • enter confirm

タスクランナーを指定して実行することも可能。

mise run git-push

また、mise.tomlにaliasを定義しているなら、aliasを指定して実行することも可能

mise run gp

miseの機能を使っていい感じにする

mise.toml
[tasks.git-status]
description = "Show git status"
run = "git status"

[tasks.git-push]
description = "Synchronize an Obsidian vault to a GitHub repo"
confirm = "今日の作業は終わり!pushしてよい?"
run = '''
git add .
git commit -m "feat: $(date +'%Y-%m-%d')"
git push -u origin main
'''
alias = "gp"
depends = ["git-status"]

この変更により、以下が可能になった

  • git-push実行前にgit-statusタスクが実行される
  • git-push時にユーザに確認を取る

image.png


あとがき

  • miseのtaskを指定してAIに指示を出すのも良さそう
    • 音声入力と親和性が高そう
    • ユーザに確認が必要な場合にはmiseの機能で確認を挟める。(AIがバイパスしそうな気はするが)
  • 引数を受け取る機能があったと思うので、AIにコミット名とか決めて引数に渡して実行してもらえば、全リポジトリ共通で使えるようになりそう。
    • プロンプトでつらつら書くならコマンド化したほうが良さそう。参考
2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?