I keep seeing extra splits in my tmux session and it is driving me crazy when trying to copy and paste out logs, it copies the columns!
You run the command CTRL+b and then type the subcommand :kill-pane -a.
Preview of what that looks like here:
Related
I have a tmux session running in PuTTY, and I have tmux configured to use vim keybindings. I want to be able to use the visual highlight mode that vim keybindings provide (shift+V I believe), highlight some text, and then copy it to my Windows 10 clipboard. Is this possible?
I assume you are running tmux remotely.
If so, then for this to work you need a terminal that supports OSC 52. From a quick look at the putty code it doesn't appear to, so you will not be able to do this with putty.
However, you could try a different terminal that does support it, like mintty - it looks like you just need to turn its AllowSetSelection option on. IIRC mintty defaults to TERM=xterm, so if your tmux is new enough and you turn this option on, it should just work.
If it doesn't work, you need to check that Ms is set in the terminal-overrides option for the TERM you have outside tmux, and that the tmux set-clipboard option is set to on or external.
I have a nice window in my tmux session that has a number of panes nicely arranged. Is it possible to duplicate a session, preserving the current panes layout?
Check out some of the tmux plugins. tmux-resurrect allows you to save then later restore a set of windows and even the commands running there (out of a limited set you can configure). You may want to start by first installing the Tmux Plugin Manager that it mentions in the guide if you want to easily try out other plugins.
I use combination of zsh with oh-my-zsh and iTerm2 for development on Mac.
I'm frustrated with the following issue:
N tabs opened
close the terminal
reopen it (with Use system Window Restoration Setting)
the history from all previously opened tabs got merged into one for every reopened tab
The question: How to preserve separated history for every reopened tab?
Per https://github.com/robbyrussell/oh-my-zsh/issues/2537,
Add unsetopt share_history to your .zshrc file.
Unless iTerm2 actually just hides a tab on closing and keeps the shell session running in the background (which, according to the iTerm2 website, seems to be an option), it is not possible to completely restore a shell session. In your case It seems like a new shell session is created when restoring a tab, which leads to the history being read form HISTFILE.
If you want to prevent any merging of history, you have to ensure that of the options APPEND_HISTORY, INC_APPEND_HISTORY and SHARE_HISTORY only the first one is set:
setopt noincappendhistory
setopt nosharehistory
setopt appendhistory
This will lead to new entries in the history (i.e. commands run during the session) only being appended to the history file when the shell exits. So when you close a session, the next shell (re-)opened will have lines of the just previously closed shell on the bottom of the history.
Another option could be to have separate history files for each shell session and device your own method of loading a history from these files using the fc builtin. This would at least in part depend on whether it is possible to differentiate between iTerm2 tabs from within a shell session (for example via some environment variable) and whether this holds true when re-opening a tab.
Until recently I have been using bash with tmux. Bash was behaving as I would expect it to behave, where the history is preserved in each separate pane, and is not shared between panes. However it looks like in zsh the default is for the history in the panes is to be shared. Is there a way to overwrite the default in zsh so that they are not shared when using in tmux?
Tmux should have nothing to do with this, really. So let's focus on your Zsh setup.
You’d have to jump through some hoops to get history to be real-time shared among running Zshs, so it’s surprising that you’re seeing this. What settings have you made to control your Zsh history? Run this to see your settings:
setopt |grep hist
For not saving history immediately, you’ll want:
setopt noincappendhistory
setopt nosharehistory
You can put that into your ~/.zshrc. You may want to log out of running shells to ensure your new settings take place.
For info on all the history-related Zsh options, see man 1 zshoptions and look for the “History” section a few pages in. Note that there are also some environment variables that impact history (SAVEHISTORY, HISTFILE, HISTFILEIGNORE, HISTSIE, HISTFILESIZE).
I got tmuxinator to work with iTerm2 the following: https://stackoverflow.com/a/19747819/1009332
However, each tab initially opens in a different window. Is there any way to attach to an existing tmux session using tabs rather than new windows?
There's some more info about this cool feature here: https://code.google.com/p/iterm2/wiki/TmuxIntegration
My motivation for this was:
1. copy/paste/find locks the process in tmux, whereas with iterm2, you can find in a tail of logs and not lock the process.
2. key bindings are simpler in iTerm2.
3. I like tmuxinator to start many shell windows (tabs) when doing rails web development, so that my stdout of different processes goes to different windows, rather than mixing together when using foreman.
It is an option in iTerm2: Preferences > general Open tmux windows as native tabs in a new window, but you have to disconnect then reconnect.
Solution found here