Skip to content

Commit 920d756

Browse files
authored
Merge pull request #56 from shotakaha/add-command-rtx
Add command rtx
2 parents 839fe9e + 3526dba commit 920d756

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

docs/source/command/command-rtx.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# 開発環境を切り替えたい(``rtx``
2+
3+
```console
4+
$ brew install rtx
5+
$ rtx --version
6+
2023.12.1 macos-x64 (2023-12-01) # Intelの場合
7+
2023.12.1 macos-arm64 (2023-12-01) # Apple Siliconの場合
8+
```
9+
10+
環境開発を切り替えるツールです。
11+
同様のツールに[anyenv](https://anyenv.github.io/)[asdf](https://asdf-vm.com/)などがありますが、
12+
最近は[rtx](https://github.com/jdx/rtx)を使うのがよさそうです。
13+
14+
## 有効/無効にしたい
15+
16+
```console
17+
$ eval "$(rtx activate bash)"
18+
$ eval "$(rtx activate zsh)"
19+
$ rtx activate fish | source
20+
$ execx($(rtx activate xonsh))
21+
```
22+
23+
``activate``コマンドを使って、現在のセッションで``rtx``を有効にできます。
24+
利用するシェルによって、コマンドが異なる点に注意してください。
25+
``rtx``をお試しで使ってみたい場合によいでしょう。
26+
常用する場合は、シェルの設定ファイルに追記します。
27+
28+
```console
29+
$ rtx deactivate
30+
```
31+
32+
``deactivate``コマンドで無効にできます。
33+
34+
## プラグイン名を確認したい(``plugins ls-remote``
35+
36+
```console
37+
$ rtx plugins ls-remote
38+
```
39+
40+
``plugins ls-remote``コマンドで、利用できるプラグイン名を一覧できます。
41+
42+
## プラグイン名のバージョンを一覧したい(``ls-remote``
43+
44+
```console
45+
$ rtx ls-remote プラグイン名
46+
$ rtx ls-remote python
47+
$ rtx ls-remote poetry
48+
$ rtx ls-remote pipx
49+
$ rtx ls-remote node
50+
$ rtx ls-remote go
51+
$ rtx ls-remote hugo
52+
```
53+
54+
``ls-remote プラグイン名``コマンドで、インストールできるバージョンを一覧できます。
55+
プラグインによっては、下記のようなメッセージが表示されるので``y(es)`を入力します。
56+
57+
```console
58+
$ rtx ls-remote pipx
59+
⚠️ pipx is a community-developed plugin: https://github.com/yozachar/asdf-pipx
60+
Would you like to install pipx? (y/n)
61+
```
62+
63+
## Pythonを使いたい
64+
65+
```console
66+
$ rtx install python@3.11
67+
```
68+
69+
``install``コマンドで、使いたいプラグイン(とバージョン)を指定します。
70+
バージョンを省略すると``latest``になります。
71+
72+
```console
73+
$ rtx use python@3.11
74+
$ rtx use python@3.12
75+
76+
$ rtx ls
77+
python 3.11.6
78+
python 3.12.0 ~/repos/sandbox/rtx-usage/.rtx.toml 3.12
79+
80+
$ which python
81+
~/.local/share/rtx/installs/python/3.12.0/bin/python
82+
```
83+
84+
``use``コマンドで、利用するプラグイン(とバージョン)の切り替えができます。
85+
設定ファイル``.rtx.toml``がカレントディレクトリに作成されます。
86+
プラグインが見当たらない場合は、インストール(``rtx install``)してくれます。
87+
88+
```console
89+
$ rtx use python@3.11
90+
$ rtx use poetry@1.7.1
91+
$ rtx use pipx@1.2.1
92+
93+
$ rtx ls
94+
pipx 1.2.1 ~/repos/sandbox/rtx-usage/.rtx.toml 1.2.1
95+
poetry 1.7.1 ~/repos/sandbox/rtx-usage/.rtx.toml 1.7
96+
python 3.11.6 ~/repos/sandbox/rtx-usage/.rtx.toml 3.11
97+
python 3.12.0
98+
99+
$ which python3
100+
~/.local/share/rtx/installs/python/3.11.6/bin/python3
101+
102+
$ which poetry
103+
~/.local/share/rtx/installs/poetry/1.7.1/bin/poetry
104+
105+
$ which pipx
106+
~/.local/share/rtx/installs/pipx/1.2.1/bin/pipx
107+
```
108+
109+
## Nodeを使いたい
110+
111+
```console
112+
$ myst --version # ~/.local/bin/myst
113+
MyST requires node 16, 18, or 20; you are running node 21.
114+
115+
$ rtx use node@20 # ~/.local/share/rtx/installs/node/20.10.0/bin/node
116+
117+
$ myst --version
118+
v1.1.32
119+
```
120+
121+
``rtx``によるバージョン管理の具体例を紹介します。
122+
Homebrewを使ってインストールした``node````noode@21``に更新してしまい、``mystmd``が動かなくなってしまいました。
123+
カレントディレクトリだけ``node@20``に設定し、無事``mystmd``を動かすことができました。

docs/source/command/command-usage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ command-ps
5151
command-pwd
5252
command-pwgen
5353
command-rsync
54+
command-rtx
5455
command-sd
5556
command-sed
5657
command-ssh

0 commit comments

Comments
 (0)