TMux Scrollback Becomes Static - terminal

I have a kinda weird question. Sometimes in some of my long-lived tmux sessions I'll have a window where the history will get kinda "stuck"
So, to clarify, that's a (bash) shell, inside a pane, inside tmux, and that shell has been running for a while.
I have my scrollback set high and I use it all the time, so I know how to use it and how it works in tmux. But sometimes something will happen and I'll always get the same history when I scroll back no matter what I print.
So for example, I'll run something like seq 1 100 and I'll only see the numbers 76 to 100 in the pane, but when I scroll up I don't see 75, I'll see the result of some git command I ran a while back. No matter what I run, when I scroll up it's that same output of that same git command, or whatever happens to have been up there when it broke.
I can exit the shell and re-open it, that works, but I'd rather not. I'm wondering if there's some kind of term control character or something, or broken curses code, or something that maybe didn't clean up properly in my terminal that would have left me in this in-between state where new lines are shown, but not added to the history? Any idea? I tried running reset, but it doesn't seem to have fixed it.
Does this make sense to anybody? I'd love to learn something new about how shells communicate with terminal emulators that makes this make sense.
Thanks!

Related

terminal command is overwritten on itself

sometimes in terminal when I type a long command, instead of continuing in the next line it starts to write at the same line and I cannot see what I am typing. What is the reason and how should I make it fine?
Sometimes if you resize a terminal window while in a fullscreen command (say inside "vim" or "less"), when you exit back to the shell it will assume your terminal has the old dimensions, and will show the behavior you are describing. See this question: https://unix.stackexchange.com/questions/61584/how-to-solve-the-issue-that-a-terminal-screen-is-messed-up-usually-after-a-res
Also, please in the future post this kind of questions in unix.stackexchange.com as this one is not strictly a programming question.

Adding informative statusbar to fullscreen terminal window

Briefly:
I would love to add a status bar that sticks to either the bottom or top of my terminal window that provides glancible information (e.g. battery life, signal strength, email count, $PROMT_COMMAND, etc.). Essentially, this will allow the terminal to be opened up to fullscreen and have all the information I could possibly want easily glancible while letting me continue all of my necessary terminal work as normal. I use a mac primarily, but would prefer a *nix compatible solution.
More detail (and what I already tried):
I am a big terminal user and only recently (within a day or two) started using tmux, so I understand that many of you may suggest that I try to use a multiplexer like screen or tmux. While tmux is starting to get very useful to me, it has it's limitations such as a limit to a single-row status bar, which is not ideal since I would want to keep the tab's bar clean without half of it being eaten up by information. Also, I would want to add $PROMPT_COMMAND which displays the current directory, and that could easily eat up most of the status bar depending on where I am in the system.
Also, I tried screen for a bit, which let's you have a hardstatus and a caption which is close to what I want, but it's development seems to have halted. Furthermore, the patch for vertical split panes messes up the graphics of a two-row status bar (very ugly).
Therefore, I think it would be preferable to have a background process running that updates a status bar on part of the screen above my multiplexer ... unless of course tmux has a multi-row status bar implementation that I haven't figured out yet.
I would love to hear about any of your possible solutions, or even your own personal setups if you think it works well for you. Thank you all for any possible help.
A couple of options:
You could run tmux inside tmux (with different configurations; you can use -f to specify a configuration file.)
You could use the tab title, though that's probably not wide enough to include everything you want. (Even if there's only one tab, you can show the tab bar in fullscreen mode). You need to tell tmux to pass the title through; see set set-titles and set set-titles-string.
I'd suggest you use both - put the current directory in the tab title and all the other status info in a separate line maintained by tmux, that way you can just skip the second part when you're not using a full-screen terminal.
I have battery info in mine,
You can get copies of the files you'll need at
https://github.com/richo/dotfiles/blob/master/tmux.conf
and
https://github.com/richo/dotfiles/blob/master/bin/battery
(Make sure that battery is executable and in your PATH)
It'll show you battery percentage in blue (charging), red (discharging) or not at all (fully charged)

Cygwin 'less' command makes bash forget screen buffer history

I'm having some issues with my Cygwin terminal when I run 'less'. 'less' works fine, but when I come out of it, all the screen buffer history of the terminal is lost. Any suggestions?
I'm running Cygwin on WinXP.
Try running as less -X, or set the LESS environment variable to -X.
It has nothing to do with bash. What's being erased is the text displayed by your terminal emulator.
Like other full-screen programs, less saves the terminal state (including any displayed text and the cursor position) when it starts, and restores it on exit.
It does this by printing the strings defined by the smcup and rmcup terminfo entries.
These depend on the value of the $TERM environment variable.
If these strings aren't printed, or if they're configured to something that doesn't save and restore your terminal state, then less will replace whatever was on your screen by the contents of the file you want to view, and then not restore it.
Using the -X option to less (as suggested by the answer you accepted tells less not to print the smcup and rmcup strings -- which I would expect to cause the problem you're trying to solve.
If you want to save and restore your terminal state (which means that the output produced by less will vanish when you quit), you need to make sure that your $TERM environment variable is set to something with proper smcup and rmcup settings. I find that setting it to xterm usually works.
If you're ambitious, you can create your own terminfo entry and use the tic command to "compile" it to the binary format used by the system.
Dawid Ferenczy's answer suggests another possible cause for the problem; it's not something I've ever run into myself.
(Opinions differ widely on whether saving and restoring the terminal state is a good thing. This blog entry was written by someone who intensely dislikes it. Personally, I like it; if I want to run a full-screen command and keep its output visible while I'm doing something else, I just launch it in another window.)
(The original poster hasn't been on the site in about 2½ years, so we shouldn't expect any feedback, but these answers are likely to be useful to others.)
I had the same issue on my new laptop. I have been using Cygwin on the 64bit Windows 7 for a long time and I never experienced this problem. But on the new fresh system (also 64bit Windows 7) the same Cygwin with the same configuration cleared the screen buffer whenever I quit LESS, MAN, VIM etc. And it bothered me very much. Because I'm using Cygwin inside ConEmu terminal emulator, I suspected ConEmu. After a lot of hours comparing everything what potentially could be the cause (environment variables, configurations, software versions etc.), I had a conversation with the ConEmu's author (and he was really great, exemplary support for the free software!). And we finally found the cause.
The only difference (or one of few) was in the display size. The old laptop has a screen resolution of 1366 x 768 pixels, while the new one has 1920 x 1080. And I'm using the whole screen for the terminal window. It's really strange, but if the terminal window height is greater than cca 62 lines, the screen buffer is cleared after quitting the LESS, VIM etc. No matters if Cygwin is executed inside the ConEMu or plain cmd.exe. Making the terminal window smaller solved the problem. Window height of 62 lines seems to be fine for me. Also, with some of greater height values, the LESS process sometimes crashed.
It seems that it's a problem of the Cygwin.
The whole story you can read here.
Maybe it could help somebody. It took me really a lot of time to solve that. While the solution (or rather workaround) is such damn stupid :)

Cygwin scrolling problem

When i run a command in cygwin when scrolled up it starts writing the output to that screen, so everything gets written over.
How can I change settings so that output will always be appended to the end not to where I have currently scrolled my window.
I found that rxvt doesn't do that but it also doesn't show me äöõü characters:(
Are you sure it's overwriting where you've currently scrolled to? I find the console just jumps back to the cursor position when there's new output. Still annoying though, and I don't know of a way to switch off that behaviour.
Anyway, have a look at 'mintty'. Like rxvt, it doesn't need an X server, but it does support Unicode, so the umlauts should be fine.

How do I make bash reverse-search work in Terminal.app without it displaying garbled output?

Using Terminal.app on OS X 10.5, often you see the commands get garbled when you do a reverse-search with Bash. Is there some kind of termcap or perhaps a bash shopt command that can fix this? It is very annoying.
Steps to reproduce: Open Terminal.app, reverse-search to a longish command. Hit <ctrl>-E once you've found the command. The cursor goes to the end of the line, but the display doesn't update.
I'm guessing this is some kind of problem with the readline library on OS X. It's more of a problem with updating the cursor position after a search than anything else. Basically, ctrl-a and ctrl-e tend to break the search output.
os x terminal failure image http://involution.com/images/osxterminal.png
In the above, the first part of the command should be displayed, and the cursor should be at the end of the line, but it isn't. You literally can't see what you're editing when this happens.
I was able to set my TERM to xterm instead of xterm-color and it solves the problem. (export TERM=xterm).
You may want to look at this post.
bash-prompt-in-os-x-terminal-broken
I had the same problem and it had to do with the PS1 variable. Let me know if this helps.
If the prompt has colors, then this is an acknowledged bug.
See bug report msg#00019.
I've encountered this bug, and while I don't know how to solve it, you can work around it by pressing <down><up>
Not sure whether this is the problem here, but a very common cause of a messed up screen in bash (with any terminal emulator, not just Terminal.app) is the window being resized.
Bash will read the window size when it starts up, and then assume it hasn't changed. When the window is resized a signal will be sent to whatever app is currently reading from the console. If this isn't bash (because you're running a text editor at the time, perhaps), then bash won't know about it.
Solution in this case is to resize the window again so that bash gets the signal and notices the new size.
I can't reproduce this, hitting either Ctrl+E, Ctrl+A or the arrow keys updates the command line correctly. Are you running 10.5.4? Is it perhaps a bug in earlier versions?
In worst case, you could launch the X server (somewhere under utilities) and launch a real xterm.

Resources