【LSDeluxe】lsコマンドの結果にアイコンや色をつける
はじめに
ls
コマンドの出力を豪華にするlsd
コマンドについて紹介します。
ls
コマンドと同じような使い方で下記のような結果になります。
LSDeluxe
lsd
(LSDeluxe)コマンドは、ls
コマンドと同じような使い方で色をつけたり、アイコンを表示したり、ディレクトリ構造を表示したりできるツールです。
GitHub - lsd-rs/lsd: The next gen ls command
The next gen ls command. Contribute to lsd-rs/lsd development by creating an account on GitHub.
インストール
Macであれば下記でインストールできます。
1brew install lsd
フォントの設定
lsd
を使うにはNerd Fontが必要になるので、インストールします。
GitHub - ryanoasis/nerd-fonts: Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts: Hack, Source Code Pro, more. Glyph collections: Font Awesome, Material Design Icons, Octicons, & more
Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts: Hack, Source Code Pro, more. Glyph collections: Font Awesome, Material Design Icons, Octicons, & more - ryano...
1git clone https://github.com/powerline/fonts.git --depth=1
2cd fonts
3./install.sh
4cd ..
5rm -rf fonts
インストールしたフォントの中から好きなものを選び、ターミナルのフォントに設定します。
iTerm2の場合は下記のようになります。
lsdの設定
~/.config/lsd/config.yaml
に設定ファイルを配置することでlsd
の設定ができます。
下記は設定ファイルの中身になります。基本的にデフォルトの内容ですが、total-size
だけtrue
にしてます。
追記: 常にtrueにしていると重くなったので、falseに変えました。
また、2022/4/17時点では、permission
とhyperlink
はまだリリースされていないようなので、コメントアウトしておきました。
1# == Classic ==
2# This is a shorthand to override some of the options to be backwards compatible
3# with `ls`. It affects the "color"->"when", "sorting"->"dir-grouping", "date"
4# and "icons"->"when" options.
5# Possible values: false, true
6classic: false
7
8# == Blocks ==
9# This specifies the columns and their order when using the long and the tree
10# layout.
11# Possible values: permission, user, group, size, size_value, date, name, inode
12blocks:
13 - permission
14 - user
15 - group
16 - size
17 - date
18 - name
19
20# == Color ==
21# This has various color options. (Will be expanded in the future.)
22color:
23 # When to colorize the output.
24 # When "classic" is set, this is set to "never".
25 # Possible values: never, auto, always
26 when: auto
27 # How to colorize the output.
28 # When "classic" is set, this is set to "no-color".
29 # Possible values: default, <theme-file-name>
30 # when specifying <theme-file-name>, lsd will look up theme file
31 # XDG Base Directory if relative, e.g. ~/.config/lsd/themes/<theme-file-name>.yaml,
32 # The file path if absolute
33 theme: default
34
35# == Date ==
36# This specifies the date format for the date column. The freeform format
37# accepts an strftime like string.
38# When "classic" is set, this is set to "date".
39# Possible values: date, relative, '+<date_format>'
40# `date_format` will be a `strftime` formatted value. e.g. `date: '+%d %b %y %X'` will give you a date like this: 17 Jun 21 20:14:55
41date: date
42
43# == Dereference ==
44# Whether to dereference symbolic links.
45# Possible values: false, true
46dereference: false
47
48# == Display ==
49# What items to display. Do not specify this for the default behavior.
50# Possible values: all, almost-all, directory-only
51# display: all
52
53# == Icons ==
54icons:
55 # When to use icons.
56 # When "classic" is set, this is set to "never".
57 # Possible values: always, auto, never
58 when: auto
59 # Which icon theme to use.
60 # Possible values: fancy, unicode
61 theme: fancy
62 # Separator between icon and the name
63 # Default to 1 space
64 separator: " "
65
66# == Ignore Globs ==
67# A list of globs to ignore when listing.
68# ignore-globs:
69# - .git
70
71# == Indicators ==
72# Whether to add indicator characters to certain listed files.
73# Possible values: false, true
74indicators: false
75
76# == Layout ==
77# Which layout to use. "oneline" might be a bit confusing here and should be
78# called "one-per-line". It might be changed in the future.
79# Possible values: grid, tree, oneline
80layout: grid
81
82# == Recursion ==
83recursion:
84 # Whether to enable recursion.
85 # Possible values: false, true
86 enabled: false
87 # How deep the recursion should go. This has to be a positive integer. Leave
88 # it unspecified for (virtually) infinite.
89 # depth: 3
90
91# == Size ==
92# Specifies the format of the size column.
93# Possible values: default, short, bytes
94size: default
95
96# == Permission ==
97# Specify the format of the permission column.
98# Possible value: rwx, octal
99#permission: rwx
100
101# == Sorting ==
102sorting:
103 # Specify what to sort by.
104 # Possible values: extension, name, time, size, version
105 column: name
106 # Whether to reverse the sorting.
107 # Possible values: false, true
108 reverse: false
109 # Whether to group directories together and where.
110 # When "classic" is set, this is set to "none".
111 # Possible values: first, last, none
112 dir-grouping: none
113
114# == No Symlink ==
115# Whether to omit showing symlink targets
116# Possible values: false, true
117no-symlink: false
118
119# == Total size ==
120# Whether to display the total size of directories.
121# Possible values: false, true
122total-size: true
123
124# == Hyperlink ==
125# Whether to display the total size of directories.
126# Possible values: always, auto, never
127#hyperlink: never
128
129# == Symlink arrow ==
130# Specifies how the symlink arrow display, chars in both ascii and utf8
131symlink-arrow: ⇒
エイリアス
ls
コマンドの代用で使えるようにエイリアスを設定しておくのが便利かと思います。
1alias ls='lsd'
2alias l='ls -l'
3alias la='ls -a'
4alias lla='ls -la'
5alias lt='ls --tree'
参考
- Peltoche/lsd: The next gen ls command
- ryanoasis/nerd-fonts: Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts: Hack, Source Code Pro, more. Glyph collections: Font Awesome, Material Design Icons, Octicons, & more