4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Purelineを軽くするconfig

Last updated at Posted at 2019-03-10

Purelineいい感じ

Windows上でGitBash使ってる
いい感じのプロンプトにしたかったのでPurelineを導入
https://github.com/chris-marsh/pureline

Powerlineライクなインターフェイス(↓は公式gitの画像)
official_screenshot

でもなんかやたら重い気がする

めっちゃ重い…
コンソールの再表示に2~3秒かかってる気がする…

カスタムしたprofileを作成

git_module が明らかに重いぽい

function git_module {
    local git_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
    if [ -n "$git_branch" ]; then
        local bg_color="$1"
        local fg_color="$2"
        local content="${PL_SYMBOLS[git_branch]} $git_branch"

        if [ "$PL_GIT_STASH" = true ]; then
            local number_stash="$(git stash list 2>/dev/null | wc -l)"
            if [ ! "$number_stash" -eq 0 ]; then
                content+="${PL_SYMBOLS[git_stash]}$number_stash"
            fi
        fi

        if [ "$PL_GIT_AHEAD" = true ]; then
            local number_behind_ahead="$(git rev-list --count --left-right '@{upstream}...HEAD' 2>/dev/null)"
            local number_ahead="${number_behind_ahead#*	}"
            local number_behind="${number_behind_ahead%	*}"
            if [ ! "0$number_ahead" -eq 0 -o ! "0$number_behind" -eq 0 ]; then
                if [ ! "$number_ahead" -eq 0 ]; then
                    content+="${PL_SYMBOLS[git_ahead]}$number_ahead"
                fi
                if [ ! "$number_behind" -eq 0 ]; then
                    content+="${PL_SYMBOLS[git_behind]}$number_behind"
                fi
            fi
        fi

        if [ "$PL_GIT_STAGED" = true ]; then
            local number_staged="$(git diff --staged --name-only --diff-filter=AM 2> /dev/null | wc -l)"
            if [ ! "$number_staged" -eq "0" ]; then
                content+=" ${PL_SYMBOLS[soft_separator]} ${PL_SYMBOLS[git_staged]}$number_staged"
            fi
        fi

        if [ "$PL_GIT_CONFLICTS" = true ]; then
            local number_conflicts="$(git diff --name-only --diff-filter=U 2> /dev/null | wc -l)"
            if [ ! "$number_conflicts" -eq "0" ]; then
                content+=" ${PL_SYMBOLS[soft_separator]} ${PL_SYMBOLS[git_conflicts]}$number_conflicts"
            fi
        fi

        if [ "$PL_GIT_MODIFIED" = true ]; then
            local number_modified="$(git diff --name-only --diff-filter=M 2> /dev/null | wc -l )"
            if [ ! "$number_modified" -eq "0" ]; then
                content+=" ${PL_SYMBOLS[soft_separator]} ${PL_SYMBOLS[git_modified]}$number_modified"
            fi
        fi

        if [ "$PL_GIT_UNTRACKED" = true ]; then
            local number_untracked="$(git ls-files --other --exclude-standard | wc -l)"
            if [ ! "$number_untracked" -eq "0" ]; then
                content+=" ${PL_SYMBOLS[soft_separator]} ${PL_SYMBOLS[git_untracked]}$number_untracked"
            fi
        fi

        if [ -n "$(git status --porcelain)" ]; then
            if [ -n "$PL_GIT_DIRTY_FG" ]; then
                fg_color="$PL_GIT_DIRTY_FG"
            fi
            if [ -n "$PL_GIT_DIRTY_BG" ]; then
                bg_color="$PL_GIT_DIRTY_BG"
            fi
        fi

        PS1+="$(section_end $fg_color $bg_color)"
        PS1+="$(section_content $fg_color $bg_color " $content ")"
        __last_color="$bg_color"
    fi
}
  • 一回の操作で何回もgitコマンド打ってる…
    • 詳細を見たかったら自分でコマンド打つなりGUIツール使うなりするのでbranch以外の表示を全部disableに
    • configで指定している$PL_GIT_STASHみたいなのを全部falseに

他にも使わなそうなmoduleをdisableに(↓このへん)

  • time_module
  • battery_module
  • virtual_env_module
  • read_only_module
  • background_jobs_module
  • newline_module
  • prompt_module

だいぶ軽くなった気がする

ローカルにcloneして↓のようにして.bashrcあたりで読み込めばOK

source [ClonedPath]/pureline/pureline
source [ClonedPath]/pureline/configs/custom.conf

その他

gitコマンドの実行結果をキャッシュするようにして機能削らなくても軽くしたりできないのかな?

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?