You are not logged in.

#1 2026-02-01 18:47:38

suyog
Member
Registered: 2025-04-11
Posts: 7

Process substitution make commands visually dissappear

I was trying to pipe stderr to less and found out i can do that with process substitution and it worked but once i quit from less the commands i type dont seem to be typed, they do execute and give outputs, they just arent visually there.
I wrote a custom PS1 myself, So i think the problem might be from there.

RESET="\e[0m"

RED="\e[1;31m"
LIGHTORANGE="\e[38;2;193;140;1m"
GREEN="\e[1;32m"
LIGHTGREEN="\e[38;2;54;193;1m"
ORANGE="\e[38;2;241;80;47m"

getFirstHalf(){
  COLOR="${1:-\e[1;31m}" 
  printf "$COLOR|$USER $HOSTNAME|$RESET"
}

getSecondHalf(){
DIRCOLOR="${1:-\e[1;32m}" 
GITCOLOR="${2:-\e[1;33m}" 

ISGITDIR=$(git rev-parse --is-inside-work-tree 2> /dev/null)
CURRENTPATH=$(pwd)
CLEANEDPATH=$CURRENTPATH
GITPATH=""
RELATIVEPATH=""
BASEGITPATH=""
SECONDHALF=""
GITBRANCH=""

if [[ $ISGITDIR ]];then
  GITPATH=$( git rev-parse --show-toplevel )
  GITBRANCH=$(git branch --show-current)
  RELATIVEPATH=$(realpath --relative-to=$GITPATH $CURRENTPATH)


  BASEGITPATH=$( basename $GITPATH )
  CLEANEDPATH="${GITPATH%$BASEGITPATH}"
fi

if [[ $CLEANEDPATH == "$HOME"* ]];then
  CLEANEDPATH="~${CLEANEDPATH#$HOME}"
fi

if [[ $ISGITDIR ]];then
  COLOREDGITDIR="${GITCOLOR}? ${BASEGITPATH}"

  if [[ $RELATIVEPATH == "." ]];then
  SECONDHALF="|${DIRCOLOR}${CLEANEDPATH}${COLOREDGITDIR}|${GITCOLOR}(${GITBRANCH})"
else
  SECONDHALF="|${DIRCOLOR}${CLEANEDPATH}${COLOREDGITDIR}${DIRCOLOR}/${RELATIVEPATH}|${GITCOLOR}(${GITBRANCH})"
  fi
else
  SECONDHALF="|$DIRCOLOR$CLEANEDPATH|"
fi
printf "$SECONDHALF$DIRCOLOR\n\$ $RESET"
}

get_ps1(){
FIRSTHALF=$(getFirstHalf $LIGHTORANGE)
SECONDHALF=$(getSecondHalf $LIGHTGREEN $ORANGE )

printf "$FIRSTHALF""$SECONDHALF"
}


PS1='$(get_ps1)' 

Terminal_Pic

I tried this with kitty and alacritty and both give same result.

Offline

#2 2026-02-01 22:03:07

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,417

Re: Process substitution make commands visually dissappear

Not your PS1 or TE - ctrl+c
Try to quit less by pressing "q"

You're btw. not redirecting stderr but stdout.

Offline

#3 2026-02-02 01:54:41

suyog
Member
Registered: 2025-04-11
Posts: 7

Re: Process substitution make commands visually dissappear

I did quit less by pressing q, it quit but it looked like the process didn't terminate properly, prompt string doesn't appear, to write another command, so i pressed ctrl c again to quit it. Pressing Enter also works. I tried this again as root and it doesn't happen there, thats what lead me to believe the problem was on custom PS1.

I know in the command i am redirecting stdout to less, after redirecting stderr it made sense for it to work with stdout aswell so i tried that, and the problem exist no matter which stream i redirect.

After quitting less with q it just stays stuck here until i press enter or Ctrl+C, pressing q again does nothing
NvB65ZI.png

No custom PS1, trying as root
6zshh7L.png

Offline

#4 2026-02-02 09:28:33

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,417

Re: Process substitution make commands visually dissappear

I did quit less by pressing q, it quit but it looked like the process didn't terminate properly

>() redirects into a subshell, something™ in your shell rc might throw that off, have you checked whether it's actually the PS1?

Sidebar, https://en.wikipedia.org/wiki/XY_problem - what's your actual goal here?

Offline

#5 2026-02-02 09:37:16

suyog
Member
Registered: 2025-04-11
Posts: 7

Re: Process substitution make commands visually dissappear

I just want to understand why that is happening, I checked and no PS1 isn't the problem, the problem is tmux, if i run that command outside tmux then after quitting less everything is normal, but in tmux if i run the command then commands dissappear.

Offline

#6 2026-02-02 09:53:30

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,417

Re: Process substitution make commands visually dissappear

Indeed - but only on the second invocation?
The sane equivalent would be "echo foo | less"
"echo foo |& less" to redirect stdout and stderr
"echo foo | less -F" to conditionally skip the pager.

"echo foo > >(rlwrap less)"  doesn't cause issues either? So the problem will ultimately be less' input handling being confused by the subshell (and tmux)

Offline

#7 2026-02-02 09:57:57

suyog
Member
Registered: 2025-04-11
Posts: 7

Re: Process substitution make commands visually dissappear

"echo foo > >(rlwrap less)" this does cause the same issue, not other ones tho

Offline

Board footer

Powered by FluxBB