Path: csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Jaren Stangret Newsgroups: gnu.bash.bug Subject: =?UTF-8?Q?Re=3A_GNUbash_v=2E_4=2E4=2E23=2D5_=E2=80=93_Bash_identifier_location?= =?UTF-8?Q?_is_non=2Dcorrect_in_terminal?= Date: Tue, 30 Oct 2018 10:43:18 -0500 Lines: 33 Approved: bug-bash@gnu.org Message-ID: References: <36e7d390-36d9-6b34-668f-bafb9b1885e5@iki.fi> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1540914240 8814 208.118.235.17 (30 Oct 2018 15:44:00 GMT) X-Complaints-To: action@cs.stanford.edu Cc: ricky.tigg@gmail.com, bug-bash@gnu.org To: itvirta@iki.fi Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ynJvawMg8IfQ6BA+BnoDCq3yd1mkvVscCzW2TKMH+Fo=; b=LrcqvV7cixedskhhIgpuYMAx6a/e0fA2sOBFntXYWPS88mOt6SB86FNO9yTqM8NIX+ ik/E90YEscoArAq41BVfgdiaKECgGP8jQ11kyM1BGRTWLV25mPeaIJlvC1J8MZdvE7KZ Qg0XxXhbBy3pdL2B5G2cC+TQey1vsmE7DoyHCppwkxLclPGpteNGLKGA8bSFNzFkD24O B8vot3nBBgYLxatANkpW+2ZFXiFzPF7JHaPpsQEB8N6oF4jTPgRac6SRcGTyTFtkZ3Ag srtc0mF7INaTnQWXYcHTQwjsPGU48cJ3Q/fRzDGucD3TdPshyuiF+lElqXsM6/frUfSM sQ3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ynJvawMg8IfQ6BA+BnoDCq3yd1mkvVscCzW2TKMH+Fo=; b=KbEYG4z/hUOIQhv7Dyj0iIXPQUydqgjOav5L4ejR0y7U23/zY5dIWxnIlomvc7xZ0A g3drt21+3mAchtMP7Jk/FMXztFiDDGWs+DbDfeNW+8EPbCdQ571IEWcjcDCf93OhUWBU OTyBaoxR1nO49tMUr/JU7Uqr/7tthk5JJwMxckox84xTDZvhWQMtNlLzo+qm9Rloudrp ybDr7REm2j+5npz7H1OOH92cHZxxW7IwjytxJamhrN/P4GjqYk7Cvb1zxMeNCTriJrst BUHNMjif79olsfGTiYZ85/dNrjdT1gRCw6nryMK8ujXUyt7Ea7Cg2gD/gJ7t1/hbAJ+U 3UsQ== X-Gm-Message-State: AGRZ1gJGgizobCC2VNjmosxitsZzJbSkqlZ8iRKUJYVDgaTRAk9f3qQJ SesFZ/5STunO9vTf2fB6vFgMEOjTP/GLwRqHQv4= X-Google-Smtp-Source: AJdET5felXJ+f5tOBQunJkEXM4eI0H+xyLM9Qg+CeIYH0ZD1iXiiLaCdC2J0r3cPsMoEXBOkB0dTRD6Rw8p4k3WL1gc= X-Received: by 2002:a6b:7801:: with SMTP id j1-v6mr8504275iom.241.1540914209411; Tue, 30 Oct 2018 08:43:29 -0700 (PDT) In-Reply-To: <36e7d390-36d9-6b34-668f-bafb9b1885e5@iki.fi> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::d43 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14746 On Mon, Oct 29, 2018 at 7:37 AM Ilkka Virta 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