Commit 4b291a46 authored by Nelso Jost's avatar Nelso Jost
Browse files

FIX: clean up and testing make save

parent 1ef436ca
......@@ -2,11 +2,18 @@ all: install-basic install-neovim-ubuntu install-vimplug-nvim setup
install-basic:
sudo apt-get install vim git tree dialog ctags curl tmux rsync colordiff
$(MAKE) install-pip
install-pip:
wget https://bootstrap.pypa.io/get-pip.py &&
sudo python3 get-pip.py && sudo python get-pip.py && rm get-pip.py
install-neovim-debian:
sudo cp etc/apt/preferences.d/testing-priority /etc/apt/preferences.d/testing-priority
sudo cp etc/apt/sources.list.d/testing.list /etc/apt/sources.list.d/testing.list
sudo apt-get update || sudo apt-get install neovim
sudo apt-get update || sudo apt-get install -t testing neovim
sudo pip install neovim
sudo pip3 install neovim
$(MAKE) install-vimplug-nvim
install-neovim-ubuntu:
......@@ -26,6 +33,6 @@ setup-keyboard:
sudo rsync -rtv etc/default/keyboard /etc/default/keyboard
save:
cp -rfv ~/.config/nvim home/.config
cp -rfv ~/.bashrc ~/.inputrc ~/.tmux.conf ~/.tmux
rsync -rtv --exclude "undo" ~/.config/nvim/ home/.config/nvim/
cp -rfv ~/.bashrc ~/.inputrc ~/.tmux.conf home/
git status
......@@ -134,7 +134,5 @@ alias tmuxrc="tmux source-file ~/.tmux.conf"
alias tmux="TERM=screen-256color tmux -2"
xmodmap ~/.Xmodmap
# http://stackoverflow.com/questions/3446320/in-vim-how-to-map-save-to-ctrl-s
stty -ixon
......@@ -19,11 +19,12 @@ Plug 'plasticboy/vim-markdown' " markdown syntax
Plug 'benmills/vimux' " exec commands on tmux panels
Plug 'xolox/vim-misc'
Plug 'xolox/vim-colorscheme-switcher'
"Plug 'lvht/tagbar-markdown'
Plug 'lvht/tagbar-markdown'
Plug 't4ku/marktag'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'bkad/CamelCaseMotion'
Plug 'christoomey/vim-tmux-navigator'
"Plug 'ervandew/supertab'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"Plug 'davidhalter/jedi'
......@@ -39,8 +40,8 @@ call plug#end()
colorscheme molokai
behave mswin
"set clipboard=unnamed
set clipboard=unnamedplus
set clipboard=unnamed
"set clipboard=unnamedplus
"
set colorcolumn=80
set nowrap
......@@ -149,7 +150,7 @@ set backspace=indent,eol,start
noremap <C-Space> ciw
inoremap <C-Space> <ESC>ciw
inoremap <C-d> <ESC>dd
"inoremap <C-d> <ESC>dd
"noremap s ciw
......@@ -192,8 +193,8 @@ nnoremap <silent> <C-Right> w
nnoremap <silent> <C-Left> b
" CTRL-Z is Undo; not in cmdline though
noremap <C-Z> u
inoremap <C-Z> <C-O> <Esc>
noremap <C-Z> u :set nopaste<cr>
inoremap <C-Z> <Esc> u :set nopaste<cr> i
noremap <C-Y> <C-R>
inoremap <C-Y> <C-O><C-R>
......@@ -261,19 +262,21 @@ let g:tagbar_width = 25
" don't give |ins-completion-menu| messages. For example,
" '-- XXX completion (YYY)', 'match 1 of 2', 'The only match',
"set shortmess+=c
set shortmess+=c
let g:deoplete#enable_at_startup=1
let g:deoplete#enable_refresh_always=0
let g:deoplete#file#enable_buffer_path=1
let g:deoplete#auto_completion_start_length = 0
"
"" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function() abort
return deoplete#close_popup() . "\<CR>"
endfunction
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
" <CR>: close popup and save indent.
"inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
"function! s:my_cr_function() abort
"return deoplete#close_popup() . "\<CR>"
"endfunction
"function! Completefunc(findstart, base)
"return "\<c-x>\<c-p>"
......@@ -309,7 +312,6 @@ endfunction
"
"
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
"let g:deoplete#disable_auto_complete = 1
......@@ -409,3 +411,18 @@ hi MatchParen cterm=none ctermbg=black ctermfg=green
" auxiliate cursor navigation between _ on words
set iskeyword-=_
" https://stackoverflow.com/questions/2514445/turning-off-auto-indent-when-pasting-text-into-vim
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
......@@ -15,6 +15,7 @@ setw -g pane-base-index 1
# https://github.com/neovim/neovim/issues/2035
set -sg escape-time 0
set-option -sg repeat-time 0
# enter scroll/copy-mode with pageup
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
......@@ -31,6 +32,7 @@ bind-key v split-window -v -c '#{pane_current_path}'
bind-key C-q kill-server
bind-key C-w kill-window
bind-key w new-window
bind-key TAB last-pane
#run-shell ~/resurrect.tmux
#
......@@ -57,10 +59,6 @@ set -g @resurrect-processes '~python'
#bind-key -T copy-mode-vi C-l select-pane -R
#bind-key -T copy-mode-vi C-\ select-pane -l
bind-key TAB select-pane -l
set-option -g repeat-time 0
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
......
# Force text files to have unix eols, so Windows/Cygwin does not break them
*.* eol=lf
# Except for images because then on checkout the files have been altered.
*.png binary
run_tests
tests/run_tests_in_isolation
tests/helpers/helpers.sh
[submodule "lib/tmux-test"]
path = lib/tmux-test
url = https://github.com/tmux-plugins/tmux-test.git
# generic packages and latest Tmux 1.9a
before_install:
- sudo apt-get update
- sudo apt-get install -y git-core expect
- sudo apt-get install -y python-software-properties software-properties-common
- sudo add-apt-repository -y ppa:pi-rho/dev
- sudo apt-get update
- sudo apt-get install -y tmux=1.9a-1~ppa1~p
install:
- git fetch --unshallow --recurse-submodules || git fetch --recurse-submodules
- lib/tmux-test/setup
script: ./tests/run_tests_in_isolation
# Changelog
### master
- save and restore tmux pane contents (@laomaiweng)
- update tmux-test to solve issue with recursing git submodules in that project
- set options quietly in `resurrect.tmux` script
- improve pane contents restoration: `cat <file>` is no longer shown in pane
content history
- refactoring: drop dependency on `paste` command
- bugfix for pane contents restoration
- expand tilde char `~` if used with `@resurrect-dir`
- do not save empty trailing lines when pane content is saved
- do not save pane contents if pane is empty (only for 'save pane contents'
feature)
- "save pane contents" feature saves files to a separate directory
- archive and compress pane contents file
- make archive & compress pane contents process more portable
- `mutt` added to the list of automatically restored programs
- added guide for migrating from tmuxinator
### v2.4.0, 2015-02-23
- add "tmux-test"
- add test for "resurrect save" feature
- add test for "resurrect restore" feature
- make the tests work and pass on travis
- add travis badge to the readme
### v2.3.0, 2015-02-12
- Improve fetching proper window_layout for zoomed windows. In order to fetch
proper value, window has to get unzoomed. This is now done faster so that
"unzoom,fetch value,zoom" cycle is almost unnoticable to the user.
### v2.2.0, 2015-02-12
- bugfix: zoomed windows related regression
- export save and restore script paths so that 'tmux-resurrect-save' plugin can
use them
- enable "quiet" saving (used by 'tmux-resurrect-save' plugin)
### v2.1.0, 2015-02-12
- if restore is started when there's only **1 pane in the whole tmux server**,
assume the users wants the "full restore" and overrwrite that pane.
### v2.0.0, 2015-02-10
- add link to the wiki page for "first pane/window issue" to the README as well
as other tweaks
- save and restore grouped sessions (used with multi-monitor workflow)
- save and restore active and alternate windows in grouped sessions
- if there are no grouped sessions, do not output empty line to "last" file
- restore active and alternate windows only if they are present in the "last" file
- refactoring: prefer using variable with tab character
- remove deprecated `M-s` and `M-r` key bindings (breaking change)
### v1.5.0, 2014-11-09
- add support for restoring neovim sessions
### v1.4.0, 2014-10-25
- plugin now uses strategies when fetching pane full command. Implemented
'default' strategy.
- save command strategy: 'pgrep'. It's here only if fallback is needed.
- save command strategy: 'gdb'
- rename default strategy name to 'ps'
- create `expect` script that can fully restore tmux environment
- fix default save command strategy `ps` command flags. Flags are different for
FreeBSD.
- add bash history saving and restoring (@rburny)
- preserving layout of zoomed windows across restores (@Azrael3000)
### v1.3.0, 2014-09-20
- remove dependency on `pgrep` command. Use `ps` for fetching process names.
### v1.2.1, 2014-09-02
- tweak 'new_pane' creation strategy to fix #36
- when running multiple tmux server and for a large number of panes (120 +) when
doing a restore, some panes might not be created. When that is the case also
don't restore programs for those panes.
### v1.2.0, 2014-09-01
- new feature: inline strategies when restoring a program
### v1.1.0, 2014-08-31
- bugfix: sourcing `variables.sh` file in save script
- add `Ctrl` key mappings, deprecate `Alt` keys mappings.
### v1.0.0, 2014-08-30
- show spinner during the save process
- add screencast script
- make default program running list even more conservative
### v0.4.0, 2014-08-29
- change plugin name to `tmux-resurrect`. Change all the variable names.
### v0.3.0, 2014-08-29
- bugfix: when top is running the pane `$PWD` can't be saved. This was causing
issues during the restore and is now fixed.
- restoring sessions multiple times messes up the whole environment - new panes
are all around. This is now fixed - pane restorations are now idempotent.
- if pane exists from before session restore - do not restore the process within
it. This makes the restoration process even more idempotent.
- more panes within a window can now be restored
- restore window zoom state
### v0.2.0, 2014-08-29
- bugfix: with vim 'session' strategy, if the session file does not exist - make
sure vim does not contain `-S` flag
- enable restoring programs with arguments (e.g. "rails console") and also
processes that contain program name
- improve `irb` restore strategy
### v0.1.0, 2014-08-28
- refactor checking if saved tmux session exists
- spinner while tmux sessions are restored
### v0.0.5, 2014-08-28
- restore pane processes
- user option for disabling pane process restoring
- enable whitelisting processes that will be restored
- expand readme with configuration options
- enable command strategies; enable restoring vim sessions
- update readme: explain restoring vim sessions
### v0.0.4, 2014-08-26
- restore pane layout for each window
- bugfix: correct pane ordering in a window
### v0.0.3, 2014-08-26
- save and restore current and alternate session
- fix a bug with non-existing window names
- restore active pane for each window that has multiple panes
- restore active and alternate window for each session
### v0.0.2, 2014-08-26
- saving a new session does not remove the previous one
- make the directory where sessions are stored configurable
- support only Tmux v1.9 or greater
- display a nice error message if saved session file does not exist
- added README
### v0.0.1, 2014-08-26
- started a project
- basic saving and restoring works
### Contributing
Code contributions are welcome!
### Reporting a bug
If you find a bug please report it in the issues. When reporting a bug please
attach:
- a file symlinked to `~/.tmux/resurrect/last`.
- your `.tmux.conf`
- if you're getting an error paste it to a [gist](https://gist.github.com/) and
link it in the issue
Copyright (C) 2014 Bruno Sutic
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Tmux Resurrect
[![Build Status](https://travis-ci.org/tmux-plugins/tmux-resurrect.png?branch=master)](https://travis-ci.org/tmux-plugins/tmux-resurrect)
Restore `tmux` environment after system restart.
Tmux is great, except when you have to restart the computer. You lose all the
running programs, working directories, pane layouts etc.
There are helpful management tools out there, but they require initial
configuration and continuous updates as your workflow evolves or you start new
projects.
`tmux-resurrect` saves all the little details from your tmux environment so it
can be completely restored after a system restart (or when you feel like it).
No configuration is required. You should feel like you never quit tmux.
It even (optionally)
[restores vim and neovim sessions](docs/restoring_vim_and_neovim_sessions.md)!
Automatic restoring and continuous saving of tmux env is also possible with
[tmux-continuum](https://github.com/tmux-plugins/tmux-continuum) plugin.
### Screencast
[![screencast screenshot](/video/screencast_img.png)](https://vimeo.com/104763018)
### Key bindings
- `prefix + Ctrl-s` - save
- `prefix + Ctrl-r` - restore
### About
This plugin goes to great lengths to save and restore all the details from your
`tmux` environment. Here's what's been taken care of:
- all sessions, windows, panes and their order
- current working directory for each pane
- **exact pane layouts** within windows (even when zoomed)
- active and alternative session
- active and alternative window for each session
- windows with focus
- active pane for each window
- "grouped sessions" (useful feature when using tmux with multiple monitors)
- programs running within a pane! More details in the
[restoring programs doc](docs/restoring_programs.md).
Optional:
- [restoring vim and neovim sessions](docs/restoring_vim_and_neovim_sessions.md)
- [restoring pane contents](docs/restoring_pane_contents.md)
- [restoring bash history](docs/restoring_bash_history.md) (experimental)
Requirements / dependencies: `tmux 1.9` or higher, `bash`.
Tested and working on Linux, OSX and Cygwin.
`tmux-resurrect` is idempotent! It will not try to restore panes or windows that
already exist.<br/>
The single exception to this is when tmux is started with only 1 pane in order
to restore previous tmux env. Only in this case will this single pane be
overwritten.
### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
Add plugin to the list of TPM plugins in `.tmux.conf`:
set -g @plugin 'tmux-plugins/tmux-resurrect'
Hit `prefix + I` to fetch the plugin and source it. You should now be able to
use the plugin.
### Manual Installation
Clone the repo:
$ git clone https://github.com/tmux-plugins/tmux-resurrect ~/clone/path
Add this line to the bottom of `.tmux.conf`:
run-shell ~/clone/path/resurrect.tmux
Reload TMUX environment with: `$ tmux source-file ~/.tmux.conf`.
You should now be able to use the plugin.
### Docs
- [Guide for migrating from tmuxinator](docs/migrating_from_tmuxinator.md)
**Configuration**
- [Changing the default key bindings](docs/custom_key_bindings.md).
- Only a conservative list of programs is restored by default:<br/>
`vi vim nvim emacs man less more tail top htop irssi mutt`.<br/>
[Restoring programs doc](docs/restoring_programs.md) explains how to restore
additional programs.
- [Change a directory](docs/save_dir.md) where `tmux-resurrect` saves tmux
environment.
**Optional features**
- [Restoring vim and neovim sessions](docs/restoring_vim_and_neovim_sessions.md)
is nice if you're a vim/neovim user.
- [Restoring pane contents](docs/restoring_pane_contents.md) feature.
**Experimental features (also optional)**
- [restoring bash history](docs/restoring_bash_history.md)
### Other goodies
- [tmux-copycat](https://github.com/tmux-plugins/tmux-copycat) - a plugin for
regex searches in tmux and fast match selection
- [tmux-yank](https://github.com/tmux-plugins/tmux-yank) - enables copying
highlighted text to system clipboard
- [tmux-open](https://github.com/tmux-plugins/tmux-open) - a plugin for quickly
opening highlighted file or a url
- [tmux-continuum](https://github.com/tmux-plugins/tmux-continuum) - automatic
restoring and continuous saving of tmux env
You might want to follow [@brunosutic](https://twitter.com/brunosutic) on
twitter if you want to hear about new tmux plugins or feature updates.
### Reporting bugs and contributing
Both contributing and bug reports are welcome. Please check out
[contributing guidelines](CONTRIBUTING.md).
### Credits
[Mislav Marohnić](https://github.com/mislav) - the idea for the plugin came from his
[tmux-session script](https://github.com/mislav/dotfiles/blob/2036b5e03fb430bbcbc340689d63328abaa28876/bin/tmux-session).
### License
[MIT](LICENSE.md)
# Custom key bindings
The default key bindings are:
- `prefix + Ctrl-s` - save
- `prefix + Ctrl-r` - restore
To change these, add to `.tmux.conf`:
set -g @resurrect-save 'S'
set -g @resurrect-restore 'R'
# Migrating from `tmuxinator`
### Why migrate to `tmux-resurrect`?
Here are some reasons why you'd want to migrate from `tmuxinator` to
`tmux-resurrect`:
- **Less dependencies**<br/>
`tmuxinator` depends on `ruby` which can be a hassle to set up if you're not a
rubyist.<br/>
`tmux-resurrect` depends just on `bash` which is virtually
omnipresent.
- **Simplicity**<br/>
`tmuxinator` has an executable, CLI interface with half dozen commands and
command completion.<br/>
`tmux-resurrect` defines just 2 tmux key bindings.
- **No configuration**<br/>
`tmuxinator` is all about config files (and their constant updating).<br/>
`tmux-resurrect` requires no configuration to work.
- **Better change handling**<br/>
When you make a change to any aspect of tmux layout, you also have to
update related `tmuxinator` project file (and test to make sure change is
ok).<br/>
With `tmux-resurrect` there's nothing to do: your change will be
remembered on the next save.
### How to migrate?
1. Install `tmux-resurrect`.
2. Open \*all* existing `tmuxinator` projects.<br/>
Verify all projects are open by pressing `prefix + s` and checking they are
all on the list.
3. Perform a `tmux-resurrect` save.
That's it! You can continue using just `tmux-resurrect` should you choose so.
Note: it probably makes no sense to use both tools at the same time as they do
the same thing (creating tmux environment for you to work in).
Technically however, there should be no issues.
### Usage differences
`tmuxinator` focuses on managing individual tmux sessions (projects).
`tmux-resurrect` keeps track of the \*whole* tmux environment: all sessions are
saved and restored together.
A couple tips if you decide to switch to `tmux-resurrect`:
- Keep all tmux sessions (projects) running all the time.<br/>
If you want to work on an existing project, you should be able to just
\*switch* to an already open session using `prefix + s`.<br/>
This is different from `tmuxinator` where you'd usually run `mux new [project]`
in order to start working on something.
- No need to kill sessions with `tmux kill-session` (unless you really don't
want to work on it ever).<br/>
It's the recurring theme by now: just keep all the sessions running all the
time. This is convenient and also cheap in terms of resources.
- The only 2 situations when you need `tmux-resurrect`:<br/>
1) Save tmux environment just before restarting/shutting down your
computer.<br/>
2) Restore tmux env after you turn the computer on.
### Other questions?
Still have questions? Feel free to open an
[issue](ihttps://github.com/tmux-plugins/tmux-resurrect/issues). We'll try to
answer it and also update this doc.
# Restoring bash history (experimental)
Enable feature with this option in `.tmux.conf`:
set -g @resurrect-save-bash-history 'on'
Bash `history` for individual panes will now be saved and restored. Due to
technical limitations, this only works for panes which have no program running
in foreground when saving. `tmux-resurrect` will send history write command to
each such pane. To prevent these commands from being added to history
themselves, add `HISTCONTROL=ignoreboth` to your `.bashrc`
(this is set by default in Ubuntu).
# Restoring pane contents
This plugin enables saving and restoring tmux pane contents.
This feature can be enabled by adding this line to `.tmux.conf`:
set -g @resurrect-capture-pane-contents 'on'
##### Known issue
When using this feature, please check the value of `default-command`
tmux option. That can be done with `$ tmux show -g default-command`.
The value should NOT contain `&&` or `||` operators. If it does, simplify the
option so those operators are removed.
Example: