Closed Ambrevar closed 6 years ago
Whew! I'm sorry, I know nothing about Eshell :-)
But you know where the daemon is searched, in getDaemonPid() Now, when I look at there, probably the way how the pid is read is problematic?
daemonPID=$(< "$tmpDir/daemon-pid")
OK, I had the same problem before with https://github.com/ambrevar/demlo: this is because Eshell is a "dumb" terminal and stty returns "0 0". The fix is easy:
screenWidth=$(stty size|cut -d' ' -f2)
[ $screenWidth -eq 0 ] && screenWidth=$COLUMNS
[ $screenWidth -eq 0 ] && screenWidth=$COLS
Also to answer your question in the comment of setScreenWidth
: stty
is a good way to get the size of the terminal. tput cols
also works if you assume ncurses
is installed.
Because of dumb terminals, you should fallback on COLUMNS
and COLS
(not sure the last one is ever necessary).
Better fix, actually:
screenWidth=$(stty size|cut -d' ' -f2)
[ $screenWidth -eq 0 ] && screenWidth=$COLUMNS
[ $screenWidth -eq 0 ] && screenWidth=$COLS
[ $screenWidth -eq 0 ] && screenWidth=72
It's better to have screenWidth default to some value, even if it does not wrap well, than not displaying anything at all.
I have tried to fix one more issue (cut nothing when not on terminal) but that was too much. Any idea how to solve this?
#FIXME: Works to good (when using watch ) :-S
if [[ -t 1 ]] ; then
screenWidth=$(stty size|cut -d' ' -f2)
# Some dump terminal like Eshell ask for special treatment
# https://github.com/loh-tar/cpd/issues/4#issuecomment-346942540
(( screenWidth )) || screenWidth="$COLUMNS"
(( screenWidth )) || screenWidth="$COLS"
else
# Some big enough number which will not cut some output line
screenWidth="999"
fi
What's the issue?
Note: It's "dumb" terminal, not "dump".
What's the issue?
It's better to have screenWidth default to some value, even if it does not wrap well, than not displaying anything at all.
How about 999 instead of 72?
Conclusion: stty can somehow detect that there is a terminal when running with watch, at least does it report the correct setting.
It depends on what cpd does after screenWidth: does it wrap or does it truncate? From what you are saying, I assume it truncates, which is why you want 999, right?
Then by all mean, go for a big truncate value.
Thanks!
I haven't investigating but right now I get the following on Eshell (the Emacs Elisp shell):
While I get this with bash: