commit ab424056bf883612be521da504aa441de24ee17d parent bcd4adbac78654c4f44138f860e197a63a58287e Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com> Date: Tue, 8 Nov 2016 19:29:53 +0100 Keep track of current column to deduce correct rule length Maybe a better option would be to display some bright red markers and display the full rule on a new line. π€· Diffstat:
| M | .bashprompt | | | 21 | ++++++++++++++++++++- |
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/.bashprompt b/.bashprompt @@ -133,10 +133,29 @@ __set-prompt () BUILDING_PS1= } +__current-column () +{ + # Cf. console_codes(4) Β§ ECMA-48 Status Report Commands + + local position + read -sdR -p$'\E[6n' position + + local pattern='\[[0-9]+;([0-9]+)' + + if [[ ${position} =~ ${pattern} ]] + then + echo ${BASH_REMATCH[1]} + else + echo 0 + fi +} + __draw-rule () { local rule='' - for ((i=0; i<COLUMNS; i++)) + local column=$(__current-column) + + for ((i=column; i<=COLUMNS; i++)) do rule+=β done