LoginSignup
2
2

More than 5 years have passed since last update.

Quiltのtopをプロンプトに表示する

Last updated at Posted at 2015-10-01

Quiltとは何かについてはこちら。
Linux - quiltの使い方 - Qiita

Gitの__git_ps1のように、quiltのtopをプロンプトに表示してみた。

.bashrc
__quilt_ps1 () {
    local db=".pc/applied-patches"
    if [ -e $db ]
    then
        echo "($(tail -n 1 $db))"
    fi
}
PS1='[\u@\h \W\[\033[36m\]`__quilt_ps1`\[\033[0m\]]\$ '

誰得と思ってたらストックされたので改良してみた。パッチが空でなければ+を、パッチから変更があれば(refreshの必要があれば)*をプロンプトに表示します。

.bashrc
__quilt_ps1 () {
    local db=".pc/applied-patches"
    local w=""
    local i=""
    local ps=""
    if [ -e $db ]; then
        if [ -n "$(quilt diff -z)" ]; then
            w="*"
        fi
        if [ -n "$(quilt diff)" ]; then
            i="+"
        fi
        echo "($(tail -n 1 $db)$w$i)"
    fi
}
PS1='[\u@\h \W\[\033[36m\]`__quilt_ps1`\[\033[0m\]]\$ '
2
2
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
2
2