diff options
| -rw-r--r-- | .bashprompt | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/.bashprompt b/.bashprompt index 6dc7e32..e384f17 100644 --- 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 |
