Skip to content

Instantly share code, notes, and snippets.

@jebberjeb
Last active September 10, 2015 18:01
Show Gist options
  • Save jebberjeb/18c515485df6b9986fd4 to your computer and use it in GitHub Desktop.
Save jebberjeb/18c515485df6b9986fd4 to your computer and use it in GitHub Desktop.
(ns si.tmux
(:require [clojure.string :as str]
[si.data :as d]))
(defn ->ssh-cmd
"Create remote ssh command."
[ssh-user command host]
(str "ssh -t " ssh-user "@" host " \"" command "\""))
(defn gen-conf
"Generate tmux config."
[cluster command ssh-user]
(->> cluster
d/find-hosts
(map (partial ->ssh-cmd ssh-user command))
(map (partial format "split-window -v '%s'"))
(#(mapcat vector % (repeat "select-layout tile")))
(cons "neww")
(str/join "\n")))
;; Usage: tmux source-file /path/to/htop.conf
(comment (spit "htop.conf" (gen-conf "ui-dev" "htop" "jbeich")))
(comment (spit "logs.conf" (gen-conf "ui-dev" "tail -n 20 -f /opt/lg/logs/lg-api.log" "jbeich")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment