Last active
September 10, 2015 18:01
-
-
Save jebberjeb/18c515485df6b9986fd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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