新規プロジェクトにmise.tomlを作りたい
新しいプロジェクトでmiseを使い始める際、コメント付きの雛形からmise.tomlを作りたい場合がある。mise generate configは、新規の設定ファイルを生成するコマンドである。
対話的に生成する
引数なしで実行すると、【mise】mise editでmise.tomlを対話的に編集する で紹介したものと同じ内蔵TUIエディタが起動する。
$ mise generate config
> [tools]
[+ Add tool from registry]
[+ Add tool from backend]
▶ [env]
▶ [tasks]
▶ [settings]
[+ Add section]
↑/↓/←/→ navigate • Enter collapse • backspace remove • s save • q quit
[+ Add tool from registry]からツールを追加しsで保存すると、その内容がファイルに書き込まれる。パスを指定しなかった場合、保存先はmise.tomlではなくmise.local.tomlである点に注意する。何も追加せずに保存すると、空のファイルが作成される。
-yで非対話生成する
-yを付けると、TUIを起動せずコメント付きのテンプレートをそのまま書き込む。
$ mise generate config -y
mise writing to mise.local.toml
# mise config files are hierarchical. mise will find all of the config files
# in all parent directories and merge them together.
# You might have a structure like:
#
# * ~/work/project/mise.toml # a config file for a specific work project
# * ~/work/mise.toml # a config file for projects related to work
# * ~/.config/mise/config.toml # the global config file
# * /etc/mise/config.toml # the system config file
#
# This setup allows you to define default versions and configuration across
# all projects but override them for specific projects.
# [env]
# NODE_ENV = "development"
# _.file = ".env" # load vars from a dotenv file
# _.path = "./node_modules/.bin" # add a directory to PATH
# [tools]
# node = "22"
# python = "3.12"
# go = "latest"
この場合も、パスを省略するとmise.local.tomlという名前で作成される。mise.tomlという名前で作りたい場合は、引数に明示的にパスを渡す。
$ mise generate config mise.toml -y
mise writing to mise.toml
–tool-versionsで.tool-versionsから移行する
asdfなどで使っていた.tool-versionsがあれば、--tool-versionsでその内容を[tools]に変換できる。
nodejs 22.1.0
python 3.12.1
$ mise generate config --tool-versions .tool-versions -y
mise writing to mise.local.toml
[tools]
node = "22.1.0"
python = "3.12.1"
.tool-versionsのnodejsのようなasdfのプラグイン名は、mise側の呼び方であるnodeに変換される。
-gでグローバル設定ファイルを生成する
-gを付けると、カレントディレクトリではなくグローバル設定ファイル(~/.config/mise/config.toml)に書き込む。
$ mise generate config -g -y
mise writing to /home/user/.config/mise/config.toml
-nでプレビューのみ確認する
-nを付けると、実際にはファイルへ書き込まずに生成内容だけを確認できる。
$ mise generate config -y -n
mise would write to mise.local.toml
(以下、生成される内容のプレビュー)
\第一線のプログラマーの行動原理を学べる!/
