woot
This commit is contained in:
@ -130,8 +130,10 @@ put_cache_val() {
|
||||
val="${*:2}"
|
||||
tmpdir="$(get_tmp_dir)"
|
||||
[ ! -d "$tmpdir" ] && mkdir -p "$tmpdir" && chmod 0700 "$tmpdir"
|
||||
get_time >"$tmpdir/$key"
|
||||
echo -n "$val" >>"$tmpdir/$key"
|
||||
(
|
||||
get_time
|
||||
echo -n "$val"
|
||||
) >"$tmpdir/$key"
|
||||
echo -n "$val"
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
### master
|
||||
|
||||
### v3.1.0, 2023-01-03
|
||||
- upgrade to new version of `tmux-test`
|
||||
- bug: when using `emacs` copy mode, Enter does not quit screen after tpm
|
||||
installation/update. Fix by making `Escape` the key for emacs mode.
|
||||
@ -9,6 +11,7 @@
|
||||
line endings - helps with misconfigured git on windows/cygwin
|
||||
- readme update: announce Cygwin support
|
||||
- un-deprecate old plugin definition syntax: `set -g @tpm_plugins`
|
||||
- More stuff, check `git log`.
|
||||
|
||||
### v3.0.0, 2015-08-03
|
||||
- refactor `shared_set_tpm_path_constant` function
|
||||
|
@ -15,7 +15,7 @@ Requirements: `tmux` version 1.9 (or higher), `git`, `bash`.
|
||||
Clone TPM:
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
||||
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
||||
```
|
||||
|
||||
Put this at the bottom of `~/.tmux.conf` (`$XDG_CONFIG_HOME/tmux/tmux.conf`
|
||||
@ -40,7 +40,7 @@ Reload TMUX environment so TPM is sourced:
|
||||
|
||||
```bash
|
||||
# type this in terminal if tmux is already running
|
||||
$ tmux source ~/.tmux.conf
|
||||
tmux source ~/.tmux.conf
|
||||
```
|
||||
|
||||
That's it!
|
||||
@ -93,7 +93,7 @@ Run tests with:
|
||||
|
||||
```bash
|
||||
# within project directory
|
||||
$ ./run_tests
|
||||
./run_tests
|
||||
```
|
||||
|
||||
### License
|
||||
|
@ -85,12 +85,18 @@ find ~/.tmux -type d -name '.git*' -prune -o -type f -print0 | xargs -0 dos2unix
|
||||
|
||||
Related: [issue #67](https://github.com/tmux-plugins/tpm/issues/67)
|
||||
|
||||
This problem is because tmux's `run-shell` command runs a shell which doesn't read from user configs, thus tmux installed in `/usr/local/bin` will not be found.
|
||||
This problem is because tmux's `run-shell` command runs a shell which doesn't read from user configs, thus tmux installed in a brew prefix (e.g. `/usr/local/bin`) will not be found.
|
||||
|
||||
The solution is to insert the following line:
|
||||
The solution is to find your brew prefix
|
||||
|
||||
```sh
|
||||
> echo "$(brew --prefix)/bin"
|
||||
/opt/homebrew/bin
|
||||
```
|
||||
set-environment -g PATH "/usr/local/bin:/bin:/usr/bin"
|
||||
|
||||
And prepend it to the `PATH` environment variable
|
||||
```
|
||||
set-environment -g PATH "/opt/homebrew/bin:/bin:/usr/bin"
|
||||
```
|
||||
|
||||
before any `run-shell`/`run` commands in `~/.tmux.conf`.
|
||||
|
@ -26,10 +26,15 @@ pull_changes() {
|
||||
}
|
||||
|
||||
update() {
|
||||
local plugin="$1"
|
||||
$(pull_changes "$plugin" > /dev/null 2>&1) &&
|
||||
echo_ok " \"$plugin\" update success" ||
|
||||
local plugin="$1" output
|
||||
output=$(pull_changes "$plugin" 2>&1)
|
||||
if (( $? == 0 )); then
|
||||
echo_ok " \"$plugin\" update success"
|
||||
echo_ok "$(echo "$output" | sed -e 's/^/ | /')"
|
||||
else
|
||||
echo_err " \"$plugin\" update fail"
|
||||
echo_err "$(echo "$output" | sed -e 's/^/ | /')"
|
||||
fi
|
||||
}
|
||||
|
||||
update_all() {
|
||||
|
@ -66,7 +66,7 @@ Add the following to your `~/.tmux.conf` file:
|
||||
# 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)?$'"
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?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'
|
||||
@ -199,6 +199,22 @@ 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 tru to move past the edge of the screen, tmux/vim will
|
||||
@ -210,11 +226,12 @@ For vim, you only need to enable this option:
|
||||
let g:tmux_navigator_no_wrap = 1
|
||||
```
|
||||
|
||||
Tmux doesn't haave an option, so whatever key bindings you have need to be set
|
||||
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|n?vim?x?)(diff)?$'"
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(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 } }
|
||||
@ -256,6 +273,56 @@ 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
|
||||
---------------
|
||||
|
||||
@ -316,6 +383,34 @@ 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
|
||||
|
@ -11,8 +11,8 @@ 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)
|
||||
vim_pattern='(^|\/)g?(view|l?n?vim?x?)(diff)?$'
|
||||
match_tests=(vim Vim VIM vimdiff lvim /usr/local/bin/vim vi gvim view gview nvim vimx)
|
||||
no_match_tests=( /Users/christoomey/.vim/thing /usr/local/bin/start-vim )
|
||||
|
||||
display_matches() {
|
||||
|
@ -3,7 +3,7 @@
|
||||
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)?$'"
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?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"
|
||||
|
Reference in New Issue
Block a user