TIL blog

技術ネタ, その他学んだことのアウトプット用

auto-ls をいい感じにする

esa と typora で個人wiki 的な感じのもの作って満足 して public なoutputをサボっていたので 小ネタを書く

auto-ls

github.com

cd したときに デフォルトで 自動的に lsgit status してくれるやつ, history が汚染されにくくなるし便利。

不満点

出力が冗長, scipy に適当にfile を追加してみる

~/gitrepos/github.com/scipy/scipy master*
❯ touch hoge && cd .
appveyor.yml  CONTRIBUTING.rst  hoge             MANIFEST.in  README.rst   setup.py          tools
benchmarks    doc               INSTALL.rst.txt  pavement.py  runtests.py  site.cfg.example  tox.ini
codecov.yml   HACKING.rst.txt   LICENSE.txt      pytest.ini   scipy        THANKS.txt

On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    hoge

nothing added to commit but untracked files present (use "git add" to track)

対策

git status --shortexa を使う

exa について

better ls, rust製

github.com

zshrc に以下を追加

export AUTO_LS_COMMANDS=(exa git-status-short)
auto-ls-exa () {
if type "exa" > /dev/null 2>&1; then;
                exa
        fi
}
auto-ls-git-status-short () {
  if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == true ]]; then
    git status --short
  fi
}

結果

出力が簡潔になっていい感じ, コードべた張りなのでわかりにくいが, exa 使ってるので色分けもいい感じ。

~/gitrepos/github.com/scipy/scipy master*
❯ cd .
appveyor.yml  CONTRIBUTING.rst  hoge             MANIFEST.in  README.rst   setup.py          tools
benchmarks    doc               INSTALL.rst.txt  pavement.py  runtests.py  site.cfg.example  tox.ini
codecov.yml   HACKING.rst.txt   LICENSE.txt      pytest.ini   scipy        THANKS.txt
?? hoge

一言

はてなシンタックスハイライト 結構マイナーなのにも対応しているのに, なんで bash ないんだ...

help.hatenablog.com