Giter Club home page Giter Club logo

tmux-save-sessions's Introduction

tmux-save-sessions

Save and restore tmux sessions in bash

There are many ways to tmuxinate, but I just want a bash script of my tmux sessions.

Usage

./tmux-save-sessions

All sessions, windows, panes, running commands and layouts get saved as a bash script in the current directory named sessions-${timestamp}.sh

To restore a session, execute the generated script.

  ./sessions-2014-08-12-4423.sh

Run ./tmux-save-sessions multiple times to save different snapshots of your sessions.

Requirements

tmux 1.9
bash




Inspired by all the other scripts out there and this snippet from the tmux manpage:

In addition, select-layout may be used to apply a previously used layout
 - the list-windows command displays the layout of each window in a form
 suitable for use with select-layout.  For example:

       $ tmux list-windows
       0: ksh [159x48]
           layout: bb62,159x48,0,0{79x48,0,0,79x48,80,0}
       $ tmux select-layout bb62,159x48,0,0{79x48,0,0,79x48,80,0}

 tmux automatically adjusts the size of the layout for the current window
 size.  Note that a layout cannot be applied to a window with more panes
 than that from which the layout was originally defined.

tmux-save-sessions's People

Contributors

zsoltf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tmux-save-sessions's Issues

send-keys not send when has 3 panes.

This is my sessions:

#!/bin/bash
TERM=screen-256color
if $(tmux has-session 2>/dev/null); then tmux att; exit; fi
tmux new-session -d -n ngrok -s 0 -c /Users/hrj/Documents/workspace/car-server
tmux send-keys -t 0:0.0 "tail -f logs/app.log" C-m
tmux select-layout -t 0:0 "1268,238x48,0,0{120x48,0,0,0,117x48,121,0,1}" > /dev/null
tmux split-window -d -t 0:0 -c /Users/hrj/Documents/workspace/ngrok
tmux send-keys -t 0:0.1 "./ngrok -config ngrok.cfg start wx" C-m
tmux select-layout -t 0:0 "1268,238x48,0,0{120x48,0,0,0,117x48,121,0,1}" > /dev/null
tmux new-window -d -n node -t 0:1 -c /Users/hrj/Documents/workspace/app-server
tmux send-keys -t 0:1.0 "gulp " C-m
tmux select-layout -t 0:1 "3453,238x48,0,0{79x48,0,0,2,79x48,80,0,4,78x48,160,0,3}" > /dev/null
tmux split-window -d -t 0:1 -c /Users/hrj/Documents/workspace/ngrok
tmux send-keys -t 0:1.1 "./ngrok -config ngrok.cfg start local" C-m  ##### This send-keys not exec
tmux select-layout -t 0:1 "3453,238x48,0,0{79x48,0,0,2,79x48,80,0,4,78x48,160,0,3}" > /dev/null
tmux split-window -d -t 0:1 -c /Users/hrj/Documents/workspace/ngrok
tmux send-keys -t 0:1.2 "./ngrok -config ngrok.cfg start wxtest" C-m
tmux select-layout -t 0:1 "3453,238x48,0,0{79x48,0,0,2,79x48,80,0,4,78x48,160,0,3}" > /dev/null
tmux new-window -d -n bash -t 0:2 -c /Users/hrj/Documents/workspace/app-server
tmux select-layout -t 0:2 "cf62,238x48,0,0,5" > /dev/null
tmux new-window -d -n bash -t 0:3 -c /Users/hrj/.dotfiles/.tmux
tmux select-layout -t 0:3 "cf63,238x48,0,0,6" > /dev/null
tmux att

This send-keys not execute when restore sessions, but execute it alone is ok.

tmux send-keys -t 0:1.1 "./ngrok -config ngrok.cfg start local" C-m

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.