Add .tmux.conf
Add .tmux/plugins/tmux-sensible/CHANGELOG.md Add .tmux/plugins/tmux-sensible/LICENSE.md Add .tmux/plugins/tmux-sensible/README.md Add .tmux/plugins/tmux-sensible/.git/HEAD Add .tmux/plugins/tmux-sensible/.git/config Add .tmux/plugins/tmux-sensible/.git/description Add .tmux/plugins/tmux-sensible/.git/hooks/applypatch-msg.sample Add .tmux/plugins/tmux-sensible/.git/hooks/commit-msg.sample Add .tmux/plugins/tmux-sensible/.git/hooks/fsmonitor-watchman.sample Add .tmux/plugins/tmux-sensible/.git/hooks/post-update.sample Add .tmux/plugins/tmux-sensible/.git/hooks/pre-applypatch.sample Add .tmux/plugins/tmux-sensible/.git/hooks/pre-commit.sample Add .tmux/plugins/tmux-sensible/.git/hooks/pre-merge-commit.sample Add .tmux/plugins/tmux-sensible/.git/hooks/pre-push.sample Add .tmux/plugins/tmux-sensible/.git/hooks/pre-rebase.sample Add .tmux/plugins/tmux-sensible/.git/hooks/pre-receive.sample Add .tmux/plugins/tmux-sensible/.git/hooks/prepare-commit-msg.sample Add .tmux/plugins/tmux-sensible/.git/hooks/push-to-checkout.sample Add .tmux/plugins/tmux-sensible/.git/hooks/update.sample Add .tmux/plugins/tmux-sensible/.git/index Add .tmux/plugins/tmux-sensible/.git/info/exclude Add .tmux/plugins/tmux-sensible/.git/logs/HEAD Add .tmux/plugins/tmux-sensible/.git/logs/refs/heads/master Add .tmux/plugins/tmux-sensible/.git/logs/refs/remotes/origin/HEAD Add .tmux/plugins/tmux-sensible/.git/objects/info/.keep Add .tmux/plugins/tmux-sensible/.git/objects/pack/pack-2a598c9f31f588f92fc2a83b1ab7a1ae38767c16.idx Add .tmux/plugins/tmux-sensible/.git/objects/pack/pack-2a598c9f31f588f92fc2a83b1ab7a1ae38767c16.pack Add .tmux/plugins/tmux-sensible/.git/packed-refs Add .tmux/plugins/tmux-sensible/.git/refs/heads/master Add .tmux/plugins/tmux-sensible/.git/refs/remotes/origin/HEAD Add .tmux/plugins/tmux-sensible/.git/refs/tags/v1.0.0 Add .tmux/plugins/tmux-sensible/.git/refs/tags/v1.1.0 Add .tmux/plugins/tmux-sensible/.git/refs/tags/v2.0.0 Add .tmux/plugins/tmux-sensible/.git/refs/tags/v2.1.0 Add .tmux/plugins/tmux-sensible/.git/refs/tags/v2.2.0 Add .tmux/plugins/tmux-sensible/.git/refs/tags/v2.3.0 Add .tmux/plugins/tmux-sensible/.git/refs/tags/v3.0.0 Add .tmux/plugins/tmux-sensible/.gitattributes Add .tmux/plugins/tmux-sensible/sensible.tmux Add .tmux/plugins/tmux/LICENSE Add .tmux/plugins/tmux/README.md Add .tmux/plugins/tmux/assets/frappe.webp Add .tmux/plugins/tmux/assets/latte.webp Add .tmux/plugins/tmux/assets/macchiato.webp Add .tmux/plugins/tmux/assets/mocha.webp Add .tmux/plugins/tmux/assets/preview.webp Add .tmux/plugins/tmux/catppuccin-frappe.tmuxtheme Add .tmux/plugins/tmux/catppuccin-latte.tmuxtheme Add .tmux/plugins/tmux/catppuccin-macchiato.tmuxtheme Add .tmux/plugins/tmux/catppuccin-mocha.tmuxtheme Add .tmux/plugins/tmux/.editorconfig Add .tmux/plugins/tmux/.git/HEAD Add .tmux/plugins/tmux/.git/config Add .tmux/plugins/tmux/.git/description Add .tmux/plugins/tmux/.git/hooks/applypatch-msg.sample Add .tmux/plugins/tmux/.git/hooks/commit-msg.sample Add .tmux/plugins/tmux/.git/hooks/fsmonitor-watchman.sample Add .tmux/plugins/tmux/.git/hooks/post-update.sample Add .tmux/plugins/tmux/.git/hooks/pre-applypatch.sample Add .tmux/plugins/tmux/.git/hooks/pre-commit.sample Add .tmux/plugins/tmux/.git/hooks/pre-merge-commit.sample Add .tmux/plugins/tmux/.git/hooks/pre-push.sample Add .tmux/plugins/tmux/.git/hooks/pre-rebase.sample Add .tmux/plugins/tmux/.git/hooks/pre-receive.sample Add .tmux/plugins/tmux/.git/hooks/prepare-commit-msg.sample Add .tmux/plugins/tmux/.git/hooks/push-to-checkout.sample Add .tmux/plugins/tmux/.git/hooks/sendemail-validate.sample Add .tmux/plugins/tmux/.git/hooks/update.sample Add .tmux/plugins/tmux/.git/index Add .tmux/plugins/tmux/.git/info/exclude Add .tmux/plugins/tmux/.git/logs/HEAD Add .tmux/plugins/tmux/.git/logs/refs/heads/main Add .tmux/plugins/tmux/.git/logs/refs/remotes/origin/HEAD Add .tmux/plugins/tmux/.git/objects/info/.keep Add .tmux/plugins/tmux/.git/objects/pack/pack-ca2499aaebdbbc41d6409686c32c5c7e0d6988c8.idx Add .tmux/plugins/tmux/.git/objects/pack/pack-ca2499aaebdbbc41d6409686c32c5c7e0d6988c8.pack Add .tmux/plugins/tmux/.git/objects/pack/pack-ca2499aaebdbbc41d6409686c32c5c7e0d6988c8.rev Add .tmux/plugins/tmux/.git/packed-refs Add .tmux/plugins/tmux/.git/refs/heads/main Add .tmux/plugins/tmux/.git/refs/remotes/origin/HEAD Add .tmux/plugins/tmux/.git/refs/tags/.keep Add .tmux/plugins/tmux/.gitignore Add .tmux/plugins/tmux/catppuccin.tmux Add .tmux/plugins/tpm/CHANGELOG.md Add .tmux/plugins/tpm/HOW_TO_PLUGIN.md Add .tmux/plugins/tpm/LICENSE.md Add .tmux/plugins/tpm/README.md Add .tmux/plugins/tpm/bin/clean_plugins Add .tmux/plugins/tpm/bin/install_plugins Add .tmux/plugins/tpm/bin/update_plugins Add .tmux/plugins/tpm/bindings/clean_plugins Add .tmux/plugins/tpm/bindings/install_plugins Add .tmux/plugins/tpm/bindings/update_plugins Add .tmux/plugins/tpm/docs/automatic_tpm_installation.md Add .tmux/plugins/tpm/docs/changing_plugins_install_dir.md Add .tmux/plugins/tpm/docs/how_to_create_plugin.md Add .tmux/plugins/tpm/docs/managing_plugins_via_cmd_line.md Add .tmux/plugins/tpm/docs/tpm_not_working.md Add .tmux/plugins/tpm/.git/HEAD Add .tmux/plugins/tpm/.git/config Add .tmux/plugins/tpm/.git/description Add .tmux/plugins/tpm/.git/hooks/applypatch-msg.sample Add .tmux/plugins/tpm/.git/hooks/commit-msg.sample Add .tmux/plugins/tpm/.git/hooks/fsmonitor-watchman.sample Add .tmux/plugins/tpm/.git/hooks/post-update.sample Add .tmux/plugins/tpm/.git/hooks/pre-applypatch.sample Add .tmux/plugins/tpm/.git/hooks/pre-commit.sample Add .tmux/plugins/tpm/.git/hooks/pre-merge-commit.sample Add .tmux/plugins/tpm/.git/hooks/pre-push.sample Add .tmux/plugins/tpm/.git/hooks/pre-rebase.sample Add .tmux/plugins/tpm/.git/hooks/pre-receive.sample Add .tmux/plugins/tpm/.git/hooks/prepare-commit-msg.sample Add .tmux/plugins/tpm/.git/hooks/push-to-checkout.sample Add .tmux/plugins/tpm/.git/hooks/update.sample Add .tmux/plugins/tpm/.git/index Add .tmux/plugins/tpm/.git/info/exclude Add .tmux/plugins/tpm/.git/logs/HEAD Add .tmux/plugins/tpm/.git/logs/refs/heads/master Add .tmux/plugins/tpm/.git/logs/refs/remotes/origin/HEAD Add .tmux/plugins/tpm/.git/objects/info/.keep Add .tmux/plugins/tpm/.git/objects/pack/pack-17625ffcf71a446997741831332005307218a33a.idx Add .tmux/plugins/tpm/.git/objects/pack/pack-17625ffcf71a446997741831332005307218a33a.pack Add .tmux/plugins/tpm/.git/packed-refs Add .tmux/plugins/tpm/.git/refs/heads/master Add .tmux/plugins/tpm/.git/refs/remotes/origin/HEAD Add .tmux/plugins/tpm/.git/refs/tags/.keep Add .tmux/plugins/tpm/.gitattributes Add .tmux/plugins/tpm/.gitignore Add .tmux/plugins/tpm/.gitmodules Add .tmux/plugins/tpm/.travis.yml Add .tmux/plugins/tpm/tpm Add .tmux/plugins/tpm/lib/tmux-test/.keep Add .tmux/plugins/tpm/scripts/check_tmux_version.sh Add .tmux/plugins/tpm/scripts/clean_plugins.sh Add .tmux/plugins/tpm/scripts/install_plugins.sh Add .tmux/plugins/tpm/scripts/source_plugins.sh Add .tmux/plugins/tpm/scripts/update_plugin.sh Add .tmux/plugins/tpm/scripts/update_plugin_prompt_handler.sh Add .tmux/plugins/tpm/scripts/helpers/plugin_functions.sh Add .tmux/plugins/tpm/scripts/helpers/shell_echo_functions.sh Add .tmux/plugins/tpm/scripts/helpers/tmux_echo_functions.sh Add .tmux/plugins/tpm/scripts/helpers/tmux_utils.sh Add .tmux/plugins/tpm/scripts/helpers/utility.sh Add .tmux/plugins/tpm/scripts/variables.sh Add .tmux/plugins/tpm/tests/expect_failed_plugin_download Add .tmux/plugins/tpm/tests/expect_successful_clean_plugins Add .tmux/plugins/tpm/tests/expect_successful_multiple_plugins_download Add .tmux/plugins/tpm/tests/expect_successful_plugin_download Add .tmux/plugins/tpm/tests/expect_successful_update_of_a_single_plugin Add .tmux/plugins/tpm/tests/expect_successful_update_of_all_plugins Add .tmux/plugins/tpm/tests/test_plugin_clean.sh Add .tmux/plugins/tpm/tests/test_plugin_installation.sh Add .tmux/plugins/tpm/tests/test_plugin_installation_legacy.sh Add .tmux/plugins/tpm/tests/test_plugin_sourcing.sh Add .tmux/plugins/tpm/tests/test_plugin_update.sh Add .tmux/plugins/tpm/tests/helpers/tpm.sh Add .tmux/plugins/vim-tmux-navigator/License.md Add .tmux/plugins/vim-tmux-navigator/README.md Add .tmux/plugins/vim-tmux-navigator/doc/tmux-navigator.txt Add .tmux/plugins/vim-tmux-navigator/.git/HEAD Add .tmux/plugins/vim-tmux-navigator/.git/config Add .tmux/plugins/vim-tmux-navigator/.git/description Add .tmux/plugins/vim-tmux-navigator/.git/hooks/applypatch-msg.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/commit-msg.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/fsmonitor-watchman.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/post-update.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/pre-applypatch.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/pre-commit.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/pre-merge-commit.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/pre-push.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/pre-rebase.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/pre-receive.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/prepare-commit-msg.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/push-to-checkout.sample Add .tmux/plugins/vim-tmux-navigator/.git/hooks/update.sample Add .tmux/plugins/vim-tmux-navigator/.git/index Add .tmux/plugins/vim-tmux-navigator/.git/info/exclude Add .tmux/plugins/vim-tmux-navigator/.git/logs/HEAD Add .tmux/plugins/vim-tmux-navigator/.git/logs/refs/heads/master Add .tmux/plugins/vim-tmux-navigator/.git/logs/refs/remotes/origin/HEAD Add .tmux/plugins/vim-tmux-navigator/.git/objects/info/.keep Add .tmux/plugins/vim-tmux-navigator/.git/objects/pack/pack-d18103c902c90ca8df5435292ec0cf5b50bd3683.idx Add .tmux/plugins/vim-tmux-navigator/.git/objects/pack/pack-d18103c902c90ca8df5435292ec0cf5b50bd3683.pack Add .tmux/plugins/vim-tmux-navigator/.git/packed-refs Add .tmux/plugins/vim-tmux-navigator/.git/refs/heads/master Add .tmux/plugins/vim-tmux-navigator/.git/refs/remotes/origin/HEAD Add .tmux/plugins/vim-tmux-navigator/.git/refs/tags/v1.0 Add .tmux/plugins/vim-tmux-navigator/.gitignore Add .tmux/plugins/vim-tmux-navigator/vim-tmux-navigator.tmux Add .tmux/plugins/vim-tmux-navigator/pattern-check Add .tmux/plugins/vim-tmux-navigator/plugin/tmux_navigator.vim Add revive.toml
This commit is contained in:
21
dot_tmux/plugins/vim-tmux-navigator/License.md
Normal file
21
dot_tmux/plugins/vim-tmux-navigator/License.md
Normal file
@@ -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.
|
305
dot_tmux/plugins/vim-tmux-navigator/README.md
Normal file
305
dot_tmux/plugins/vim-tmux-navigator/README.md
Normal file
@@ -0,0 +1,305 @@
|
||||
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|n?vim?x?)(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
|
||||
|
||||
nnoremap <silent> {Left-Mapping} :TmuxNavigateLeft<cr>
|
||||
nnoremap <silent> {Down-Mapping} :TmuxNavigateDown<cr>
|
||||
nnoremap <silent> {Up-Mapping} :TmuxNavigateUp<cr>
|
||||
nnoremap <silent> {Right-Mapping} :TmuxNavigateRight<cr>
|
||||
nnoremap <silent> {Previous-Mapping} :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 `nnoremap <silent> <c-h> :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
|
||||
|
||||
#### 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.
|
||||
|
||||
#### 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"
|
||||
```
|
||||
|
||||
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
|
||||
`\vn(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/
|
||||
|
||||
### 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
|
39
dot_tmux/plugins/vim-tmux-navigator/doc/tmux-navigator.txt
Normal file
39
dot_tmux/plugins/vim-tmux-navigator/doc/tmux-navigator.txt
Normal file
@@ -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
|
||||
|
||||
nnoremap <silent> {Left-mapping} :TmuxNavigateLeft<cr>
|
||||
nnoremap <silent> {Down-Mapping} :TmuxNavigateDown<cr>
|
||||
nnoremap <silent> {Up-Mapping} :TmuxNavigateUp<cr>
|
||||
nnoremap <silent> {Right-Mapping} :TmuxNavigateRight<cr>
|
||||
nnoremap <silent> {Previous-Mapping} :TmuxNavigatePrevious<cr>
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
1
dot_tmux/plugins/vim-tmux-navigator/dot_git/HEAD
Normal file
1
dot_tmux/plugins/vim-tmux-navigator/dot_git/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
15
dot_tmux/plugins/vim-tmux-navigator/dot_git/config
Normal file
15
dot_tmux/plugins/vim-tmux-navigator/dot_git/config
Normal file
@@ -0,0 +1,15 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
ignorecase = true
|
||||
precomposeunicode = 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
|
1
dot_tmux/plugins/vim-tmux-navigator/dot_git/description
Normal file
1
dot_tmux/plugins/vim-tmux-navigator/dot_git/description
Normal file
@@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
@@ -0,0 +1,15 @@
|
||||
#!/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 @@
|
||||
#!/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,173 @@
|
||||
#!/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.
|
||||
if (substr($last_update_token, 0, 1) eq "c") {
|
||||
$last_update_token = "\"$last_update_token\"";
|
||||
}
|
||||
my $query = <<" END";
|
||||
["query", "$git_work_tree", {
|
||||
"since": $last_update_token,
|
||||
"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 @@
|
||||
#!/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 @@
|
||||
#!/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 @@
|
||||
#!/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 @@
|
||||
#!/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 @@
|
||||
#!/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 @@
|
||||
#!/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 @@
|
||||
#!/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 @@
|
||||
#!/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 @@
|
||||
#!/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,128 @@
|
||||
#!/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
dot_tmux/plugins/vim-tmux-navigator/dot_git/index
Normal file
BIN
dot_tmux/plugins/vim-tmux-navigator/dot_git/index
Normal file
Binary file not shown.
6
dot_tmux/plugins/vim-tmux-navigator/dot_git/info/exclude
Normal file
6
dot_tmux/plugins/vim-tmux-navigator/dot_git/info/exclude
Normal file
@@ -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]
|
||||
# *~
|
1
dot_tmux/plugins/vim-tmux-navigator/dot_git/logs/HEAD
Normal file
1
dot_tmux/plugins/vim-tmux-navigator/dot_git/logs/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 9ca5bfe5bd274051b5dd796cc150348afc993b80 Kasper J. Hermansen <contact@kjuulh.io> 1657609203 +0200 clone: from https://github.com/christoomey/vim-tmux-navigator
|
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 9ca5bfe5bd274051b5dd796cc150348afc993b80 Kasper J. Hermansen <contact@kjuulh.io> 1657609203 +0200 clone: from https://github.com/christoomey/vim-tmux-navigator
|
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 9ca5bfe5bd274051b5dd796cc150348afc993b80 Kasper J. Hermansen <contact@kjuulh.io> 1657609203 +0200 clone: from https://github.com/christoomey/vim-tmux-navigator
|
Binary file not shown.
Binary file not shown.
2
dot_tmux/plugins/vim-tmux-navigator/dot_git/packed-refs
Normal file
2
dot_tmux/plugins/vim-tmux-navigator/dot_git/packed-refs
Normal file
@@ -0,0 +1,2 @@
|
||||
# pack-refs with: peeled fully-peeled sorted
|
||||
9ca5bfe5bd274051b5dd796cc150348afc993b80 refs/remotes/origin/master
|
@@ -0,0 +1 @@
|
||||
9ca5bfe5bd274051b5dd796cc150348afc993b80
|
@@ -0,0 +1 @@
|
||||
ref: refs/remotes/origin/master
|
@@ -0,0 +1 @@
|
||||
22734100c02990ff090f3544319620ef3f516dea
|
1
dot_tmux/plugins/vim-tmux-navigator/dot_gitignore
Normal file
1
dot_tmux/plugins/vim-tmux-navigator/dot_gitignore
Normal file
@@ -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|n?vim?x?)(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
|
42
dot_tmux/plugins/vim-tmux-navigator/pattern-check
Normal file
42
dot_tmux/plugins/vim-tmux-navigator/pattern-check
Normal file
@@ -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|n?vim?x?)(diff)?$'
|
||||
match_tests=(vim Vim VIM vimdiff /usr/local/bin/vim vi gvim view gview nvim vimx)
|
||||
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
|
131
dot_tmux/plugins/vim-tmux-navigator/plugin/tmux_navigator.vim
Normal file
131
dot_tmux/plugins/vim-tmux-navigator/plugin/tmux_navigator.vim
Normal file
@@ -0,0 +1,131 @@
|
||||
" 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)
|
||||
nnoremap <silent> <c-h> :TmuxNavigateLeft<cr>
|
||||
nnoremap <silent> <c-j> :TmuxNavigateDown<cr>
|
||||
nnoremap <silent> <c-k> :TmuxNavigateUp<cr>
|
||||
nnoremap <silent> <c-l> :TmuxNavigateRight<cr>
|
||||
nnoremap <silent> <c-\> :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
|
||||
|
||||
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
|
||||
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
|
Reference in New Issue
Block a user