Hi! Since tmux supports chaining commands via \; already, I find it a pity tmux cannot handle any sort of line continuation as far as I can see.
The patch below implements this feature: lines ending with a single backslash will trigger the next line to be read in also. Thus, it's possible to split up big commands over several lines, like this: # paste latest cutbuffer to sprunge bind P run-shell \ "tmux set-b $(tmux sa - | curl -F 'sprunge=<-' http://sprunge.us) && \ tmux display-message 'sprunge: upload sucessful!'" If there's something fishy with the patch, please tell me and I'll correct it. Julius diff --git i/cfg.c w/cfg.c index b69e29f..542fb14 100644 --- i/cfg.c +++ w/cfg.c @@ -92,15 +92,25 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes) retval = 0; while ((buf = fgetln(f, &len))) { if (buf[len - 1] == '\n') - buf[len - 1] = '\0'; - else { - line = xrealloc(line, 1, len + 1); - memcpy(line, buf, len); - line[len] = '\0'; - buf = line; - } + len--; + + if(line != NULL) + line = xrealloc(line, 1, strlen(line) + len + 1); + else + line = xcalloc(1, len + 1); + + /* append buffer to line */ + strncat(line, buf, len); + buf = line; n++; + /* continuation: slurp in next line? */ + if (buf[strlen(buf) - 1] == '\\') { + buf[strlen(buf) - 1] = '\0'; + continue; + } + line = NULL; + if (cmd_string_parse(buf, &cmdlist, &cause) != 0) { if (cause == NULL) continue; @@ -135,8 +145,10 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes) xfree(cfg_cause); } } - if (line != NULL) + if (line != NULL) { xfree(line); + log_warnx("unfinished command at end of file: %s", path); + } fclose(f); return (retval); ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users