Referring to this answer I tried increasing the buffer size using commands
set-option -g history-limit 10000
set -g history-limit 10000
but it does not work for me. I want to increase the buffer size of all the windows or at least the current window in tmux. I am opening the tmux session in Putty.
Note: I was trying to use the mouse scroll. I am able to scroll up using "prefix [" but not using the mouse
Some troubleshooting tools that helped me when I had this problem:
yes
to quickly fill up the scrollback
tmux new-session
to make sure I was getting a new session
tmux show-options -g
to see if tmux actually had the right setting.
In my case, I was unknowingly attaching to previous tmux sessions, that were created before I increased the history-limit.
In my case I had some tmux processes running even though tmux a showed no attachable sessions. I manually killed every tmux process and after starting a new session new history-limit finally kicked in (check by tmux show-options -g to make sure).
Related
I'm trying to view all commands I have entered and their outputs. I understand that I can use 'history' to view all of my recent commands. However, is there a way I can check for previous outputs of those commands? I have tried looking it up and there does not seem to be a way.
It only stores history of the commands you ran (which you can retrieve by typing history). Unless you already have set the scroll-back to a very high number, there is no way to see the outputs that are older than the set value of scroll-back. Also setting this value to a very high number will make your scrolling sluggish since the lines are stored in the memory. Cloud Shell uses Tmux, which has a scroll back buffer of 2000 lines by default.
To store your future commands and their outputs, there are few options:
Using screen
Start a screen session by entering screen. Once you are inside ‘screen’, press Ctrl-a, then :, then enter log. All the I/O will be captured in screenlog files in the directory where you started the screen command.
Using script
You can start by typing script. A script session will start that will capture all the I/O to a file named typescript. You can exit the script session by Ctrl-d and view the logs in the typescript file.
Using tee
tee is a handy tool. You can do something like this:
$ tmux | tee log.txt
This will open a new bash shell inside the one you are already running. When you exit out of this, you can see the outputs in the file called log.txt
Other ways
As Dustin Kirkland suggested in this post, you can also use byobu. Although, I have never used terminal screencasting tools such as Shelr also sounds like an option.
Other ways
Cloud Shell commands to run and a link that explains more. This will exit the terminal and thus delete all the scroll back buffer, resetting it to empty, but in the future it will save 5000 lines rather than 2000.
$ tmux show-options -g | grep history
history-limit 2000
$ echo "set -g history-limit 5000" >> ~/.tmux.conf
$ exit
$ tmux show-options -g | grep history
history-limit 5000
If you type…
$ man tmux
… you can find the documentation for this setting (search by typing '/history-limit' + (enter)).
‘history-limit lines’ set the maximum number of lines held in window history. This setting applies only to new windows - existing window histories are not resized and retain the limit at the point they were created.
Initially, I had tmux working in bash shell. Then, I installed the zsh shell and changed the default shell to zsh with the following line:
#set shell
set-option -g default-shell /usr/bin/zsh
Then, I noticed that tmux would not work. For instance, after getting into tmux, pressing ctrl+b+" displayed a yellow bar at the bottom with "index" on it.
Since then, I have made several modifications to tmux.conf and now I do not know the settings for the default tmux.conf. I tried removing and reinstalling tmux but the tmux.conf file still remains the same.
Any suggestions would be very much appreciated.
Thanks.
Try to re-install tmux using this command: dpkg --purge tmux This will erase all tmux configuration file. And then install it againapt-get install tmux
I am running a server with Ubuntu 14.04 using nodejs with
npm start
command.
I start tmux session with
tmux
command, then do
npm start
and finally do
ctrl+d
to detach.
But ctrl+d would not work for me. Whatever I am using, it only detaches me from the session if I stop all the processes.
It is also same problem when I am trying to detach from session with mongod running.
Any ideas?
PS: running ctrl+a+d does not work either.
When issuing a tmux command, you need to first use the prefix key combination. By default, this is C-b (ctrl+b).
If the default prefix isn't working, it's possible that you changed it or, if you're using someone else's .tmux.conf, they may have changed it. You can run tmux list-keys | grep send-prefix from your shell to determine what the current prefix is.
So, in order to detach from a running session, you'd type C-b d.
Scenario: I open a new tmux session, and run emacs .tmux.conf.
The second line of .tmux.conf reads: set-option -g prefix C-a. I type 'asd', and the second line now reads: asdset-option -g prefix C-a. All good.
I ssh to another server, do some stuff, and then close the connection. I now re-run emacs .tmux.conf, and type 'asd'. The second line now reads asd-option -g prefix C-a, but if I save and run emacs .tmux.conf again, I'll see asdset-option -g prefix C-a.
This issue affects all lines except the first, even when I'm typing commands in the prompt.
Sourcing .bashrc, resetting the pane with respawn-pane, does not fix this. If I create a new pane or window, the issue is fixed in the new pane or window until I run ssh again.
What's happening? It's clearly a display issue, since inspection of the actual file reveals that i'm not actually overwriting.
To fix the problems of this kind, type in your shell:
$ stty sane
This is generally an universal one-time fix for terminal left off in a weird state.
To get rid of the problem completely, check your $TERM environment variable.
Inside tmux it should be TERM=screen (some suffix may present).
tmux does this automatically but your TERM environment variable can be altered by shell startup/login scripts.
So, in your tmux window type:
$ export TERM=screen
$ emacs <...>
If it helps, revise your shell rc files.
When I run Vim from inside a tmux session and copy some text to the clipboard, each line gets padded with spaces to the right.
For example, say I have a text file like this:
^some$
^text$
Note: I've used ^ and $ to mark the beginning and end of a line respectively. They are not part of the file content.
I start tmux and open this file in Vim. I press Shift (to prevent Vim from processing the mouse click) and mark the complete text by holding the left mouse button clicked. Then I copy it to the clipboard with Shift+Ctrl+c.
The result in the clipboard is something like:
^some $
^text $
Note the extra spaces. The number of spaces depends on the terminal width.
If I start Vim without tmux or if I just cat the file content and then copy it, there are no extra spaces. So it must have to do with the combination of Vim + tmux. I've seen this on different Linux flavours, i.e. on Ubuntu and Mint. I use the default terminal (Gnome Terminal 3.6.2) there.
So how can I prevent this?
EDIT: My tmux.conf
set-option -g prefix C-a
set-option -g mouse-utf8 off
set-option -g status-keys vi
set-window-option -g mode-keys vi
set-window-option -g mode-mouse on
set-option -g terminal-overrides 'xterm*:smcup#:rmcup#'
bind-key C-a last-window
bind-key C-h select-pane -L
bind-key C-l select-pane -R
# colors:
set-option -g status-bg black
set-option -g status-fg white
set-option -g status-left '#[fg=green]#H'
set-window-option -g window-status-current-bg red
EDIT 2: I've also tried without the above .tmux.conf, using tmux' default settings - no difference.
After more investigation I found the root of the problem. It's because tmux does not support the bce feature. From the xterm FAQ:
The term "bce" stands for "back color erase". Terminals such as modern xterm and rxvt implement back color erase, others such as dtterm do not. (Roughly half of the emulators that I know about implement bce). When an application clears the screen, a terminal that implements back color erase will retain the last-set background color. A terminal that does not implement back color erase will reset the background color to the default or initial colors. Applications that paint most of the screen in a single color are more efficient on terminals that support back color erase. Inevitably, there are tradeoffs and issues with standardization of the feature as noted in the ncurses FAQ. Unsurprisingly, ncurses supports xterm's behavior.
The original screen multiplexer had this feature. I've opened a feature request issue, but unfortunately they refused to implement it. So the hard truth is: There's no solution with tmux.
UPDATE: For those checking the feature request - Good luck! The author is very opinionated and reacts quite thin-skinned. He completely banned me from the repository, because I dared to counter one of his snotty comments. Take care.
Emm, I found a workaround, to change TERM to xterm from screen:
TERM=xterm vim
or use below in ~/.tmux.conf
set -g default-terminal "xterm"
Above I've tested in GNOME terminal's local shell and SecureCRT's remote shell.
If this still not works, maybe you can check you don't have "set t_ut=" in your ~/.vimrc or other global settings, because I find this break my workaround.
but in "man tmux", it says
"The TERM environment variable must be set to “screen” for all programs running inside tmux. New windows will automatically have “TERM=screen” added to their environment, but care must be taken not to reset this in shell start-up files."
and
"Set the default terminal for new windows created in this session - the default value of the TERM environment variable. For tmux to work correctly, this must be set to ‘screen’ or a derivative of it."
I don't know the side effect of this.