2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Qiitaの記事にディレクトリ構造を記述するにはどうするか?

Last updated at Posted at 2022-03-13

はじめに

今回は、下記のようにQiitaの記事にディレクトリ構造を記述する方法をお伝えします。

ディレクトリ構造
.
├── Dockerfile
└── src
    ├── Gemfile
    ├── Gemfile.lock
    └── app.rb

結論

以下の手順を行えばOKです。

1. ターミナルでtreeコマンドを実行

$ tree

treeコマンドは、現在のディレクトリ以下の構造をテキストで表示してくれます。

私の環境では、実行結果はこのようになります。

ディレクトリ構造
.
├── Dockerfile
└── src
    ├── Gemfile
    ├── Gemfile.lock
    └── app.rb

ここで、もし「treeコマンドがないよ」と表示されたらどうしたら良いでしょうか?

treeコマンドがないよ!
zsh: command not found: tree

簡単です。

treeコマンドをインストールしましょう!

MacOSの場合
brew install tree
Debian系Linuxの場合
apt install tree
RedHat系Linuxの場合
yum install tree

インストールが終了したら、再度treeコマンドを実行してください。

2. Qiitaの記事にコピペ

1.の実行結果をコピーし、Qiitaの記事の編集画面でペーストします。
c7e0a1d99f91d212445469e04317adc5.gif

ディレクトリ構造
.
├── Dockerfile
└── src
    ├── Gemfile
    ├── Gemfile.lock
    └── app.rb

するとどうでしょう。

綺麗にディレクトリ構造が記述できました!

ポイントとしては、「```」で囲っておくことをおすすめします。

「```」で囲うと、自動的にコードブロックとしてレンダリングしてくれます。

【参照】
https://qiita.com/Qiita/items/c686397e4a0f4f11683d#code---コードの挿入

おわりに

treeコマンド、とても便利ですね!

これからも活用していきます。

それでは。

2
0
1

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?