|
1 | 1 | ---
|
2 |
| -title: "bash auto-completion on Linux" |
3 |
| -description: "Some optional configuration for bash auto-completion on Linux." |
| 2 | +title: "Linux上でのbashの自動補完" |
| 3 | +description: "Linux上でのbashの自動補完に対するいくつかの補助的な設定。" |
4 | 4 | headless: true
|
5 | 5 | _build:
|
6 | 6 | list: never
|
7 | 7 | render: never
|
8 | 8 | publishResources: false
|
9 | 9 | ---
|
10 | 10 |
|
11 |
| -### Introduction |
| 11 | +### はじめに |
12 | 12 |
|
13 |
| -The kubectl completion script for Bash can be generated with the command `kubectl completion bash`. |
14 |
| -Sourcing the completion script in your shell enables kubectl autocompletion. |
| 13 | +Bashにおけるkubectlの補完スクリプトは`kubectl completion bash`コマンドで生成できます。 |
| 14 | +シェル内で補完スクリプトをsourceすることでkubectlの自動補完が有効になります。 |
15 | 15 |
|
16 |
| -However, the completion script depends on |
17 |
| -[**bash-completion**](https://github.com/scop/bash-completion), |
18 |
| -which means that you have to install this software first |
19 |
| -(you can test if you have bash-completion already installed by running `type _init_completion`). |
| 16 | +ただし、補完スクリプトは[**bash-completion**](https://github.com/scop/bash-completion)に依存しているため、事前にインストールしておく必要があります(`type _init_completion`を実行することで、bash-completionがすでにインストールされていることを確認できます)。 |
20 | 17 |
|
21 |
| -### Install bash-completion |
| 18 | +### bash-completionをインストールする |
22 | 19 |
|
23 |
| -bash-completion is provided by many package managers |
24 |
| -(see [here](https://github.com/scop/bash-completion#installation)). |
25 |
| -You can install it with `apt-get install bash-completion` or `yum install bash-completion`, etc. |
| 20 | +bash-completionは多くのパッケージマネージャーから提供されています([こちら](https://github.com/scop/bash-completion#installation)を参照してください)。 |
| 21 | +`apt-get install bash-completion`または`yum install bash-completion`などでインストールできます。 |
26 | 22 |
|
27 |
| -The above commands create `/usr/share/bash-completion/bash_completion`, |
28 |
| -which is the main script of bash-completion. Depending on your package manager, |
29 |
| -you have to manually source this file in your `~/.bashrc` file. |
| 23 | +上記のコマンドでbash-completionの主要スクリプトである`/usr/share/bash-completion/bash_completion`が作成されます。 |
| 24 | +パッケージマネージャーによっては、このファイルを`~/.bashrc`にて手動でsourceする必要があります。 |
30 | 25 |
|
31 |
| -To find out, reload your shell and run `type _init_completion`. |
32 |
| -If the command succeeds, you're already set, otherwise add the following to your `~/.bashrc` file: |
| 26 | +これを調べるには、シェルをリロードしてから`type _init_completion`を実行してください。 |
| 27 | +コマンドが成功していればすでに設定済みです。そうでなければ、`~/.bashrc`ファイルに以下を追記してください: |
33 | 28 |
|
34 | 29 | ```bash
|
35 | 30 | source /usr/share/bash-completion/bash_completion
|
36 | 31 | ```
|
37 | 32 |
|
38 |
| -Reload your shell and verify that bash-completion is correctly installed by typing `type _init_completion`. |
| 33 | +シェルをリロードし、`type _init_completion`を実行してbash-completionが正しくインストールされていることを検証してください。 |
39 | 34 |
|
40 |
| -### Enable kubectl autocompletion |
| 35 | +### kubectlの自動補完を有効にする |
41 | 36 |
|
42 | 37 | #### Bash
|
43 | 38 |
|
44 |
| -You now need to ensure that the kubectl completion script gets sourced in all |
45 |
| -your shell sessions. There are two ways in which you can do this: |
| 39 | +すべてのシェルセッションにてkubectlの補完スクリプトをsourceできるようにしなければなりません。 |
| 40 | +これを行うには2つの方法があります: |
46 | 41 |
|
47 | 42 | {{< tabs name="kubectl_bash_autocompletion" >}}
|
48 |
| -{{< tab name="User" codelang="bash" >}} |
| 43 | +{{< tab name="ユーザー" codelang="bash" >}} |
49 | 44 | echo 'source <(kubectl completion bash)' >>~/.bashrc
|
50 | 45 | {{< /tab >}}
|
51 |
| -{{< tab name="System" codelang="bash" >}} |
| 46 | +{{< tab name="システム" codelang="bash" >}} |
52 | 47 | kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
|
53 | 48 | sudo chmod a+r /etc/bash_completion.d/kubectl
|
54 | 49 | {{< /tab >}}
|
55 | 50 | {{< /tabs >}}
|
56 | 51 |
|
57 |
| -If you have an alias for kubectl, you can extend shell completion to work with that alias: |
| 52 | +kubectlにエイリアスを張っている場合は、エイリアスでも動作するようにシェルの補完を拡張することができます: |
58 | 53 |
|
59 | 54 | ```bash
|
60 | 55 | echo 'alias k=kubectl' >>~/.bashrc
|
61 | 56 | echo 'complete -o default -F __start_kubectl k' >>~/.bashrc
|
62 | 57 | ```
|
63 | 58 |
|
64 | 59 | {{< note >}}
|
65 |
| -bash-completion sources all completion scripts in `/etc/bash_completion.d`. |
| 60 | +bash-completionは`/etc/bash_completion.d`内のすべての補完スクリプトをsourceします。 |
66 | 61 | {{< /note >}}
|
67 | 62 |
|
68 |
| -Both approaches are equivalent. After reloading your shell, kubectl autocompletion should be working. |
69 |
| -To enable bash autocompletion in current session of shell, source the ~/.bashrc file: |
| 63 | +どちらも同様の手法です。 |
| 64 | +シェルをリロードしたあとに、kubectlの自動補完が機能するはずです。 |
| 65 | +シェルの現在のセッションでbashの自動補完を有効にするには、~/.bashrcをsourceします: |
70 | 66 |
|
71 | 67 | ```bash
|
72 | 68 | source ~/.bashrc
|
|
0 commit comments