LoginSignup
1
1

More than 5 years have passed since last update.

Macでもlessでlzoファイルをみたいよ

Last updated at Posted at 2014-07-01

CentOSとかではlzoファイルでもlessで見れるんだよなぁ…
お!brewでも強力なパッケージlesspipeはインストールできるbrew install lesspipe
しかしbz2は開けるもののlzoは…

ということで自作します

/usr/loca/bin/lzopipe.sh

LESSPIPE_SH=/usr/local/bin/lesspipe.sh #インストールした場所に合わせてくdさい
if [[ $1 =~ .*.lzo$ ]];then
  lzop -dc $1|cat
else
  $LESSPIPE_SH $1
fi

これを置いた後に

sudo chmod 755 /usr/local/bin/lzopipe.sh
export LESSOPEN='|/usr/local/bin/lzopipe.sh %s'

してください

[1]別にlesspipeをインストールしたくない人はLESSPIPE_SH=catとすればいいです
[2]lesspipeに.lzoをわたすとバイナリファイルとしてかいしゃくされるので,lzoの時は通しません

1
1
0

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
1
1