Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14746

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

From Jaren Stangret <sirjaren@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: GNUbash v. 4.4.23-5 – Bash identifier location is non-correct in terminal
Date 2018-10-30 10:43 -0500
Message-ID <mailman.3107.1540914239.1284.bug-bash@gnu.org> (permalink)
References <CAM_8-CjzL77M=XjQCNKHrXpqiAZk172UjaLjAEksJuMLgzGvRQ@mail.gmail.com> <36e7d390-36d9-6b34-668f-bafb9b1885e5@iki.fi>

Show all headers | View raw


On Mon, Oct 29, 2018 at 7:37 AM Ilkka Virta <itvirta@iki.fi> 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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: GNUbash v. 4.4.23-5 – Bash identifier location is non-correct in terminal Jaren Stangret <sirjaren@gmail.com> - 2018-10-30 10:43 -0500

csiph-web