FIXING TMUX NOT RUNNING SHELL COMMANDS The joys of tmux ---------------------------------------------------------------------- I've been moving more of my shell life into `tmux'. I find it to be a very pleasant bit of software. I've picked it up with relative ease thanks to its thoroughly document man-page, sensical key-bindings, and smooth integration into my existing "all-text" lifestyle. My favorite thing about `tmux' is how it keeps my sessions alive even when I close its enclosing terminal. My sometimes slippery fingies might accidentally close a window (oops!). I've gained confidence from `tmux' knowing that I can reconnect a client to the server's sessions anytime. There's also a workflow boon from this feature: I can connect multiple clients if I want to have `tmux' open in multiple `i3' workspaces. Multiplexing more ---------------------------------------------------------------------- I want to spend more time in `tmux'. I've become so familiar and frequent with it that I'll sometimes forget a `urxvt' window isn't inside a `tmux' client. This means that I can't take advantage of `tmux''s copy mode, among other things. I use `plumber' to plumb links inside a terminal window. Basically, `urxvt-matcher' matches for certain URIs and then sends those to a Python script, `plumb', which moves the URL along to the relevant opener (YouTube, Gopher, Firefox, etc.) A lot of links I visit open `lynx' in a new terminal window. What I'd like to do instead is have those links open `lynx' on an existing `tmux' server. The first step towards this improvement is learning how to start a new shell command inside an existing `tmux' server. Fixing what's broken ---------------------------------------------------------------------- `tmux' documentation states a user can invoke `new-session' to run a given shell command on an existing `tmux' server. In whole, the command looks something like this: ,---- | tmux new-session "lynx gopher://roygbyte.com" `---- For me, this didn't work out of the box. The behavior I observed was that the session immediately exited. Weird! I thought maybe I was missing a switch for the command. I tried different switches. I ran the `new-session' command inside and outside `tmux'. I tried different programs: `top' and `emacs -nw' also exited immediately. Oddly, running `ed' worked fine (that's why it's the standard). This got me thinking my virtual terminal could be a problem. A suggested commands are suppose to exit. In other words, this is the intended behavior. It also suggested a work around (which did work!) of `tmux send-keys -t session-id "lynx gopher://roygbyte.com" ENTER'. I didn't accept the work around as a solution for me. I wanted to know what was wrong with my setup. There was mention of debugging using the `remain-on-exit' option. So I turned this on (`set -g remain-on-exit on') and invoked my initial `new-session' command again. Lo! The session read: "Terminal initialisation failed - unknown terminal type?". So the issue *is* with my terminal, which `$TERM' evaluates as `rxvt-unicode-256'. Looking through gave me ideas about what to do next, particularily: tmux has a `default-terminal' option. So I set that to be the same as `$TERM', `rxvt-unicode-256color' and tada, t'works. The `new-session' command completes and `lynx' has successfully opened the URL I supplied as an argument. Yay! In concluson ---------------------------------------------------------------------- This issue was a standard-issue "gotcha!". It's also a wake up call for me to better understand what a terminal even is. I spend so much of my life inside these things yet I don't understand their principals. Like: why do some people use `st' over `urxvt' or `xterm'? And: what's a virtual terminal, anyways? I can't answer these questions but I hope to find answers soon. Anyways, this was a fun little thing to dig into. I gained a few anciliary outcomes: this phlog post and a new `tmux' config file. I started it with some help from . Not much in it yet, but I'm sure it will grow over time: ,---- | unbind C-Space | set -g prefix C-Space | bind C-Space send-prefix | set -g mouse on | set -g renumber-windows on | set -g remain-on-exit on | set -g default-terminal rxvt-unicode-256color `---- My thanks to eidolon, too, who helped debug. They also mentioned a nice plumber hax: `bind-key -T copy-mode-vi p send-keys -X copy-pipe "plumb -"'. Make a copy in copymode and press P to send "pay the plumber". I haven't tried this yet, but I someday will.