[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request for PS0
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: Feature request for PS0 |
Date: |
Tue, 8 Feb 2022 03:37:22 +0100 |
PS0=$'\e[1A\e[K$time \e[s\n' PS1=$'prompt] ' PROMPT_COMMAND='printf -v
time "%(%F-%T)T" ${EPOCHREALTIME%.*}' ; trap $'[[ $BASH_COMMAND !=
@(trap|"printf -v time ")* ]] && { cmd=$BASH_COMMAND; IFS=$\'[;\' read
-r -d R -p $\'\\e[6n\' none line char ; printf \'\\e[u%s\e[%d;%dH\'
"$cmd" "$line" "$char" ; }' debug
but, there are two issues
one after setting a garbage command may be disabled, if no cmd was
prevously entered all ok may appear
then looked good
2022-02-08-03:35:29 ls
bl5 bl5e bl5.tgz t xbl5 xbl5.750763197 xbl5e xbl5e.3881483953
xbl5.tgz xft xft.tgz
2022-02-08-03:35:35 ps
PID TTY TIME CMD
224 pts/2 00:00:00 bash
328 pts/2 00:00:00 bash
388 pts/2 00:00:00 bash
631 pts/2 00:00:00 ps
but on piped commands, along sometimes else i think i saw, i get:
2022-02-08-03:35:39 head -1
^[[16;1Rbl5 read error: 0: Input/output error
prompt] ;1R
On Tue, Feb 8, 2022 at 3:25 AM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> wrote:
>
> if u try this and like
> ther is bugfixes to do
> manual calculatement of the late enterpoint in the printf, the \e H one
>
> for the case a cmd is longer than $cOLUMNS it may fuck up there a bit
> but with manual positionment it should be working
>
> On Tue, Feb 8, 2022 at 3:05 AM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> wrote:
> >
> > it may mangle data
> > it mangled the paste
> >
> > PS0=$'\e[1A\e[K$time \e[s\n' PS1=$'' PROMPT_COMMAND='printf -v time
> > "%(%F-%T)T" ${EPOCHREALTIME%.*}' ; trap $'[[ $BASH_COMMAND != "printf
> > -v time "* ]] && { cmd=$BASH_COMMAND; IFS=$\'[;\' read -r -d R -p
> > $\'\\e[6n\' none line char ; printf \'\\e[u%s\e[%d;%dH\' "$cmd"
> > "$line" "$char" ; }' debug
> >
> > On Tue, Feb 8, 2022 at 3:04 AM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
> > wrote:
> > >
> > > PS0=$'\e[1A\e[K$time \e[s\n' PS1=$'' PROMPT_COMMAND='printf -v time
> > > "%(%F-%T)T" ${EPOCHREALTIME%.*}' ; trap $'[[ $BASH_COMMAND != "printf
> > > -v time "* ]] && { cmd=$BASH_COMMAND; IFS=$\'[;\' read -r -d R -p
> > > 2022-02-08-03:04:31
> > > 2022-02-08-03:04:33 ls
> > > bl5 bl5e bl5.tgz t xbl5 xbl5.750763197 xbl5e xbl5e.3881483953
> > > xbl5.tgz xft xft.tgz
> > > 2022-02-08-03:04:35 uptime
> > > 03:04:37 up 2:17, 0 users, load average: 0.00, 0.00, 0.00
> > >
> > > On Mon, Feb 7, 2022 at 8:13 PM Akbarkhon Variskhanov
> > > <akbarkhon.variskhanov@gmail.com> wrote:
> > > >
> > > > Hello.
> > > >
> > > > Would it be possible to add an option or easy configuration of where
> > > > PS0 is
> > > > placed? I really want to have PS0 appear side-by-side with PS1 but in
> > > > front
> > > > of it, so that the whole command line looks like this after having been
> > > > read:
> > > > ~ echo "Hello, Wo # not finished typing
> > > > ~ echo "Hello, World!" # finished typing, pressing Enter
> > > > 21:39:44 ~ echo "Hello, World!"
> > > > Hello, World!
> > > > The default behavior is:
> > > > ~ echo "Hello, World!"
> > > > 21:39:44
> > > > Hello, World!
> > > >
> > > > CSI sequences such as \033[A, \033[F or term caps like cuu and tput cuu1
> > > > only work for single-row command lines. As soon as pipelines, multiple
> > > > arguments or long command lines are involved, everything gets scrambled.
> > > > See this thread for details:
> > > > https://ubuntuforums.org/showthread.php?t=2471634
> > > >
> > > > Thanks.