Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid auto jump after selection & search outputs #118

Closed
changkun opened this issue Nov 22, 2017 · 12 comments
Closed

Avoid auto jump after selection & search outputs #118

changkun opened this issue Nov 22, 2017 · 12 comments

Comments

@changkun
Copy link

Very grateful for your nice configs of tmux, however I am facing two issues here:

  1. In mouse mode, when I select text for previous output text, then automatically jump to the bottom. Very annoying here, what should I do? How can I only enable Escape key for return to bottom?

  2. I want to search output results, how can I do that?

@gpakosz
Copy link
Owner

gpakosz commented Nov 22, 2017

Hello @changkun

  1. is tmux's default behavior:
$ tmux -f /dev/null
$ tmux list-keys | grep copy-selection
bind-key    -T copy-mode    C-w               send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode    MouseDragEnd1Pane send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode    M-w               send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode-vi C-j               send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode-vi Enter             send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection-and-cancel

I think you can edit your ~/.tmux.conf.local copy and redefine the default bindings to use copy-selection instead of copy-selection-and-cancel:

bind-key    -T copy-mode    C-w               send-keys -X copy-selection
bind-key    -T copy-mode    MouseDragEnd1Pane send-keys -X copy-selection
bind-key    -T copy-mode    M-w               send-keys -X copy-selection
bind-key    -T copy-mode-vi C-j               send-keys -X copy-selection
bind-key    -T copy-mode-vi Enter             send-keys -X copy-selection
bind-key    -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection
  1. I'm not sure I understand the question

@changkun
Copy link
Author

changkun commented Nov 22, 2017

Hi @gpakosz , thanks for you quickly response. Question 1 works for me 👍

Maybe I need to rephrase my second question.

What I mean here is, for a tmux window, when I enable mouse mode, I am able to scroll up for retrieve the console output history. for example, in vim, I can type / at command mode with text for searching. Thus, how can I search the historical text in this tmux configuration?

@gpakosz
Copy link
Owner

gpakosz commented Nov 22, 2017

@changkun My configuration doesn't change search bindings. Enter copy mode by either scrolling up when mouse mode is on or by hitting <prefix> + Enter and when you're in copy mode use the / key just like in vim.

Hope that helps

@changkun
Copy link
Author

@gpakosz ..Here is the point, I tried them before I create this issue, <prefix>+Enter does get in to copy mode, but after that / and any other key doesn't works

@gpakosz
Copy link
Owner

gpakosz commented Nov 22, 2017

I don't know what you did to your configuration then...

$ tmux list-keys | grep 'search down'
bind-key    -T copy-mode    C-s               command-prompt -i -I "#{pane_search_string}" -p "(search down)" "send -X search-forward-incremental \"%%%\""
bind-key    -T copy-mode-vi /                 command-prompt -p "(search down)" "send -X search-forward \"%%%\""

Please make sure you whatever you suspect doesn't work with this configuration works with stock tmux settings. You can do so by launching tmux -f /dev/null which skips loading ~/.tmux.conf

@gpakosz
Copy link
Owner

gpakosz commented Nov 22, 2017

Oh right I think I get it. If you want vi like behavior you have to export EDITOR=vim from e.g. your ~/.bashrc or ~/.bash_profile.

From tmux manual:

status-keys [vi | emacs]
        Use vi or emacs-style key bindings in the status line, for example at the command prompt.  The default is emacs, unless the VISUAL or
        EDITOR environment variables are set and contain the string `vi'.

@gpakosz
Copy link
Owner

gpakosz commented Nov 22, 2017

And I also mention it in README.md

If you're a Vim user, setting the $EDITOR environment variable to vim will enable and further customize the vi-style key bindings (see tmux manual).

@changkun
Copy link
Author

@gpakosz sadly doesn't work.. I have enabled $EDITOR as you mentioned in README...

is it because I use mvim as alias for vim?

qq20171122-181022

@gpakosz
Copy link
Owner

gpakosz commented Nov 22, 2017

Did you relaunch tmux after having exported $EDITOR?

You should see:

$ tmux show -wg mode-keys
mode-keys vi
$ tmux show -g status-keys
status-keys vi

If for some reason exporting $EDITOR doesn't work for you (while it really should), you can uncomment the lines in your ~/.tmux.conf.local copy:

# force Vi mode
#   really you should export VISUAL or EDITOR environment variable, see manual
#set -g status-keys vi
#set -g mode-keys vi

@changkun
Copy link
Author

changkun commented Nov 22, 2017

@gpakosz Thank you so much! I never tried relaunch tmux, only <prefix-r> for reload... now finally works 👍 Really appreciate your help

@gpakosz
Copy link
Owner

gpakosz commented Nov 22, 2017

You're welcome. Spread the tmux ❤️

@changkun
Copy link
Author

@gpakosz always recommend your nice configuration to my friends ❤️

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

No branches or pull requests

2 participants