Skip to content

Instantly share code, notes, and snippets.

@enjalot
Last active August 24, 2022 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enjalot/5138865 to your computer and use it in GitHub Desktop.
Save enjalot/5138865 to your computer and use it in GitHub Desktop.
Setup tmux so that you can use one command to restore many terminal tabs to their last path with individual command history

Install tmux

brew install tmux

Download the recovery script

http://blog.edsantiago.com/articles/tmux-session-preserve/
specifically:
goes in your home dir: http://blog.edsantiago.com/articles/tmux-session-preserve/.bashrc.tmux
goes in /usr/local/bin (or $PATH of your choice): http://blog.edsantiago.com/articles/tmux-session-preserve/tmux-session

Prepare

mkdir ~/.bash_history.d
chmod 700 ~/.bash_history.d

sudo cpan
install IPC::Run

Add the following to your ~/.profile

#tmux recovery script
alias 'tshortcut'='tmux-session new seshname.window1 seshname.window2; tmux attach -t seshname'

#mac os x doesn't have cat
alias 'tac'='tail -r'
#loads the script
if [ ! -z "$PS1" ]; then
    _tmuxrc="$HOME/.bashrc.tmux"
    if [ -e $_tmuxrc ]; then
        source $_tmuxrc
        _tmux-init-history
    fi
fi

Setup your session!

tmux-session new seshname.window1 seshname.window2
tmux attach -t seshname

TODO

save some env variables:
http://stackoverflow.com/questions/8645053/how-do-i-start-tmux-with-my-current-environment

@romanr
Copy link

romanr commented Aug 24, 2022

Scripts not found. This is backwards, the code should be in GitHub, the whole point to post this on Github is to preserve the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment