Bash:使输出"ls"丰富多彩和多列

  • 本文关键字:丰富多彩 ls 输出 Bash bash
  • 更新时间 :
  • 英文 :


我想在带有macos bash shell的颜色亮点的列中查看 ls的输出。

颜色

ls -GFS # gives colorful output of one column

ls | paste - - -   # gives 3 columns without hightlight

我们如何使其既有彩色和3列?

如果我可以发挥功能并放入.bash_profile,那就太好了每当我做lss时,我都可以在3列中看到输出列表。

例如:

alias lss='ls -GFS'

update

ls -GFS | paste - - - # This gives 3 columns but no hightlight
ls -GFS # this gives one column with hightlight

您可以强迫MacOS LS通过设置CLICOLOR_FORCE

在管道上显示颜色
CLICOLOR_FORCE=1 ls -GFS | cat

gnu ls的等效物为:

ls --color=always | cat

但是,请注意,MacOS ls -GFS将自动调整适合文件名和终端宽度的列数:

bash-3.2 $ ls -GFS
a pretty long filename
an even longer filename that takes up half the terminal
file1*
file2*
file3*
bash-3.2 $ rm an even longer filename that takes up half the terminal
bash-3.2 $ ls -GFS
a pretty long filename  file2*
file1*                  file3*
bash-3.2 $ rm a pretty long filename
bash-3.2 $ ls -GFS
file1* file2* file3*

最新更新