Show HN: Tmuxp – Tmux session manager written in Python
github.com
github.com
tm() {
if [ -z $1 ]; then
tmux list-sessions
return
fi
tmux detach -s $1 2> /dev/null
tmux attach-session -t $1 2> /dev/null || tmux new-session -s $1
}
_tm() {
local word completions
word="$1"
sessions=`tmux list-sessions 2> /dev/null`
[ $? -ne 0 ] && return
completions=`echo "$sessions" | cut -d ':' -f1`
reply=( "${(f)completions}" )
}
compctl -K _tm tm
I don't find I need to persist sessions, I just want a quick way to switch between them. This gives me a tm command that autocompletes session names and creates new sessions if they don't exist. It also detaches existing clients since I only ever connect once and this way I don't have to deal with issues of differing terminal sizes.They seem to load tmux, then some files in vim, then change panes.
For layout of multiple terminal sessions I use a tiling window manager on my desktop.
I've used tiling WM's full time for maybe the past decade (xmonad, i3, awesome, dwm, scrotwm/spectrwm). Also I use rxvt-unicode with the tabs extension. That's in addition to tmux.
In practice, I do not perceive redundancy. Using the tiling WM to keep the layout of terminals doesn't persist across login/logout or even the X session. Also, you can SSH to the box via another machine and have the layout there waiting for you.
Another factor that played a roll in it probably was irssi / weechat and ssh'ing into a remote box for it. No special splits or anything crazy, just using the attach/detach feature. I started with screen. Eventually moved to tmux (one thing I missed from screen was easily being able to share the 'session', though I forgot screen's terminology for that).
Then for a time, I saw tmuxinator and teamocil out there, but felt meh, don't feel like keeping a bunch of config files floating around. This was before it came a trend to store dot-configs in git.
When I realized I could have a dot config persisted across my machines (local network and remote) via git, that's when keeping project files became less an abstract nicety and more of a time saver.
I see many gradually evolve into trying a session manager out, but also see many (like another commenter ITT) who get by fine with a simple script.
I will give a try at advantages, but take note its been a while and tmuxinator may have improved on these:
1. focusing a pane in each window, as well as window in the session. So after the session is loaded, the cursor will be focused wherever you entered "focus: true". http://tmuxp.readthedocs.io/en/latest/examples.html#focusing. tmuxinator's startup_window seems to only do window focusing, not pane focusing.
2. freezing tmux layouts http://tmuxp.readthedocs.io/en/latest/cli.html#freeze-sessio...
3. JSON support
4. More ability to resolve paths relative to configuration file and relative to start_directory. http://tmuxp.readthedocs.io/en/latest/examples.html#start-di...
5. before_script for bootstrapping project dependencies before launch http://tmuxp.readthedocs.io/en/latest/examples.html#bootstra.... Can target bootstrap script via absolute path, relation to start_directory and relation to config directory.
6. Set custom indexes (window numbers) via config
These are little conveniences I don't recall seeing in tmuxinator/teamocil in 2013 (I originally used both):
- If your tmux session is already loaded, it will offer to attach it for you instead of re-running. (I don't recall if this was tmuxinator or teamocil)
- If you're already inside a tmux session and load a session via tmuxp, it will offer to switch-client for you.
- There is also an ability to import teamocil and tmuxinator configs, http://tmuxp.readthedocs.io/en/latest/cli.html#import, though it may be out of date with the latest config for them. I'm considering whether I want to remove the feature, or just try to load them natively. It wouldn't be hard.
[1] http://www.freebsd.org/cgi/man.cgi?query=tmux&apropos=0&sekt... [2] http://www.freebsd.org/cgi/man.cgi?query=tmux&apropos=0&sekt... [3] https://github.com/tony/libtmux