bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNUbash v. 4.4.23-5 – Bash identifier location is non-correct in ter


From: Jaren Stangret
Subject: Re: GNUbash v. 4.4.23-5 – Bash identifier location is non-correct in terminal
Date: Tue, 30 Oct 2018 10:43:18 -0500

On Mon, Oct 29, 2018 at 7:37 AM Ilkka Virta <address@hidden> wrote:
>
>    prompt_to_bol() { local pos; printf '\e[6n'; read -sdR pos;
>        [[ ${pos#*;} != 1 ]] && printf '\e[30;47m%%\n\e[0m'; }
>    PROMPT_COMMAND=prompt_to_bol
>
> (I stole the main parts from the answers in
> https://unix.stackexchange.com/q/88296/170373 )

 Another solution I use is to emulate ZSH's behavior, which places a
'%' in reverse video if the previous command ended in a newline,

# Can return $ps1 by printing our using this function in
# PROMPT_COMMAND, or some other means.
_zsh_prompt_nl()
{
  local line_pos col_pos
  IFS=';[' read -s -t1 -d'R' -p $'\033[6n' _ line_pos col_pos

  if (( col_pos != 1 )); then
    (( LINES != line_pos ))
    ps1="${reset/\[0/[7}%${reset}\n${ps1}\n"
  else
    ps1="${ps1}\n"
  fi
}

Updating LINES and COLUMN non-interactively can be difficult,
so obtaining these values manually may be required:

IFS='[;'                                                    \
  read -rsu2 -d'R' -p $'\033[s\033[9999;9999H\033[6n\033[u' \
  _ LINES COLUMNS


reply via email to

[Prev in Thread] Current Thread [Next in Thread]