You are not logged in.
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)' 
I tried this with kitty and alacritty and both give same result.
Offline
Not your PS1 or TE - ctrl+c
Try to quit less by pressing "q"
You're btw. not redirecting stderr but stdout.
Offline
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
No custom PS1, trying as root
Offline
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
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
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
"echo foo > >(rlwrap less)" this does cause the same issue, not other ones tho
Offline