dirlens 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +180 -0
- package/bin/dirlens +13 -0
- package/dirlens.bat +2 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# dirlens 🌳
|
|
2
|
+
|
|
3
|
+
ファイルサイズ付きのディレクトリツリーを表示するコマンドラインツール。
|
|
4
|
+
**Python 3.8+ のみで動作**(追加ライブラリ不要)。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 出力例
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
Desktop/ (3.74 MB)
|
|
12
|
+
├── EmptyDir/ (0 bytes)
|
|
13
|
+
├── Project/ (712 KB)
|
|
14
|
+
│ ├── assets/ (512 KB)
|
|
15
|
+
│ │ └── images/ (512 KB)
|
|
16
|
+
│ │ └── logo.png (512 KB)
|
|
17
|
+
│ ├── src/ (80 KB)
|
|
18
|
+
│ │ └── util.py (80 KB)
|
|
19
|
+
│ └── main.py (120 KB)
|
|
20
|
+
├── archive.zip (3 MB)
|
|
21
|
+
└── readme.txt (50 KB)
|
|
22
|
+
|
|
23
|
+
5 ディレクトリ, 5 ファイル
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 特徴
|
|
29
|
+
|
|
30
|
+
- **クロスプラットフォーム** — macOS / Linux / Windows
|
|
31
|
+
- **カラー表示** — ディレクトリ・ファイル・シンボリックリンクを色で識別
|
|
32
|
+
- **自動サイズ変換** — bytes / KB / MB / GB / TB
|
|
33
|
+
- **ディレクトリサイズ** — サブディレクトリの合計サイズを自動計算
|
|
34
|
+
- **隠しファイル対応** — `-a` で表示切り替え
|
|
35
|
+
- **サイズ順ソート** — `-s` で大きいものから表示
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## インストール
|
|
40
|
+
|
|
41
|
+
### npm(推奨・全プラットフォーム共通)
|
|
42
|
+
|
|
43
|
+
Node.js が入っていれば、どの OS でも同じコマンドでインストールできます。
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install -g dirlens
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
インストール確認:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
dirlens --help
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
アンインストール:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm uninstall -g dirlens
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### macOS / Linux(スクリプト直接インストール)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 実行権限を付与
|
|
67
|
+
chmod +x dirlens
|
|
68
|
+
|
|
69
|
+
# /usr/local/bin にインストール(どこからでも呼べるようになる)
|
|
70
|
+
sudo cp dirlens /usr/local/bin/
|
|
71
|
+
|
|
72
|
+
# ── または sudo なしでユーザーローカルにインストール ──
|
|
73
|
+
mkdir -p ~/.local/bin
|
|
74
|
+
cp dirlens ~/.local/bin/
|
|
75
|
+
|
|
76
|
+
# ~/.zshrc(zsh)または ~/.bashrc(bash)に以下を追記:
|
|
77
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
78
|
+
# 追記後に反映:
|
|
79
|
+
source ~/.zshrc # または source ~/.bashrc
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
インストール確認:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
dirlens --help
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### Windows(スクリプト直接インストール)
|
|
91
|
+
|
|
92
|
+
1. `dirlens` を **`dirlens.py`** に改名して任意のフォルダへ置く
|
|
93
|
+
(例: `C:\Users\ユーザー名\bin\`)
|
|
94
|
+
|
|
95
|
+
2. 同じフォルダに **`dirlens.bat`** を置く(同梱のものを使用):
|
|
96
|
+
|
|
97
|
+
```batch
|
|
98
|
+
@echo off
|
|
99
|
+
python "%~dp0dirlens.py" %*
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
3. そのフォルダを **システム環境変数 PATH** に追加:
|
|
103
|
+
- スタートメニュー →「環境変数を編集」→ PATH に追記
|
|
104
|
+
- または PowerShell(管理者):
|
|
105
|
+
|
|
106
|
+
```powershell
|
|
107
|
+
[Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";C:\Users\ユーザー名\bin", "User")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
4. 新しいターミナルを開いて確認:
|
|
111
|
+
|
|
112
|
+
```cmd
|
|
113
|
+
dirlens --help
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
> **メモ**: Windows Terminal や VS Code のターミナルではカラー表示されます。
|
|
117
|
+
> 旧来のコマンドプロンプト(cmd.exe)ではカラーが出ない場合があります。
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 使い方
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# カレントディレクトリを表示
|
|
125
|
+
dirlens
|
|
126
|
+
|
|
127
|
+
# 特定のディレクトリを表示
|
|
128
|
+
dirlens ~/Desktop
|
|
129
|
+
|
|
130
|
+
# 深さ 2 階層まで表示(大きなディレクトリに便利)
|
|
131
|
+
dirlens -d 2
|
|
132
|
+
|
|
133
|
+
# 隠しファイル・ディレクトリ (.xxx) も表示
|
|
134
|
+
dirlens -a
|
|
135
|
+
|
|
136
|
+
# サイズの大きい順に並べる
|
|
137
|
+
dirlens -s
|
|
138
|
+
|
|
139
|
+
# カラーなし(パイプ・ファイル書き出し向け)
|
|
140
|
+
dirlens --no-color
|
|
141
|
+
|
|
142
|
+
# 組み合わせ例:Desktop を深さ 3・サイズ順で表示
|
|
143
|
+
dirlens ~/Desktop -d 3 -s
|
|
144
|
+
|
|
145
|
+
# テキストファイルに書き出す
|
|
146
|
+
dirlens --no-color > tree.txt
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## オプション一覧
|
|
152
|
+
|
|
153
|
+
| オプション | 省略形 | 説明 |
|
|
154
|
+
|------------------|--------|------------------------------------------|
|
|
155
|
+
| `path` | — | 対象ディレクトリ(省略時はカレント) |
|
|
156
|
+
| `--depth N` | `-d N` | 表示する最大の深さ |
|
|
157
|
+
| `--all` | `-a` | 隠しファイル・ディレクトリも表示 |
|
|
158
|
+
| `--sort-size` | `-s` | サイズが大きい順に並べる |
|
|
159
|
+
| `--no-color` | — | カラー表示を無効化(リダイレクト時に推奨) |
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## カラーの意味
|
|
164
|
+
|
|
165
|
+
| 表示色 | 意味 |
|
|
166
|
+
|---------------|------------------------|
|
|
167
|
+
| 青(太字) | ルートディレクトリ |
|
|
168
|
+
| シアン(太字) | サブディレクトリ |
|
|
169
|
+
| 緑 | ファイル |
|
|
170
|
+
| マゼンタ | シンボリックリンク |
|
|
171
|
+
| 暗色(dim) | サイズ表示 |
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 仕様・注意事項
|
|
176
|
+
|
|
177
|
+
- ディレクトリのサイズは **全サブファイルの合計**(隠しファイルを含む)
|
|
178
|
+
- **シンボリックリンク先のディレクトリ**は展開せず `→` マークで表示
|
|
179
|
+
- 権限がないディレクトリは `[アクセス拒否]` と表示してスキップ
|
|
180
|
+
- 非常に深いディレクトリ(1万階層以上)は `-d` で深さを制限してください
|
package/bin/dirlens
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
const { spawnSync } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const python = process.platform === 'win32' ? 'python' : 'python3';
|
|
7
|
+
const script = path.join(__dirname, '..', 'dirlens.py');
|
|
8
|
+
|
|
9
|
+
const result = spawnSync(python, [script, ...process.argv.slice(2)], {
|
|
10
|
+
stdio: 'inherit'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
process.exit(result.status ?? 1);
|
package/dirlens.bat
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dirlens",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Directory tree viewer with file sizes / ファイルサイズ付きディレクトリツリー表示ツール",
|
|
5
|
+
"bin": {
|
|
6
|
+
"dirlens": "./bin/dirlens"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/",
|
|
10
|
+
"dirlens",
|
|
11
|
+
"dirlens.bat",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"cli",
|
|
16
|
+
"tree",
|
|
17
|
+
"file-size",
|
|
18
|
+
"directory",
|
|
19
|
+
"terminal"
|
|
20
|
+
],
|
|
21
|
+
"author": "igarin",
|
|
22
|
+
"license": "UNLICENSED",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/igarinpiano/dirlens.git"
|
|
26
|
+
}
|
|
27
|
+
}
|