Migrate to chezmoi
Move config files from config to chezmoi Add script to auto install packages with DNF and Cargo
This commit is contained in:
parent
110e0882c6
commit
224c7ed45c
1654 changed files with 470035 additions and 51 deletions
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Chris Toomey
|
||||
|
||||
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.
|
||||
436
chezmoi/dot_config/tmux/plugins/vim-tmux-navigator/README.md
Normal file
436
chezmoi/dot_config/tmux/plugins/vim-tmux-navigator/README.md
Normal file
|
|
@ -0,0 +1,436 @@
|
|||
Vim Tmux Navigator
|
||||
==================
|
||||
|
||||
This plugin is a repackaging of [Mislav Marohnić's](https://mislav.net/) tmux-navigator
|
||||
configuration described in [this gist][]. When combined with a set of tmux
|
||||
key bindings, the plugin will allow you to navigate seamlessly between
|
||||
vim and tmux splits using a consistent set of hotkeys.
|
||||
|
||||
**NOTE**: This requires tmux v1.8 or higher.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
This plugin provides the following mappings which allow you to move between
|
||||
Vim panes and tmux splits seamlessly.
|
||||
|
||||
- `<ctrl-h>` => Left
|
||||
- `<ctrl-j>` => Down
|
||||
- `<ctrl-k>` => Up
|
||||
- `<ctrl-l>` => Right
|
||||
- `<ctrl-\>` => Previous split
|
||||
|
||||
**Note** - you don't need to use your tmux `prefix` key sequence before using
|
||||
the mappings.
|
||||
|
||||
If you want to use alternate key mappings, see the [configuration section
|
||||
below][].
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
### Vim
|
||||
|
||||
If you don't have a preferred installation method, I recommend using [Vundle][].
|
||||
Assuming you have Vundle installed and configured, the following steps will
|
||||
install the plugin:
|
||||
|
||||
Add the following line to your `~/.vimrc` file
|
||||
|
||||
``` vim
|
||||
Plugin 'christoomey/vim-tmux-navigator'
|
||||
```
|
||||
|
||||
Then run
|
||||
|
||||
```
|
||||
:PluginInstall
|
||||
```
|
||||
|
||||
If you are using Vim 8+, you don't need any plugin manager. Simply clone this repository inside `~/.vim/pack/plugin/start/` directory and restart Vim.
|
||||
|
||||
```
|
||||
git clone git@github.com:christoomey/vim-tmux-navigator.git ~/.vim/pack/plugins/start/vim-tmux-navigator
|
||||
```
|
||||
|
||||
|
||||
### tmux
|
||||
|
||||
To configure the tmux side of this customization there are two options:
|
||||
|
||||
#### Add a snippet
|
||||
|
||||
Add the following to your `~/.tmux.conf` file:
|
||||
|
||||
``` tmux
|
||||
# Smart pane switching with awareness of Vim splits.
|
||||
# See: https://github.com/christoomey/vim-tmux-navigator
|
||||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
|
||||
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
|
||||
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
|
||||
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
|
||||
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
|
||||
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
|
||||
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
|
||||
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
|
||||
|
||||
bind-key -T copy-mode-vi 'C-h' select-pane -L
|
||||
bind-key -T copy-mode-vi 'C-j' select-pane -D
|
||||
bind-key -T copy-mode-vi 'C-k' select-pane -U
|
||||
bind-key -T copy-mode-vi 'C-l' select-pane -R
|
||||
bind-key -T copy-mode-vi 'C-\' select-pane -l
|
||||
```
|
||||
|
||||
#### TPM
|
||||
|
||||
If you'd prefer, you can use the Tmux Plugin Manager ([TPM][]) instead of
|
||||
copying the snippet.
|
||||
When using TPM, add the following lines to your ~/.tmux.conf:
|
||||
|
||||
``` tmux
|
||||
set -g @plugin 'christoomey/vim-tmux-navigator'
|
||||
run '~/.tmux/plugins/tpm/tpm'
|
||||
```
|
||||
|
||||
Thanks to Christopher Sexton who provided the updated tmux configuration in
|
||||
[this blog post][].
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
### Custom Key Bindings
|
||||
|
||||
If you don't want the plugin to create any mappings, you can use the five
|
||||
provided functions to define your own custom maps. You will need to define
|
||||
custom mappings in your `~/.vimrc` as well as update the bindings in tmux to
|
||||
match.
|
||||
|
||||
#### Vim
|
||||
|
||||
Add the following to your `~/.vimrc` to define your custom maps:
|
||||
|
||||
``` vim
|
||||
let g:tmux_navigator_no_mappings = 1
|
||||
|
||||
noremap <silent> {Left-Mapping} :<C-U>TmuxNavigateLeft<cr>
|
||||
noremap <silent> {Down-Mapping} :<C-U>TmuxNavigateDown<cr>
|
||||
noremap <silent> {Up-Mapping} :<C-U>TmuxNavigateUp<cr>
|
||||
noremap <silent> {Right-Mapping} :<C-U>TmuxNavigateRight<cr>
|
||||
noremap <silent> {Previous-Mapping} :<C-U>TmuxNavigatePrevious<cr>
|
||||
```
|
||||
|
||||
*Note* Each instance of `{Left-Mapping}` or `{Down-Mapping}` must be replaced
|
||||
in the above code with the desired mapping. Ie, the mapping for `<ctrl-h>` =>
|
||||
Left would be created with `noremap <silent> <c-h> :<C-U>TmuxNavigateLeft<cr>`.
|
||||
|
||||
##### Autosave on leave
|
||||
|
||||
You can configure the plugin to write the current buffer, or all buffers, when
|
||||
navigating from Vim to tmux. This functionality is exposed via the
|
||||
`g:tmux_navigator_save_on_switch` variable, which can have either of the
|
||||
following values:
|
||||
|
||||
Value | Behavior
|
||||
------ | ------
|
||||
1 | `:update` (write the current buffer, but only if changed)
|
||||
2 | `:wall` (write all buffers)
|
||||
|
||||
To enable this, add the following (with the desired value) to your ~/.vimrc:
|
||||
|
||||
```vim
|
||||
" Write all buffers before navigating from Vim to tmux pane
|
||||
let g:tmux_navigator_save_on_switch = 2
|
||||
```
|
||||
|
||||
##### Disable While Zoomed
|
||||
|
||||
By default, if you zoom the tmux pane running Vim and then attempt to navigate
|
||||
"past" the edge of the Vim session, tmux will unzoom the pane. This is the
|
||||
default tmux behavior, but may be confusing if you've become accustomed to
|
||||
navigation "wrapping" around the sides due to this plugin.
|
||||
|
||||
We provide an option, `g:tmux_navigator_disable_when_zoomed`, which can be used
|
||||
to disable this unzooming behavior, keeping all navigation within Vim until the
|
||||
tmux pane is explicitly unzoomed.
|
||||
|
||||
To disable navigation when zoomed, add the following to your ~/.vimrc:
|
||||
|
||||
```vim
|
||||
" Disable tmux navigator when zooming the Vim pane
|
||||
let g:tmux_navigator_disable_when_zoomed = 1
|
||||
```
|
||||
|
||||
##### Preserve Zoom
|
||||
|
||||
As noted above, navigating from a Vim pane to another tmux pane normally causes
|
||||
the window to be unzoomed. Some users may prefer the behavior of tmux's `-Z`
|
||||
option to `select-pane`, which keeps the window zoomed if it was zoomed. To
|
||||
enable this behavior, set the `g:tmux_navigator_preserve_zoom` option to `1`:
|
||||
|
||||
```vim
|
||||
" If the tmux window is zoomed, keep it zoomed when moving from Vim to another pane
|
||||
let g:tmux_navigator_preserve_zoom = 1
|
||||
```
|
||||
|
||||
Naturally, if `g:tmux_navigator_disable_when_zoomed` is enabled, this option
|
||||
will have no effect.
|
||||
|
||||
#### Tmux
|
||||
|
||||
Alter each of the five lines of the tmux configuration listed above to use your
|
||||
custom mappings. **Note** each line contains two references to the desired
|
||||
mapping.
|
||||
|
||||
### Additional Customization
|
||||
|
||||
#### Ignoring programs that use Ctrl+hjkl movement
|
||||
|
||||
In interactive programs such as FZF, Ctrl+hjkl can be used instead of the arrow keys to move the selection up and down. If vim-tmux-navigator is getting in your way trying to change the active window instead, you can make it be ignored and work as if this plugin were not enabled. Just modify the `is_vim` variable(that you have either on the snipped you pasted on `~/.tmux.conf` or on the `vim-tmux-navigator.tmux` file). For example, to add the program `foobar`:
|
||||
|
||||
```diff
|
||||
- is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
|
||||
+ is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf|foobar)(diff)?$'"
|
||||
```
|
||||
|
||||
#### Restoring Clear Screen (C-l)
|
||||
|
||||
The default key bindings include `<Ctrl-l>` which is the readline key binding
|
||||
for clearing the screen. The following binding can be added to your `~/.tmux.conf` file to provide an alternate mapping to `clear-screen`.
|
||||
|
||||
``` tmux
|
||||
bind C-l send-keys 'C-l'
|
||||
```
|
||||
|
||||
With this enabled you can use `<prefix> C-l` to clear the screen.
|
||||
|
||||
Thanks to [Brian Hogan][] for the tip on how to re-map the clear screen binding.
|
||||
|
||||
#### Restoring SIGQUIT (C-\\)
|
||||
|
||||
The default key bindings also include `<Ctrl-\>` which is the default method of
|
||||
sending SIGQUIT to a foreground process. Similar to "Clear Screen" above, a key
|
||||
binding can be created to replicate SIGQUIT in the prefix table.
|
||||
|
||||
``` tmux
|
||||
bind C-\\ send-keys 'C-\'
|
||||
```
|
||||
|
||||
Alternatively, you can exclude the previous pane key binding from your `~/.tmux.conf`. If using TPM, the following line can be used to unbind the previous pane binding set by the plugin.
|
||||
|
||||
``` tmux
|
||||
unbind -n C-\\
|
||||
```
|
||||
|
||||
#### Disable Wrapping
|
||||
|
||||
By default, if you try to move past the edge of the screen, tmux/vim will
|
||||
"wrap" around to the opposite side. To disable this, you'll need to
|
||||
configure both tmux and vim:
|
||||
|
||||
For vim, you only need to enable this option:
|
||||
```vim
|
||||
let g:tmux_navigator_no_wrap = 1
|
||||
```
|
||||
|
||||
Tmux doesn't have an option, so whatever key bindings you have need to be set
|
||||
to conditionally wrap based on position on screen:
|
||||
|
||||
```tmux
|
||||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
|
||||
bind-key -n 'C-h' if-shell "$is_vim" { send-keys C-h } { if-shell -F '#{pane_at_left}' {} { select-pane -L } }
|
||||
bind-key -n 'C-j' if-shell "$is_vim" { send-keys C-j } { if-shell -F '#{pane_at_bottom}' {} { select-pane -D } }
|
||||
bind-key -n 'C-k' if-shell "$is_vim" { send-keys C-k } { if-shell -F '#{pane_at_top}' {} { select-pane -U } }
|
||||
bind-key -n 'C-l' if-shell "$is_vim" { send-keys C-l } { if-shell -F '#{pane_at_right}' {} { select-pane -R } }
|
||||
|
||||
bind-key -T copy-mode-vi 'C-h' if-shell -F '#{pane_at_left}' {} { select-pane -L }
|
||||
bind-key -T copy-mode-vi 'C-j' if-shell -F '#{pane_at_bottom}' {} { select-pane -D }
|
||||
bind-key -T copy-mode-vi 'C-k' if-shell -F '#{pane_at_top}' {} { select-pane -U }
|
||||
bind-key -T copy-mode-vi 'C-l' if-shell -F '#{pane_at_right}' {} { select-pane -R }
|
||||
```
|
||||
|
||||
#### Nesting
|
||||
If you like to nest your tmux sessions, this plugin is not going to work
|
||||
properly. It probably never will, as it would require detecting when Tmux would
|
||||
wrap from one outermost pane to another and propagating that to the outer
|
||||
session.
|
||||
|
||||
By default this plugin works on the outermost tmux session and the vim
|
||||
sessions it contains, but you can customize the behaviour by adding more
|
||||
commands to the expression used by the grep command.
|
||||
|
||||
When nesting tmux sessions via ssh or mosh, you could extend it to look like
|
||||
`'(^|\/)g?(view|vim|ssh|mosh?)(diff)?$'`, which makes this plugin work within
|
||||
the innermost tmux session and the vim sessions within that one. This works
|
||||
better than the default behaviour if you use the outer Tmux sessions as relays
|
||||
to different hosts and have all instances of vim on remote hosts.
|
||||
|
||||
Similarly, if you like to nest tmux locally, add `|tmux` to the expression.
|
||||
|
||||
This behaviour means that you can't leave the innermost session with Ctrl-hjkl
|
||||
directly. These following fallback mappings can be targeted to the right Tmux
|
||||
session by escaping the prefix (Tmux' `send-prefix` command).
|
||||
|
||||
``` tmux
|
||||
bind -r C-h run "tmux select-pane -L"
|
||||
bind -r C-j run "tmux select-pane -D"
|
||||
bind -r C-k run "tmux select-pane -U"
|
||||
bind -r C-l run "tmux select-pane -R"
|
||||
bind -r C-\ run "tmux select-pane -l"
|
||||
```
|
||||
|
||||
Another workaround is to configure tmux on the outer machine to send keys to
|
||||
the inner tmux session:
|
||||
|
||||
```
|
||||
bind-key -n 'M-h' 'send-keys c-h'
|
||||
bind-key -n 'M-j' 'send-keys c-j'
|
||||
bind-key -n 'M-k' 'send-keys c-k'
|
||||
bind-key -n 'M-l' 'send-keys c-l'
|
||||
```
|
||||
|
||||
Here we bind "meta" key (aka "alt" or "option" key) combinations for each of
|
||||
the four directions and send those along to the innermost session via
|
||||
`send-keys`. You use the normal `C-h,j,k,l` while in the outermost session and
|
||||
the alternative bindings to navigate the innermost session. Note that if you
|
||||
use the example above on a Mac, you may need to configure your terminal app to
|
||||
get the option key to work like a normal meta key. Consult your terminal app's
|
||||
manual for details.
|
||||
|
||||
A third possible solution is to manually prevent the outermost tmux session
|
||||
from intercepting the navigation keystrokes by disabling the prefix table:
|
||||
|
||||
```
|
||||
set -g pane-active-border-style 'fg=#000000,bg=#ffff00'
|
||||
bind -T root F12 \
|
||||
set prefix None \;\
|
||||
set key-table off \;\
|
||||
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
|
||||
set -g pane-active-border-style 'fg=#000000,bg=#00ff00'
|
||||
refresh-client -S \;\
|
||||
|
||||
bind -T off F12 \
|
||||
set -u prefix \;\
|
||||
set -u key-table \;\
|
||||
set -g pane-active-border-style 'fg=#000000,bg=#ffff00'
|
||||
refresh-client -S
|
||||
```
|
||||
|
||||
This code, added to the machine running the outermost tmux session, toggles the
|
||||
outermost prefix table on and off with the `F12` key. When off, the active
|
||||
pane's border changes to green to indicate that the inner session receives
|
||||
navigation keystrokes. When toggled back on, the border returns to yellow and
|
||||
normal operation resumes and the outermost responds to the nav keystrokes.
|
||||
|
||||
The code example above also toggles the prefix key (ctrl-b by default) for the
|
||||
outer session so that same prefix can be temporarily used on the inner session
|
||||
instead of having to use a different prefix (ctrl-a by default) which you may
|
||||
find convenient. If not, simply remove the lines that set/unset the prefix key
|
||||
from the code example above.
|
||||
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
### Vim -> Tmux doesn't work!
|
||||
|
||||
This is likely due to conflicting key mappings in your `~/.vimrc`. You can use
|
||||
the following search pattern to find conflicting mappings
|
||||
`\v(nore)?map\s+\<c-[hjkl]\>`. Any matching lines should be deleted or
|
||||
altered to avoid conflicting with the mappings from the plugin.
|
||||
|
||||
Another option is that the pattern matching included in the `.tmux.conf` is
|
||||
not recognizing that Vim is active. To check that tmux is properly recognizing
|
||||
Vim, use the provided Vim command `:TmuxNavigatorProcessList`. The output of
|
||||
that command should be a list like:
|
||||
|
||||
```
|
||||
Ss -zsh
|
||||
S+ vim
|
||||
S+ tmux
|
||||
```
|
||||
|
||||
If you encounter a different output please [open an issue][] with as much info
|
||||
about your OS, Vim version, and tmux version as possible.
|
||||
|
||||
[open an issue]: https://github.com/christoomey/vim-tmux-navigator/issues/new
|
||||
|
||||
### Tmux Can't Tell if Vim Is Active
|
||||
|
||||
This functionality requires tmux version 1.8 or higher. You can check your
|
||||
version to confirm with this shell command:
|
||||
|
||||
``` bash
|
||||
tmux -V # should return 'tmux 1.8'
|
||||
```
|
||||
|
||||
### Switching out of Vim Is Slow
|
||||
|
||||
If you find that navigation within Vim (from split to split) is fine, but Vim
|
||||
to a non-Vim tmux pane is delayed, it might be due to a slow shell startup.
|
||||
Consider moving code from your shell's non-interactive rc file (e.g.,
|
||||
`~/.zshenv`) into the interactive startup file (e.g., `~/.zshrc`) as Vim only
|
||||
sources the non-interactive config.
|
||||
|
||||
### It doesn't work in Vim's `terminal` mode
|
||||
|
||||
Terminal mode is currently unsupported as adding this plugin's mappings there
|
||||
causes conflict with movement mappings for FZF (it also uses terminal mode).
|
||||
There's a conversation about this in https://github.com/christoomey/vim-tmux-navigator/pull/172
|
||||
|
||||
### It Doesn't Work in tmate
|
||||
|
||||
[tmate][] is a tmux fork that aids in setting up remote pair programming
|
||||
sessions. It is designed to run alongside tmux without issue, but occasionally
|
||||
there are hiccups. Specifically, if the versions of tmux and tmate don't match,
|
||||
you can have issues. See [this
|
||||
issue](https://github.com/christoomey/vim-tmux-navigator/issues/27) for more
|
||||
detail.
|
||||
|
||||
[tmate]: http://tmate.io/
|
||||
|
||||
### Switching between host panes doesn't work when docker is running
|
||||
|
||||
Images built from minimalist OSes may not have the `ps` command or have a
|
||||
simpler version of the command that is not compatible with this plugin.
|
||||
Try installing the `procps` package using the appropriate package manager
|
||||
command. For Alpine, you would do `apk add procps`.
|
||||
|
||||
If this doesn't solve your problem, you can also try the following:
|
||||
|
||||
Replace the `is_vim` variable in your `~/.tmux.conf` file with:
|
||||
```tmux
|
||||
if-shell '[ -f /.dockerenv ]' \
|
||||
"is_vim=\"ps -o state=,comm= -t '#{pane_tty}' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'\""
|
||||
# Filter out docker instances of nvim from the host system to prevent
|
||||
# host from thinking nvim is running in a pseudoterminal when its not.
|
||||
"is_vim=\"ps -o state=,comm=,cgroup= -t '#{pane_tty}' \
|
||||
| grep -ivE '^.+ +.+ +.+\\/docker\\/.+$' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)? +'\""
|
||||
```
|
||||
|
||||
Details: The output of the ps command on the host system includes processes
|
||||
running within containers, but containers have their own instances of
|
||||
/dev/pts/\*. vim-tmux-navigator relies on /dev/pts/\* to determine if vim is
|
||||
running, so if vim is running in say /dev/pts/<N> in a container and there is a
|
||||
tmux pane (not running vim) in /dev/pts/<N> on the host system, then without
|
||||
the patch above vim-tmux-navigator will think vim is running when its not.
|
||||
|
||||
### It Still Doesn't Work!!!
|
||||
|
||||
The tmux configuration uses an inlined grep pattern match to help determine if
|
||||
the current pane is running Vim. If you run into any issues with the navigation
|
||||
not happening as expected, you can try using [Mislav's original external
|
||||
script][] which has a more robust check.
|
||||
|
||||
[Brian Hogan]: https://twitter.com/bphogan
|
||||
[Mislav's original external script]: https://github.com/mislav/dotfiles/blob/master/bin/tmux-vim-select-pane
|
||||
[Vundle]: https://github.com/gmarik/vundle
|
||||
[TPM]: https://github.com/tmux-plugins/tpm
|
||||
[configuration section below]: #custom-key-bindings
|
||||
[this blog post]: http://www.codeography.com/2013/06/19/navigating-vim-and-tmux-splits
|
||||
[this gist]: https://gist.github.com/mislav/5189704
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
*tmux-navigator.txt* Plugin to allow seamless navigation between tmux and vim
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *tmux-navigator-contents*
|
||||
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *tmux-navigator*
|
||||
|
||||
Vim-tmux-navigator is a little plugin which enables seamless navigation
|
||||
between tmux panes and vim splits. This plugin is a repackaging of Mislav
|
||||
Marohinc's tmux=navigator configuration. When combined with a set of tmux key
|
||||
bindings, the plugin will allow you to navigate seamlessly between vim and
|
||||
tmux splits using a consistent set of hotkeys.
|
||||
|
||||
NOTE: This requires tmux v1.8 or higher.
|
||||
|
||||
==============================================================================
|
||||
CONFIGURATION *tmux-navigator-configuration*
|
||||
|
||||
* Activate autoupdate on exit
|
||||
let g:tmux_navigator_save_on_switch = 1
|
||||
|
||||
* Disable vim->tmux navigation when the Vim pane is zoomed in tmux
|
||||
let g:tmux_navigator_disable_when_zoomed = 1
|
||||
|
||||
* If the Vim pane is zoomed, stay zoomed when moving to another tmux pane
|
||||
let g:tmux_navigator_preserve_zoom = 1
|
||||
|
||||
* Custom Key Bindings
|
||||
let g:tmux_navigator_no_mappings = 1
|
||||
|
||||
noremap <silent> {Left-mapping} :<C-U>TmuxNavigateLeft<cr>
|
||||
noremap <silent> {Down-Mapping} :<C-U>TmuxNavigateDown<cr>
|
||||
noremap <silent> {Up-Mapping} :<C-U>TmuxNavigateUp<cr>
|
||||
noremap <silent> {Right-Mapping} :<C-U>TmuxNavigateRight<cr>
|
||||
noremap <silent> {Previous-Mapping} :<C-U><C-U>TmuxNavigatePrevious<cr>
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
|
@ -0,0 +1 @@
|
|||
ref: refs/heads/master
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
[submodule]
|
||||
active = .
|
||||
[remote "origin"]
|
||||
url = https://git::@github.com/christoomey/vim-tmux-navigator
|
||||
fetch = +refs/heads/master:refs/remotes/origin/master
|
||||
[branch "master"]
|
||||
remote = origin
|
||||
merge = refs/heads/master
|
||||
|
|
@ -0,0 +1 @@
|
|||
Unnamed repository; edit this file 'description' to name the repository.
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message taken by
|
||||
# applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit. The hook is
|
||||
# allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "applypatch-msg".
|
||||
|
||||
. git-sh-setup
|
||||
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
|
||||
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
|
||||
:
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message.
|
||||
# Called by "git commit" with one argument, the name of the file
|
||||
# that has the commit message. The hook should exit with non-zero
|
||||
# status after issuing an appropriate message if it wants to stop the
|
||||
# commit. The hook is allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "commit-msg".
|
||||
|
||||
# Uncomment the below to add a Signed-off-by line to the message.
|
||||
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
||||
# hook is more suited to it.
|
||||
#
|
||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
||||
|
||||
# This example catches duplicate Signed-off-by lines.
|
||||
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use IPC::Open2;
|
||||
|
||||
# An example hook script to integrate Watchman
|
||||
# (https://facebook.github.io/watchman/) with git to speed up detecting
|
||||
# new and modified files.
|
||||
#
|
||||
# The hook is passed a version (currently 2) and last update token
|
||||
# formatted as a string and outputs to stdout a new update token and
|
||||
# all files that have been modified since the update token. Paths must
|
||||
# be relative to the root of the working tree and separated by a single NUL.
|
||||
#
|
||||
# To enable this hook, rename this file to "query-watchman" and set
|
||||
# 'git config core.fsmonitor .git/hooks/query-watchman'
|
||||
#
|
||||
my ($version, $last_update_token) = @ARGV;
|
||||
|
||||
# Uncomment for debugging
|
||||
# print STDERR "$0 $version $last_update_token\n";
|
||||
|
||||
# Check the hook interface version
|
||||
if ($version ne 2) {
|
||||
die "Unsupported query-fsmonitor hook version '$version'.\n" .
|
||||
"Falling back to scanning...\n";
|
||||
}
|
||||
|
||||
my $git_work_tree = get_working_dir();
|
||||
|
||||
my $retry = 1;
|
||||
|
||||
my $json_pkg;
|
||||
eval {
|
||||
require JSON::XS;
|
||||
$json_pkg = "JSON::XS";
|
||||
1;
|
||||
} or do {
|
||||
require JSON::PP;
|
||||
$json_pkg = "JSON::PP";
|
||||
};
|
||||
|
||||
launch_watchman();
|
||||
|
||||
sub launch_watchman {
|
||||
my $o = watchman_query();
|
||||
if (is_work_tree_watched($o)) {
|
||||
output_result($o->{clock}, @{$o->{files}});
|
||||
}
|
||||
}
|
||||
|
||||
sub output_result {
|
||||
my ($clockid, @files) = @_;
|
||||
|
||||
# Uncomment for debugging watchman output
|
||||
# open (my $fh, ">", ".git/watchman-output.out");
|
||||
# binmode $fh, ":utf8";
|
||||
# print $fh "$clockid\n@files\n";
|
||||
# close $fh;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
print $clockid;
|
||||
print "\0";
|
||||
local $, = "\0";
|
||||
print @files;
|
||||
}
|
||||
|
||||
sub watchman_clock {
|
||||
my $response = qx/watchman clock "$git_work_tree"/;
|
||||
die "Failed to get clock id on '$git_work_tree'.\n" .
|
||||
"Falling back to scanning...\n" if $? != 0;
|
||||
|
||||
return $json_pkg->new->utf8->decode($response);
|
||||
}
|
||||
|
||||
sub watchman_query {
|
||||
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
|
||||
or die "open2() failed: $!\n" .
|
||||
"Falling back to scanning...\n";
|
||||
|
||||
# In the query expression below we're asking for names of files that
|
||||
# changed since $last_update_token but not from the .git folder.
|
||||
#
|
||||
# To accomplish this, we're using the "since" generator to use the
|
||||
# recency index to select candidate nodes and "fields" to limit the
|
||||
# output to file names only. Then we're using the "expression" term to
|
||||
# further constrain the results.
|
||||
my $last_update_line = "";
|
||||
if (substr($last_update_token, 0, 1) eq "c") {
|
||||
$last_update_token = "\"$last_update_token\"";
|
||||
$last_update_line = qq[\n"since": $last_update_token,];
|
||||
}
|
||||
my $query = <<" END";
|
||||
["query", "$git_work_tree", {$last_update_line
|
||||
"fields": ["name"],
|
||||
"expression": ["not", ["dirname", ".git"]]
|
||||
}]
|
||||
END
|
||||
|
||||
# Uncomment for debugging the watchman query
|
||||
# open (my $fh, ">", ".git/watchman-query.json");
|
||||
# print $fh $query;
|
||||
# close $fh;
|
||||
|
||||
print CHLD_IN $query;
|
||||
close CHLD_IN;
|
||||
my $response = do {local $/; <CHLD_OUT>};
|
||||
|
||||
# Uncomment for debugging the watch response
|
||||
# open ($fh, ">", ".git/watchman-response.json");
|
||||
# print $fh $response;
|
||||
# close $fh;
|
||||
|
||||
die "Watchman: command returned no output.\n" .
|
||||
"Falling back to scanning...\n" if $response eq "";
|
||||
die "Watchman: command returned invalid output: $response\n" .
|
||||
"Falling back to scanning...\n" unless $response =~ /^\{/;
|
||||
|
||||
return $json_pkg->new->utf8->decode($response);
|
||||
}
|
||||
|
||||
sub is_work_tree_watched {
|
||||
my ($output) = @_;
|
||||
my $error = $output->{error};
|
||||
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
|
||||
$retry--;
|
||||
my $response = qx/watchman watch "$git_work_tree"/;
|
||||
die "Failed to make watchman watch '$git_work_tree'.\n" .
|
||||
"Falling back to scanning...\n" if $? != 0;
|
||||
$output = $json_pkg->new->utf8->decode($response);
|
||||
$error = $output->{error};
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
# Uncomment for debugging watchman output
|
||||
# open (my $fh, ">", ".git/watchman-output.out");
|
||||
# close $fh;
|
||||
|
||||
# Watchman will always return all files on the first query so
|
||||
# return the fast "everything is dirty" flag to git and do the
|
||||
# Watchman query just to get it over with now so we won't pay
|
||||
# the cost in git to look up each individual file.
|
||||
my $o = watchman_clock();
|
||||
$error = $output->{error};
|
||||
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
output_result($o->{clock}, ("/"));
|
||||
$last_update_token = $o->{clock};
|
||||
|
||||
eval { launch_watchman() };
|
||||
return 0;
|
||||
}
|
||||
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub get_working_dir {
|
||||
my $working_dir;
|
||||
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
|
||||
$working_dir = Win32::GetCwd();
|
||||
$working_dir =~ tr/\\/\//;
|
||||
} else {
|
||||
require Cwd;
|
||||
$working_dir = Cwd::cwd();
|
||||
}
|
||||
|
||||
return $working_dir;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# An example hook script to prepare a packed repository for use over
|
||||
# dumb transports.
|
||||
#
|
||||
# To enable this hook, rename this file to "post-update".
|
||||
|
||||
exec git update-server-info
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed
|
||||
# by applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-applypatch".
|
||||
|
||||
. git-sh-setup
|
||||
precommit="$(git rev-parse --git-path hooks/pre-commit)"
|
||||
test -x "$precommit" && exec "$precommit" ${1+"$@"}
|
||||
:
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=$(git hash-object -t tree /dev/null)
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --type=bool hooks.allownonascii)
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
|
||||
To be portable it is advisable to rename the file.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
exec git diff-index --check --cached $against --
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git merge" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message to
|
||||
# stderr if it wants to stop the merge commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-merge-commit".
|
||||
|
||||
. git-sh-setup
|
||||
test -x "$GIT_DIR/hooks/pre-commit" &&
|
||||
exec "$GIT_DIR/hooks/pre-commit"
|
||||
:
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/sh
|
||||
|
||||
# An example hook script to verify what is about to be pushed. Called by "git
|
||||
# push" after it has checked the remote status, but before anything has been
|
||||
# pushed. If this script exits with a non-zero status nothing will be pushed.
|
||||
#
|
||||
# This hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- Name of the remote to which the push is being done
|
||||
# $2 -- URL to which the push is being done
|
||||
#
|
||||
# If pushing without using a named remote those arguments will be equal.
|
||||
#
|
||||
# Information about the commits which are being pushed is supplied as lines to
|
||||
# the standard input in the form:
|
||||
#
|
||||
# <local ref> <local oid> <remote ref> <remote oid>
|
||||
#
|
||||
# This sample shows how to prevent push of commits where the log message starts
|
||||
# with "WIP" (work in progress).
|
||||
|
||||
remote="$1"
|
||||
url="$2"
|
||||
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||
|
||||
while read local_ref local_oid remote_ref remote_oid
|
||||
do
|
||||
if test "$local_oid" = "$zero"
|
||||
then
|
||||
# Handle delete
|
||||
:
|
||||
else
|
||||
if test "$remote_oid" = "$zero"
|
||||
then
|
||||
# New branch, examine all commits
|
||||
range="$local_oid"
|
||||
else
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_oid..$local_oid"
|
||||
fi
|
||||
|
||||
# Check for WIP commit
|
||||
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
|
||||
if test -n "$commit"
|
||||
then
|
||||
echo >&2 "Found WIP commit in $local_ref, not pushing"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# Copyright (c) 2006, 2008 Junio C Hamano
|
||||
#
|
||||
# The "pre-rebase" hook is run just before "git rebase" starts doing
|
||||
# its job, and can prevent the command from running by exiting with
|
||||
# non-zero status.
|
||||
#
|
||||
# The hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- the upstream the series was forked from.
|
||||
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
||||
#
|
||||
# This sample shows how to prevent topic branches that are already
|
||||
# merged to 'next' branch from getting rebased, because allowing it
|
||||
# would result in rebasing already published history.
|
||||
|
||||
publish=next
|
||||
basebranch="$1"
|
||||
if test "$#" = 2
|
||||
then
|
||||
topic="refs/heads/$2"
|
||||
else
|
||||
topic=`git symbolic-ref HEAD` ||
|
||||
exit 0 ;# we do not interrupt rebasing detached HEAD
|
||||
fi
|
||||
|
||||
case "$topic" in
|
||||
refs/heads/??/*)
|
||||
;;
|
||||
*)
|
||||
exit 0 ;# we do not interrupt others.
|
||||
;;
|
||||
esac
|
||||
|
||||
# Now we are dealing with a topic branch being rebased
|
||||
# on top of master. Is it OK to rebase it?
|
||||
|
||||
# Does the topic really exist?
|
||||
git show-ref -q "$topic" || {
|
||||
echo >&2 "No such branch $topic"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Is topic fully merged to master?
|
||||
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
|
||||
if test -z "$not_in_master"
|
||||
then
|
||||
echo >&2 "$topic is fully merged to master; better remove it."
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
fi
|
||||
|
||||
# Is topic ever merged to next? If so you should not be rebasing it.
|
||||
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
|
||||
only_next_2=`git rev-list ^master ${publish} | sort`
|
||||
if test "$only_next_1" = "$only_next_2"
|
||||
then
|
||||
not_in_topic=`git rev-list "^$topic" master`
|
||||
if test -z "$not_in_topic"
|
||||
then
|
||||
echo >&2 "$topic is already up to date with master"
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
|
||||
/usr/bin/perl -e '
|
||||
my $topic = $ARGV[0];
|
||||
my $msg = "* $topic has commits already merged to public branch:\n";
|
||||
my (%not_in_next) = map {
|
||||
/^([0-9a-f]+) /;
|
||||
($1 => 1);
|
||||
} split(/\n/, $ARGV[1]);
|
||||
for my $elem (map {
|
||||
/^([0-9a-f]+) (.*)$/;
|
||||
[$1 => $2];
|
||||
} split(/\n/, $ARGV[2])) {
|
||||
if (!exists $not_in_next{$elem->[0]}) {
|
||||
if ($msg) {
|
||||
print STDERR $msg;
|
||||
undef $msg;
|
||||
}
|
||||
print STDERR " $elem->[1]\n";
|
||||
}
|
||||
}
|
||||
' "$topic" "$not_in_next" "$not_in_master"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
<<\DOC_END
|
||||
|
||||
This sample hook safeguards topic branches that have been
|
||||
published from being rewound.
|
||||
|
||||
The workflow assumed here is:
|
||||
|
||||
* Once a topic branch forks from "master", "master" is never
|
||||
merged into it again (either directly or indirectly).
|
||||
|
||||
* Once a topic branch is fully cooked and merged into "master",
|
||||
it is deleted. If you need to build on top of it to correct
|
||||
earlier mistakes, a new topic branch is created by forking at
|
||||
the tip of the "master". This is not strictly necessary, but
|
||||
it makes it easier to keep your history simple.
|
||||
|
||||
* Whenever you need to test or publish your changes to topic
|
||||
branches, merge them into "next" branch.
|
||||
|
||||
The script, being an example, hardcodes the publish branch name
|
||||
to be "next", but it is trivial to make it configurable via
|
||||
$GIT_DIR/config mechanism.
|
||||
|
||||
With this workflow, you would want to know:
|
||||
|
||||
(1) ... if a topic branch has ever been merged to "next". Young
|
||||
topic branches can have stupid mistakes you would rather
|
||||
clean up before publishing, and things that have not been
|
||||
merged into other branches can be easily rebased without
|
||||
affecting other people. But once it is published, you would
|
||||
not want to rewind it.
|
||||
|
||||
(2) ... if a topic branch has been fully merged to "master".
|
||||
Then you can delete it. More importantly, you should not
|
||||
build on top of it -- other people may already want to
|
||||
change things related to the topic as patches against your
|
||||
"master", so if you need further changes, it is better to
|
||||
fork the topic (perhaps with the same name) afresh from the
|
||||
tip of "master".
|
||||
|
||||
Let's look at this example:
|
||||
|
||||
o---o---o---o---o---o---o---o---o---o "next"
|
||||
/ / / /
|
||||
/ a---a---b A / /
|
||||
/ / / /
|
||||
/ / c---c---c---c B /
|
||||
/ / / \ /
|
||||
/ / / b---b C \ /
|
||||
/ / / / \ /
|
||||
---o---o---o---o---o---o---o---o---o---o---o "master"
|
||||
|
||||
|
||||
A, B and C are topic branches.
|
||||
|
||||
* A has one fix since it was merged up to "next".
|
||||
|
||||
* B has finished. It has been fully merged up to "master" and "next",
|
||||
and is ready to be deleted.
|
||||
|
||||
* C has not merged to "next" at all.
|
||||
|
||||
We would want to allow C to be rebased, refuse A, and encourage
|
||||
B to be deleted.
|
||||
|
||||
To compute (1):
|
||||
|
||||
git rev-list ^master ^topic next
|
||||
git rev-list ^master next
|
||||
|
||||
if these match, topic has not merged in next at all.
|
||||
|
||||
To compute (2):
|
||||
|
||||
git rev-list master..topic
|
||||
|
||||
if this is empty, it is fully merged to "master".
|
||||
|
||||
DOC_END
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# An example hook script to make use of push options.
|
||||
# The example simply echoes all push options that start with 'echoback='
|
||||
# and rejects all pushes when the "reject" push option is used.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-receive".
|
||||
|
||||
if test -n "$GIT_PUSH_OPTION_COUNT"
|
||||
then
|
||||
i=0
|
||||
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
|
||||
do
|
||||
eval "value=\$GIT_PUSH_OPTION_$i"
|
||||
case "$value" in
|
||||
echoback=*)
|
||||
echo "echo from the pre-receive-hook: ${value#*=}" >&2
|
||||
;;
|
||||
reject)
|
||||
exit 1
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
fi
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# An example hook script to prepare the commit log message.
|
||||
# Called by "git commit" with the name of the file that has the
|
||||
# commit message, followed by the description of the commit
|
||||
# message's source. The hook's purpose is to edit the commit
|
||||
# message file. If the hook fails with a non-zero status,
|
||||
# the commit is aborted.
|
||||
#
|
||||
# To enable this hook, rename this file to "prepare-commit-msg".
|
||||
|
||||
# This hook includes three examples. The first one removes the
|
||||
# "# Please enter the commit message..." help message.
|
||||
#
|
||||
# The second includes the output of "git diff --name-status -r"
|
||||
# into the message, just before the "git status" output. It is
|
||||
# commented because it doesn't cope with --amend or with squashed
|
||||
# commits.
|
||||
#
|
||||
# The third example adds a Signed-off-by line to the message, that can
|
||||
# still be edited. This is rarely a good idea.
|
||||
|
||||
COMMIT_MSG_FILE=$1
|
||||
COMMIT_SOURCE=$2
|
||||
SHA1=$3
|
||||
|
||||
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
|
||||
|
||||
# case "$COMMIT_SOURCE,$SHA1" in
|
||||
# ,|template,)
|
||||
# /usr/bin/perl -i.bak -pe '
|
||||
# print "\n" . `git diff --cached --name-status -r`
|
||||
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
|
||||
# *) ;;
|
||||
# esac
|
||||
|
||||
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
|
||||
# if test -z "$COMMIT_SOURCE"
|
||||
# then
|
||||
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
|
||||
# fi
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/sh
|
||||
|
||||
# An example hook script to update a checked-out tree on a git push.
|
||||
#
|
||||
# This hook is invoked by git-receive-pack(1) when it reacts to git
|
||||
# push and updates reference(s) in its repository, and when the push
|
||||
# tries to update the branch that is currently checked out and the
|
||||
# receive.denyCurrentBranch configuration variable is set to
|
||||
# updateInstead.
|
||||
#
|
||||
# By default, such a push is refused if the working tree and the index
|
||||
# of the remote repository has any difference from the currently
|
||||
# checked out commit; when both the working tree and the index match
|
||||
# the current commit, they are updated to match the newly pushed tip
|
||||
# of the branch. This hook is to be used to override the default
|
||||
# behaviour; however the code below reimplements the default behaviour
|
||||
# as a starting point for convenient modification.
|
||||
#
|
||||
# The hook receives the commit with which the tip of the current
|
||||
# branch is going to be updated:
|
||||
commit=$1
|
||||
|
||||
# It can exit with a non-zero status to refuse the push (when it does
|
||||
# so, it must not modify the index or the working tree).
|
||||
die () {
|
||||
echo >&2 "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Or it can make any necessary changes to the working tree and to the
|
||||
# index to bring them to the desired state when the tip of the current
|
||||
# branch is updated to the new commit, and exit with a zero status.
|
||||
#
|
||||
# For example, the hook can simply run git read-tree -u -m HEAD "$1"
|
||||
# in order to emulate git fetch that is run in the reverse direction
|
||||
# with git push, as the two-tree form of git read-tree -u -m is
|
||||
# essentially the same as git switch or git checkout that switches
|
||||
# branches while keeping the local changes in the working tree that do
|
||||
# not interfere with the difference between the branches.
|
||||
|
||||
# The below is a more-or-less exact translation to shell of the C code
|
||||
# for the default behaviour for git's push-to-checkout hook defined in
|
||||
# the push_to_deploy() function in builtin/receive-pack.c.
|
||||
#
|
||||
# Note that the hook will be executed from the repository directory,
|
||||
# not from the working tree, so if you want to perform operations on
|
||||
# the working tree, you will have to adapt your code accordingly, e.g.
|
||||
# by adding "cd .." or using relative paths.
|
||||
|
||||
if ! git update-index -q --ignore-submodules --refresh
|
||||
then
|
||||
die "Up-to-date check failed"
|
||||
fi
|
||||
|
||||
if ! git diff-files --quiet --ignore-submodules --
|
||||
then
|
||||
die "Working directory has unstaged changes"
|
||||
fi
|
||||
|
||||
# This is a rough translation of:
|
||||
#
|
||||
# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX
|
||||
if git cat-file -e HEAD 2>/dev/null
|
||||
then
|
||||
head=HEAD
|
||||
else
|
||||
head=$(git hash-object -t tree --stdin </dev/null)
|
||||
fi
|
||||
|
||||
if ! git diff-index --quiet --cached --ignore-submodules $head --
|
||||
then
|
||||
die "Working directory has staged changes"
|
||||
fi
|
||||
|
||||
if ! git read-tree -u -m "$commit"
|
||||
then
|
||||
die "Could not update working tree to new HEAD"
|
||||
fi
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/sh
|
||||
|
||||
# An example hook script to validate a patch (and/or patch series) before
|
||||
# sending it via email.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an appropriate
|
||||
# message if it wants to prevent the email(s) from being sent.
|
||||
#
|
||||
# To enable this hook, rename this file to "sendemail-validate".
|
||||
#
|
||||
# By default, it will only check that the patch(es) can be applied on top of
|
||||
# the default upstream branch without conflicts in a secondary worktree. After
|
||||
# validation (successful or not) of the last patch of a series, the worktree
|
||||
# will be deleted.
|
||||
#
|
||||
# The following config variables can be set to change the default remote and
|
||||
# remote ref that are used to apply the patches against:
|
||||
#
|
||||
# sendemail.validateRemote (default: origin)
|
||||
# sendemail.validateRemoteRef (default: HEAD)
|
||||
#
|
||||
# Replace the TODO placeholders with appropriate checks according to your
|
||||
# needs.
|
||||
|
||||
validate_cover_letter () {
|
||||
file="$1"
|
||||
# TODO: Replace with appropriate checks (e.g. spell checking).
|
||||
true
|
||||
}
|
||||
|
||||
validate_patch () {
|
||||
file="$1"
|
||||
# Ensure that the patch applies without conflicts.
|
||||
git am -3 "$file" || return
|
||||
# TODO: Replace with appropriate checks for this patch
|
||||
# (e.g. checkpatch.pl).
|
||||
true
|
||||
}
|
||||
|
||||
validate_series () {
|
||||
# TODO: Replace with appropriate checks for the whole series
|
||||
# (e.g. quick build, coding style checks, etc.).
|
||||
true
|
||||
}
|
||||
|
||||
# main -------------------------------------------------------------------------
|
||||
|
||||
if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
|
||||
then
|
||||
remote=$(git config --default origin --get sendemail.validateRemote) &&
|
||||
ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
|
||||
worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
|
||||
git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
|
||||
git config --replace-all sendemail.validateWorktree "$worktree"
|
||||
else
|
||||
worktree=$(git config --get sendemail.validateWorktree)
|
||||
fi || {
|
||||
echo "sendemail-validate: error: failed to prepare worktree" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
unset GIT_DIR GIT_WORK_TREE
|
||||
cd "$worktree" &&
|
||||
|
||||
if grep -q "^diff --git " "$1"
|
||||
then
|
||||
validate_patch "$1"
|
||||
else
|
||||
validate_cover_letter "$1"
|
||||
fi &&
|
||||
|
||||
if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL"
|
||||
then
|
||||
git config --unset-all sendemail.validateWorktree &&
|
||||
trap 'git worktree remove -ff "$worktree"' EXIT &&
|
||||
validate_series
|
||||
fi
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
#!/usr/bin/sh
|
||||
#
|
||||
# An example hook script to block unannotated tags from entering.
|
||||
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
|
||||
#
|
||||
# To enable this hook, rename this file to "update".
|
||||
#
|
||||
# Config
|
||||
# ------
|
||||
# hooks.allowunannotated
|
||||
# This boolean sets whether unannotated tags will be allowed into the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowdeletetag
|
||||
# This boolean sets whether deleting tags will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowmodifytag
|
||||
# This boolean sets whether a tag may be modified after creation. By default
|
||||
# it won't be.
|
||||
# hooks.allowdeletebranch
|
||||
# This boolean sets whether deleting branches will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.denycreatebranch
|
||||
# This boolean sets whether remotely creating branches will be denied
|
||||
# in the repository. By default this is allowed.
|
||||
#
|
||||
|
||||
# --- Command line
|
||||
refname="$1"
|
||||
oldrev="$2"
|
||||
newrev="$3"
|
||||
|
||||
# --- Safety check
|
||||
if [ -z "$GIT_DIR" ]; then
|
||||
echo "Don't run this script from the command line." >&2
|
||||
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||||
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
||||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Config
|
||||
allowunannotated=$(git config --type=bool hooks.allowunannotated)
|
||||
allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch)
|
||||
denycreatebranch=$(git config --type=bool hooks.denycreatebranch)
|
||||
allowdeletetag=$(git config --type=bool hooks.allowdeletetag)
|
||||
allowmodifytag=$(git config --type=bool hooks.allowmodifytag)
|
||||
|
||||
# check for no description
|
||||
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
||||
case "$projectdesc" in
|
||||
"Unnamed repository"* | "")
|
||||
echo "*** Project description file hasn't been set" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Check types
|
||||
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||
if [ "$newrev" = "$zero" ]; then
|
||||
newrev_type=delete
|
||||
else
|
||||
newrev_type=$(git cat-file -t $newrev)
|
||||
fi
|
||||
|
||||
case "$refname","$newrev_type" in
|
||||
refs/tags/*,commit)
|
||||
# un-annotated tag
|
||||
short_refname=${refname##refs/tags/}
|
||||
if [ "$allowunannotated" != "true" ]; then
|
||||
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||||
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,delete)
|
||||
# delete tag
|
||||
if [ "$allowdeletetag" != "true" ]; then
|
||||
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,tag)
|
||||
# annotated tag
|
||||
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
||||
then
|
||||
echo "*** Tag '$refname' already exists." >&2
|
||||
echo "*** Modifying a tag is not allowed in this repository." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,commit)
|
||||
# branch
|
||||
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
||||
echo "*** Creating a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,delete)
|
||||
# delete branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/remotes/*,commit)
|
||||
# tracking branch
|
||||
;;
|
||||
refs/remotes/*,delete)
|
||||
# delete tracking branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Anything else (is there anything else?)
|
||||
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Finished
|
||||
exit 0
|
||||
BIN
chezmoi/dot_config/tmux/plugins/vim-tmux-navigator/dot_git/index
Normal file
BIN
chezmoi/dot_config/tmux/plugins/vim-tmux-navigator/dot_git/index
Normal file
Binary file not shown.
|
|
@ -0,0 +1,6 @@
|
|||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
||||
|
|
@ -0,0 +1 @@
|
|||
0000000000000000000000000000000000000000 7db70e08ea03b3e4d91f63713d76134512e28d7e aleidk <ale.navarro.parra@gmail.com> 1699105325 -0300 clone: from https://github.com/christoomey/vim-tmux-navigator
|
||||
|
|
@ -0,0 +1 @@
|
|||
0000000000000000000000000000000000000000 7db70e08ea03b3e4d91f63713d76134512e28d7e aleidk <ale.navarro.parra@gmail.com> 1699105325 -0300 clone: from https://github.com/christoomey/vim-tmux-navigator
|
||||
|
|
@ -0,0 +1 @@
|
|||
0000000000000000000000000000000000000000 7db70e08ea03b3e4d91f63713d76134512e28d7e aleidk <ale.navarro.parra@gmail.com> 1699105325 -0300 clone: from https://github.com/christoomey/vim-tmux-navigator
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,2 @@
|
|||
# pack-refs with: peeled fully-peeled sorted
|
||||
7db70e08ea03b3e4d91f63713d76134512e28d7e refs/remotes/origin/master
|
||||
|
|
@ -0,0 +1 @@
|
|||
7db70e08ea03b3e4d91f63713d76134512e28d7e
|
||||
|
|
@ -0,0 +1 @@
|
|||
ref: refs/remotes/origin/master
|
||||
|
|
@ -0,0 +1 @@
|
|||
22734100c02990ff090f3544319620ef3f516dea
|
||||
|
|
@ -0,0 +1 @@
|
|||
doc/tags
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
version_pat='s/^tmux[^0-9]*([.0-9]+).*/\1/p'
|
||||
|
||||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
|
||||
tmux bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
|
||||
tmux bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
|
||||
tmux bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
|
||||
tmux bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
|
||||
tmux_version="$(tmux -V | sed -En "$version_pat")"
|
||||
tmux setenv -g tmux_version "$tmux_version"
|
||||
|
||||
#echo "{'version' : '${tmux_version}', 'sed_pat' : '${version_pat}' }" > ~/.tmux_version.json
|
||||
|
||||
tmux if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
|
||||
tmux if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
|
||||
|
||||
tmux bind-key -T copy-mode-vi C-h select-pane -L
|
||||
tmux bind-key -T copy-mode-vi C-j select-pane -D
|
||||
tmux bind-key -T copy-mode-vi C-k select-pane -U
|
||||
tmux bind-key -T copy-mode-vi C-l select-pane -R
|
||||
tmux bind-key -T copy-mode-vi C-\\ select-pane -l
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Collection of various test strings that could be the output of the tmux
|
||||
# 'pane_current_comamnd' message. Included as regression test for updates to
|
||||
# the inline grep pattern used in the `.tmux.conf` configuration
|
||||
|
||||
set -e
|
||||
|
||||
RED=$(tput setaf 1)
|
||||
GREEN=$(tput setaf 2)
|
||||
YELLOW=$(tput setaf 3)
|
||||
NORMAL=$(tput sgr0)
|
||||
|
||||
vim_pattern='(^|\/)g?(view|l?n?vim?x?|fzf)(diff)?$'
|
||||
match_tests=(vim Vim VIM vimdiff lvim /usr/local/bin/vim vi gvim view gview nvim vimx fzf)
|
||||
no_match_tests=( /Users/christoomey/.vim/thing /usr/local/bin/start-vim )
|
||||
|
||||
display_matches() {
|
||||
for process_name in "$@"; do
|
||||
printf "%s %s\n" "$(matches_vim_pattern $process_name)" "$process_name"
|
||||
done
|
||||
}
|
||||
|
||||
matches_vim_pattern() {
|
||||
if echo "$1" | grep -iqE "$vim_pattern"; then
|
||||
echo "${GREEN}match${NORMAL}"
|
||||
else
|
||||
echo "${RED}fail${NORMAL}"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
echo "Testing against pattern: ${YELLOW}$vim_pattern${NORMAL}\n"
|
||||
|
||||
echo "These should all ${GREEN}match${NORMAL}\n----------------------"
|
||||
display_matches "${match_tests[@]}"
|
||||
|
||||
echo "\nThese should all ${RED}fail${NORMAL}\n---------------------"
|
||||
display_matches "${no_match_tests[@]}"
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
" Maps <C-h/j/k/l> to switch vim splits in the given direction. If there are
|
||||
" no more windows in that direction, forwards the operation to tmux.
|
||||
" Additionally, <C-\> toggles between last active vim splits/tmux panes.
|
||||
|
||||
if exists("g:loaded_tmux_navigator") || &cp || v:version < 700
|
||||
finish
|
||||
endif
|
||||
let g:loaded_tmux_navigator = 1
|
||||
|
||||
function! s:VimNavigate(direction)
|
||||
try
|
||||
execute 'wincmd ' . a:direction
|
||||
catch
|
||||
echohl ErrorMsg | echo 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits: wincmd k' | echohl None
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
if !get(g:, 'tmux_navigator_no_mappings', 0)
|
||||
noremap <silent> <c-h> :<C-U>TmuxNavigateLeft<cr>
|
||||
noremap <silent> <c-j> :<C-U>TmuxNavigateDown<cr>
|
||||
noremap <silent> <c-k> :<C-U>TmuxNavigateUp<cr>
|
||||
noremap <silent> <c-l> :<C-U>TmuxNavigateRight<cr>
|
||||
noremap <silent> <c-\> :<C-U>TmuxNavigatePrevious<cr>
|
||||
endif
|
||||
|
||||
if empty($TMUX)
|
||||
command! TmuxNavigateLeft call s:VimNavigate('h')
|
||||
command! TmuxNavigateDown call s:VimNavigate('j')
|
||||
command! TmuxNavigateUp call s:VimNavigate('k')
|
||||
command! TmuxNavigateRight call s:VimNavigate('l')
|
||||
command! TmuxNavigatePrevious call s:VimNavigate('p')
|
||||
finish
|
||||
endif
|
||||
|
||||
command! TmuxNavigateLeft call s:TmuxAwareNavigate('h')
|
||||
command! TmuxNavigateDown call s:TmuxAwareNavigate('j')
|
||||
command! TmuxNavigateUp call s:TmuxAwareNavigate('k')
|
||||
command! TmuxNavigateRight call s:TmuxAwareNavigate('l')
|
||||
command! TmuxNavigatePrevious call s:TmuxAwareNavigate('p')
|
||||
|
||||
if !exists("g:tmux_navigator_save_on_switch")
|
||||
let g:tmux_navigator_save_on_switch = 0
|
||||
endif
|
||||
|
||||
if !exists("g:tmux_navigator_disable_when_zoomed")
|
||||
let g:tmux_navigator_disable_when_zoomed = 0
|
||||
endif
|
||||
|
||||
if !exists("g:tmux_navigator_preserve_zoom")
|
||||
let g:tmux_navigator_preserve_zoom = 0
|
||||
endif
|
||||
|
||||
if !exists("g:tmux_navigator_no_wrap")
|
||||
let g:tmux_navigator_no_wrap = 0
|
||||
endif
|
||||
|
||||
let s:pane_position_from_direction = {'h': 'left', 'j': 'bottom', 'k': 'top', 'l': 'right'}
|
||||
|
||||
function! s:TmuxOrTmateExecutable()
|
||||
return (match($TMUX, 'tmate') != -1 ? 'tmate' : 'tmux')
|
||||
endfunction
|
||||
|
||||
function! s:TmuxVimPaneIsZoomed()
|
||||
return s:TmuxCommand("display-message -p '#{window_zoomed_flag}'") == 1
|
||||
endfunction
|
||||
|
||||
function! s:TmuxSocket()
|
||||
" The socket path is the first value in the comma-separated list of $TMUX.
|
||||
return split($TMUX, ',')[0]
|
||||
endfunction
|
||||
|
||||
function! s:TmuxCommand(args)
|
||||
let cmd = s:TmuxOrTmateExecutable() . ' -S ' . s:TmuxSocket() . ' ' . a:args
|
||||
let l:x=&shellcmdflag
|
||||
let &shellcmdflag='-c'
|
||||
let retval=system(cmd)
|
||||
let &shellcmdflag=l:x
|
||||
return retval
|
||||
endfunction
|
||||
|
||||
function! s:TmuxNavigatorProcessList()
|
||||
echo s:TmuxCommand("run-shell 'ps -o state= -o comm= -t ''''#{pane_tty}'''''")
|
||||
endfunction
|
||||
command! TmuxNavigatorProcessList call s:TmuxNavigatorProcessList()
|
||||
|
||||
let s:tmux_is_last_pane = 0
|
||||
augroup tmux_navigator
|
||||
au!
|
||||
autocmd WinEnter * let s:tmux_is_last_pane = 0
|
||||
augroup END
|
||||
|
||||
function! s:NeedsVitalityRedraw()
|
||||
return exists('g:loaded_vitality') && v:version < 704 && !has("patch481")
|
||||
endfunction
|
||||
|
||||
function! s:ShouldForwardNavigationBackToTmux(tmux_last_pane, at_tab_page_edge)
|
||||
if g:tmux_navigator_disable_when_zoomed && s:TmuxVimPaneIsZoomed()
|
||||
return 0
|
||||
endif
|
||||
return a:tmux_last_pane || a:at_tab_page_edge
|
||||
endfunction
|
||||
|
||||
function! s:TmuxAwareNavigate(direction)
|
||||
let nr = winnr()
|
||||
let tmux_last_pane = (a:direction == 'p' && s:tmux_is_last_pane)
|
||||
if !tmux_last_pane
|
||||
call s:VimNavigate(a:direction)
|
||||
endif
|
||||
let at_tab_page_edge = (nr == winnr())
|
||||
" Forward the switch panes command to tmux if:
|
||||
" a) we're toggling between the last tmux pane;
|
||||
" b) we tried switching windows in vim but it didn't have effect.
|
||||
if s:ShouldForwardNavigationBackToTmux(tmux_last_pane, at_tab_page_edge)
|
||||
if g:tmux_navigator_save_on_switch == 1
|
||||
try
|
||||
update " save the active buffer. See :help update
|
||||
catch /^Vim\%((\a\+)\)\=:E32/ " catches the no file name error
|
||||
endtry
|
||||
elseif g:tmux_navigator_save_on_switch == 2
|
||||
try
|
||||
wall " save all the buffers. See :help wall
|
||||
catch /^Vim\%((\a\+)\)\=:E141/ " catches the no file name error
|
||||
endtry
|
||||
endif
|
||||
let args = 'select-pane -t ' . shellescape($TMUX_PANE) . ' -' . tr(a:direction, 'phjkl', 'lLDUR')
|
||||
if g:tmux_navigator_preserve_zoom == 1
|
||||
let l:args .= ' -Z'
|
||||
endif
|
||||
if g:tmux_navigator_no_wrap == 1
|
||||
let args = 'if -F "#{pane_at_' . s:pane_position_from_direction[a:direction] . '}" "" "' . args . '"'
|
||||
endif
|
||||
silent call s:TmuxCommand(args)
|
||||
if s:NeedsVitalityRedraw()
|
||||
redraw!
|
||||
endif
|
||||
let s:tmux_is_last_pane = 1
|
||||
else
|
||||
let s:tmux_is_last_pane = 0
|
||||
endif
|
||||
endfunction
|
||||
Loading…
Add table
Add a link
Reference in a new issue