kshプロンプトは、改行文字を持つ関数として定義されます。

kshプロンプトは、改行文字を持つ関数として定義されます。

私は素晴らしいgit認識kshプロンプト関数を直接書いた。ここでは、あなたが私の問題を膨らませることなく見ることができるように、最小限の実際の例を提供します。

#!/bin/ksh

function _test_prompt
{
    prompt="`whoami`@`hostname` > "
    [[ $(id -u) -eq 0 ]] && prompt="ROOT@`hostname` # "

    print "\n\w"
    print -n "$prompt"
}

export readonly PS1='$(_test_prompt)'

私は私のものから始めました.kshrc

問題は、長くてきれいなgitログを見ようとすると、プロンプトの改行が出力の上部を切り捨てることです。例えば

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s'

次のように表示されます

* f0490d0 - Make sure fb is big enough to handle reconfigure   (3 years, 10 months ago) <Keith Packard>
* 7caa6ce - Add xrandr-auto sample script   (3 years, 10 months ago) <Keith Packard>
* f59c924 - (tag: v0.2) Update to version 0.2   (7 years ago) <Keith Packard>
* a6c8969 - Add --auto switch, a shortcut for --config "xrandr --auto"   (7 years ago) <Keith Packard>
* d45135b - Add manual   (7 years ago) <Keith Packard>
* ef165dc - add .gitignore   (7 years ago) <Keith Packard>
* d927ec1 - Autotool   (7 years ago) <Keith Packard>
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~

~/git-misc/x-on-resize
user@hostname >

そして、出力の最初の行はページの上に一度だけ表示されます。

~/git-misc/x-on-resize
user@hostname > git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s'
* 617e5ed - (HEAD -> master, origin/master, origin/HEAD) Use mode ID instead of mode for autoconfig   (3 years, 10 months ago) <Keith Packard>
* f0490d0 - Make sure fb is big enough to handle reconfigure   (3 years, 10 months ago) <Keith Packard>

(前のページの一番下にあった内容を切り取りました。)

想像できるように、これは非常に迷惑なことです。この場合、実際には最新のコミットを失い、それを見つけるために上にスクロールする必要がありました。

これは、ログ出力が1つの画面に収まる場合にのみ発生します(そうでなければ縮小されます)。

ご協力ありがとうございます!

ベストアンサー1

いつものように、実際に時間をかけて質問した後、問題を解決しました。

ちょうどpager.loggit config変数less -RFc;に設定しましたが、-c関連するスイッチは次のとおりです。less画面を下から上に再描画することであり、その逆ではありません。

明らかに、これは実際にkshの問題ではありません。とても申し訳ありません。

おすすめ記事