Show HN: tmuxp – session manager for tmux
tmuxp.git-pull.com
tmuxp.git-pull.com
ITerm has native TMux integration so you don't have to re-learn how to use TMux terminal (ex. copy and paste work differently, etc). I used to use Mosh + TMux for super durable connections and that worked beautifully. Unfortunately Mosh doesn't play well with ITerm's native integration so you can achieve a poor man's Mosh by using http://www.harding.motd.ca/autossh/.
All-together it looks something like this: Open iTerm. autossh -t myRemoteHost "tmux -CC -A"
(Of course I have an alias for this)
Learning tmux and it's default bindings is a very good skill too have
For some reason there doesn't seem to be support for it on Linux terminals though: http://unix.stackexchange.com/questions/189805/what-terminal...
Strange. I have found using iTerm through tmux to be very liberating and easy.
Autossh for automatic reconnection would be splendid. Unfortunately, it did not work iTerm 3.1 beta 2 with autossh 1.4e. I'll have to check again when 3.1 gets out of beta. Though restarting connections doesn't happen that often, fortunately.
When working through mobile network I sometimes get latencies that makes me wish for what Mosh can do. Hopefully somebody figures out what magic is needed for shells and terminals to communicate between themselves. All of these solutions, while working, do have some hacky feel to them. Mind you, this is a hard problem due to long legacy of Unix tools.
Also, for my version of autossh and Ubuntu server needed this incantation: autossh -M 5055 -t SERVER "tmux -CC attach"
Is there a way to use the iterm integration but keep the tmux keyboard config? I did not find anything...
I see there's a --freeze option that saves the layout of the current session but that's a partial solution as it can't really freeze and restore the state of the applications running in the terminal windows (which is a deal breaker for me as I need to be working in a "blessed" environment for Android development with certain env variables, etc set up by a script).
Side note: tmux has an annoying misfeature that panes can't be named nor does their numbering stay stable. It's a bit tricky to programmatically set up a bunch of panes (can't do `tmux split-window -t mysession:mywindow.mypane` because mypane will change with every split) in the correct layout. So to get a specific layout, you need to do all your splits in a specific order. I did read somewhere that naming panes is a feature under development, though.
In addition, there's no need to worry about shell scripting portability across systems. I personally use macOS, Linux and BSDs, so I have to take extra time to ensure my scripts work on machines without Bash.
For some shortcuts, tips, and tricks on tmux, I have a section in a book I've recently published at https://leanpub.com/the-tao-of-tmux/read#scripting-tmux. It's freely available online. It covers command aliases, pattern matching, targets and formats.
> Side note: tmux has an annoying misfeature that panes can't be named nor does their numbering stay stable. It's a bit tricky to programmatically set up a bunch of panes (can't do `tmux split-window -t mysession:mywindow.mypane`
The internal pane_id stays the same. If you're using a library like libtmux (https://libtmux.git-pull.com), you can keep reference to the pane after split-window commands and stuff.
> So to get a specific layout, you need to do all your splits in a specific order.
Yes, this is one of the reason tools like tmuxp, tmuxinator and tmuxomatic exist.
tmuxp goes the extra mile and has integration tests across a matrix of tmux versions to assure complex configurations produce the intended result upon loading a session. (https://github.com/tony/tmuxp/tree/master/tests)
Writing those tests took time, but were highly worth it when minor changes in the behavior of tmux popped up across versions.
Plus, the whole point of a decent package manager is to simplify the "shitloads installation" process. Then again the situation might be better on Mac, where Homebrew installations have maybe one or two dependencies, then on your typical Linux distro which will install dozens of libraries separate packages. But then the difference is purely psychological, and that's why commands like "yum autoremove" exist.
It's not as configurable, but doesn't really need much configuration.
I never configure it. I have three sessions configured that I start, whether at work or at home.
Shells - Irssi, vim, bash.
SSH - All my ssh
Vim - My development (inside I then use vim tabs for different areas of a project)
My experience from configuring tmuxp in Yaml is not overall good, it felt clunky and immature. But like I said, I never touch it anymore. It just works.
That all said, I do completely relate to your "[screen] happens to be installed on most hosts" point. That's also the main reason I've never switched to zsh over bash and why I don't run fancy vim plugins.
session "statictrain"
directory "/home/minhajuddin/r/st/web"
window "src", [
pane("vim TODO"),
]
window "server-iex", [
pane("iex -S mix phoenix.server"),
# the last argument is passed to tmux as raw arguments
#pane("iex -S mix", :horizontal, "-l 8"),
pane("git status; tail -f log/debug.log", :vertical),
]
# if you comment this out it will focus the first window when the session is started
#focus_window "server-iex"
# focus_window 0 # you can even focus a window by index starting at 0
# vim: filetype=rubyMy other problem is that when I restart my laptop I lose all local tmux sessions. It looks like this might be a solution via `tmuxp freeze`. Will this save bash history and stdout or only pane layouts?
I am also looking for a way to grep unified bash history across all hosts I use.
One idea I have to improve workflow / keep state across restarts is to vpn to a remote server and use my "main" terminal from there. When I need to run something locally I do it via mosh to local IP on vpn. This way local screen state is saved even across restarts (since server is up 24/7). However this is super convoluted and not ideal for many reasons.
https://github.com/tmux-plugins/tmux-continuum
As for nested sessions I usually bind ^B ^B to send-prefix which means it will call the nested session, if you keep this as a standard in all you tmux configs you'll always be able to nest by repeating ^B, and even if you haven't you can always do ^B :send-prefix
I've used tmux-continuum in conjunction with tmuxinator in order to easily keep sessions for different projects, however tmuxp should fill this purpose as well.
Restarting is a pain, having to restore tmux and emacs and chrome and whatnot, but since I restart about once per month it's still acceptable.
Instead of launching tmux with a predefined session configuration, I launch a fresh session and then use tmuxifier to load window configurations as needed.
A large benefit of tmuxifier is that it's all written as a collection of shell scripts, so there are no additional dependencies. It also has really good tab completion.
I am switching to Kakoune IDE, which doesn't have pane splitting/etc, it relies on a tool such as tmux to do splitting instead. So, needless to say Tmux has become even more crucial to my environment.