exa チートシート
exa チートシート
インストール
| プラットフォーム | コマンド |
|---|---|
| Ubuntu 20.10+ | sudo apt update && sudo apt install exa |
| Debian/Ubuntu (older) | cargo install exa |
| Arch Linux | sudo pacman -S exa |
| Fedora | sudo dnf install exa |
| RHEL/CentOS | sudo dnf install epel-release && sudo dnf install exa |
| openSUSE | sudo zypper install exa |
| macOS (Homebrew) | brew install exa |
| macOS (MacPorts) | sudo port install exa |
| Windows (Scoop) | scoop install exa |
| Universal (Cargo) | cargo install exa |
exa --version
基本コマンド
| コマンド | 説明 |
|---|---|
exa | List files in current directory (replaces ls) |
exa -l | 権限、サイズ、タイムスタンプを含む長い形式 |
exa -a | Show all files including hidden (. files) |
exa -la | 隠しファイルを含むすべてのファイルの長い形式 |
exa -lh | 人間が読みやすいサイズ形式 (KiB, MiB, GiB) |
exa -lH | 小数点サイズの長い形式 (KB, MB, GB) |
exa -1 | 1行に1ファイル(スクリプティングに便利) |
exa -R | ディレクトリの再帰的リスト |
exa -F | ファイルタイプインジケータ(/、@、\)を追加 |
exa --grid | グリッドレイアウト(デフォルトのターミナルビュー) |
exa --across | 水平フロー レイアウト |
exa -D | ディレクトリのみをリストする |
exa -f | ディレクトリを除外してファイルのみをリストする |
exa --color=always | カラー出力を強制 |
exa --color=never | カラー出力を無効にする |
高度な使用法
| コマンド | 説明 |
|---|---|
exa --tree | Display directory structure as tree (replaces tree) |
exa --tree --level=2 | ツリービューを2レベルの深さに制限 |
exa -l --git | ファイルのGitステータスを表示(追跡済み、変更済み、未追跡) |
exa --git-ignore | Respect .gitignore and show only tracked files |
exa -l --sort=modified | 更新時間で並べ替え(新しい順) |
exa -l --sort=size | ファイルサイズで並べ替え(最大から) |
exa -l --sort=extension | ファイル拡張子で並べ替え |
exa -l --reverse | 逆順に並べ替え |
exa -l --icons | ファイルタイプアイコンを表示 (Nerd Fontsが必要) |
exa -l --extended | 拡張属性(SELinux、ACL)を表示 |
exa -l@ | 拡張属性の短縮形 |
exa -li | inode 番号を表示 |
exa -ls | ブロックサイズを表示 |
exa -l --octal-permissions | 8進数形式(755)で権限を表示 |
exa -l --numeric | ユーザー/グループ名の代わりに数値のユーザー/グループIDを表示 |
exa -l --time-style=iso | ISO形式のタイムスタンプ |
exa -l --time-style=relative | 相対的な時間(例:「2時間前」) |
exa -l --modified | 変更時間を表示(デフォルト) |
exa -l --accessed | 最終アクセス時間を表示 |
exa -l --created | 作成時間を表示 |
exa --ignore-glob="*.tmp" | パターンに一致するファイルを無視する |
exa -lZ | SELinuxセキュリティコンテキストを表示 |
exa --tree --git --icons | Gitステータスとアイコン付きのツリービュー |
exa -R --level=3 | 再帰的リスト表示を3レベルに制限 |
設定
シェルエイリアス
以下を追加してください ~/.bashrc、~/.zshrc、または~/.config/fish/config.fishに:
# Basic replacements
alias ls='exa'
alias l='exa -l'
alias la='exa -la'
alias ll='exa -l'
alias lt='exa --tree'
# Advanced aliases
alias lg='exa -l --git'
alias lgi='exa -l --git --git-ignore'
alias lt2='exa --tree --level=2'
alias lta='exa -la --tree'
# Comprehensive view
alias lx='exa -lah --git --icons --group --time-style=long-iso'
# Sorting shortcuts
alias lm='exa -l --sort=modified --reverse' # Most recent first
alias lz='exa -l --sort=size --reverse' # Largest first
# Tree with Git
alias ltg='exa --tree --git --level=3'
カラーカスタマイズ
環境変数を使用してカスタムカラーを設定:
EXA_COLORS
# Add to ~/.bashrc or ~/.zshrc
export EXA_COLORS="da=38;5;245:sb=38;5;204:sn=38;5;43:uu=38;5;245:un=38;5;241"
# Color codes:
# da = date
# sb = file size
# sn = size number
# uu = user (you)
# un = user (other)
# gu = group (you)
# gn = group (other)
デフォルトオプション
デフォルトオプション用の関数ラッパーを作成:
# Add to shell configuration
exa() {
command exa --icons --group-directories-first "$@"
}
一般的なユースケース
ユースケース: Gitリポジトリの検査
# Show all files with Git status and icons
exa -la --git --icons
# Tree view of repository with Git status (ignore node_modules)
exa --tree --git --ignore-glob="node_modules|.git" --level=3
# Only show modified files
exa -l --git | grep -E "M|A|D"
ユースケース: 大きなファイルの検索
# List files by size, largest first
exa -l --sort=size --reverse
# Recursive search for large files with human-readable sizes
exa -lRh --sort=size --reverse | head -20
# Show only files (no directories) sorted by size
exa -lf --sort=size --reverse
ユースケース: ファイル権限の監査
# Show permissions in octal format with extended attributes
exa -l@ --octal-permissions
# Show all permission details with numeric IDs
exa -la --numeric --octal-permissions
# Check SELinux contexts
exa -lZ /var/www/html
ユースケース: ディレクトリ構造の分析
# Tree view with file sizes and modification times
exa -l --tree --level=3 --time-style=iso
# Show directory structure with Git awareness
exa --tree --git --icons --level=4 --ignore-glob=".git"
# List only directories in tree format
exa -D --tree --level=2
ユースケース: 高速ファイル閲覧
# Grid view with icons for visual scanning
exa --icons --grid
# Long format with all metadata
exa -lah --icons --git --time-style=relative
# Show recent changes (last 24 hours)
exa -l --sort=modified --reverse --time-style=relative | head -20
ベストプラクティス
- エイリアスの使用: シェルエイリアスを設定して
lsをexaに置き換え、ワークフロー全体で一貫した体験を提供 - Nerd Fontsのインストール: アイコンを完全にサポートするため、ターミナルにNerd Font(例:FiraCode Nerd Font、Hack Nerd Font)をインストール
- Gitとの組み合わせ: 常に
Would you like me to clarify or modify any part of the translation?--gitリポジトリ内のフラグを使用して、コマンドを実行せずにファイルの状態を一目で確認するgit status- ツリービューを活用: 使用するexa --tree別々にインストールする代わりにtreeコマンド、特に--level深さを制御するEXA_COLORS- 色を設定: カスタマイズする--time-style=relativeターミナルテーマに合わせて読みやすくする--time-style=iso- 時間スタイルオプションを使用: 選択する-1最近のファイル用または--color=never正確なタイムスタンプ用--git-ignore- スクリプトに適した出力: 使用する--sort(1行に1つ)と--reverse他のコマンドやスクリプトにパイプする際exa- gitignoreを尊重: 大規模なリポジトリでは、使用するexa -l --git --icons何千ものビルド成果物や依存関係をリストしないようにする
| 問題 | ソリューション |
|---|---|
| Icons not displaying correctly | Nerd Fontをインストールし、ターミナルでそれを使用するように設定します。nerdfonts.comからダウンロードしてください。 |
exa: command not found | Ensure installation completed successfully. Check $PATH includes /usr/local/bin or ~/.cargo/bin |
| Git status not showing | Verify you’re in a Git repository (git status). Use exa -l --git explicitly |
| Colors not working in pipes | Use exa --color=always when piping to less or other commands: `exa —color=always \ |
| Slow performance on network drives | Disable Git integration (--no-git) and avoid extended attributes (--no-extended) on slow filesystems |
| Permission denied errors | Some extended attributes require elevated privileges. Use sudo exa -l@ or skip with regular exa -l |
| Tree view truncated | Increase depth with --level=N or remove limit with no level flag (caution: may be slow on large trees) |
Alias conflicts with system ls | Use \ls to call original ls, or unalias ls temporarily. Check aliases with `alias \ |
| Icons showing as boxes/squares | Terminal doesn’t support Unicode properly. Update terminal emulator or disable icons with --no-icons |
Different output than ls | exa sorts and displays differently by default. Use --sort=name and adjust flags to match ls behavior |
| フラグ | 説明 |
| ------ | ------------- |
--modified or -m | 変更時間(デフォルト) |
--accessed or -u | 最終アクセス時間 |
--created or -U | 作成時間 |
--time-style=iso | ISO形式 |
--time-style=long-iso | 長い ISO 形式 |
--time-style=full-iso | フルISO(タイムゾーン付き) |
--time-style=relative | 相対的な時間 |
| ソート キー | 説明 |
| ---------- | ------------- |
name | 名前順(デフォルト) |
size | ファイルサイズ |
extension | ファイル拡張子 |
modified | 更新時間 |
accessed | アクセス時間 |
created | 作成時間 |
type | ファイルタイプ (dir, file, link) |
inode | Iノード番号 |
oldest | 最初に古いもの(変更日の逆順) |