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

Nested if-shell breaks because of quotes working #573

Closed
rahul0x24 opened this issue Oct 9, 2016 · 3 comments
Closed

Nested if-shell breaks because of quotes working #573

rahul0x24 opened this issue Oct 9, 2016 · 3 comments

Comments

@rahul0x24
Copy link

rahul0x24 commented Oct 9, 2016

I have the following code in my tmux.conf and it breaks

# 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 -n WheelUpPane if-shell "$is_vim" "" "if -F -t = '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= "#{pane_in_mode}" "send-keys -M" "copy-mode -e"'"

But the following works fine maybe because its first level of nesting

bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"

I know the problem is because of second nesting of the quotes (") & ('). Could you tell me some work around to achieve this thing.

@nicm
Copy link
Member

nicm commented Oct 10, 2016

Did you try escaping the inner quotes like "?

On Sun, Oct 09, 2016 at 03:27:44PM -0700, Rahul Katariya wrote:

I have the following code in my tmux.conf

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 -n WheelUpPane if-shell "$is_vim" "" "if -F -t = '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= "#{pane_in_mode}" "send-keys -M" "copy-mode -e"'"

But the following works fine maybe because its first level of nesting

bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"

I know the problem is because of second nesting of the quotes (") & (').
Could you tell me some work around to achieve this thing.

--
You are receiving this because you are subscribed to this thread.
Reply to this email directly, [1]view it on GitHub, or [2]mute the thread.

Reverse link: [3]unknown

References

Visible links

  1. Nested if-shell breaks because of quotes working  #573
  2. https://github.com/notifications/unsubscribe-auth/AASkc2qZUw4Hx0JzG3EaG0cCGULEPvoJks5qyWpggaJpZM4KSIhn
  3. Nested if-shell breaks because of quotes working  #573

@rahul0x24
Copy link
Author

Thanks that worked.

And I found a better solution in one of the tmux closed issues #168 which does exactly what I wanted to achieve.

# Check if copy-mode or any mouse flags, then send mouse events
# or check if we're in alternate screen end send navigation keys (up, down)
bind -n WheelUpPane if-shell -Ft= '#{?pane_in_mode,1,#{mouse_any_flag}}' \
        'send -Mt=' 'if-shell -Ft= "#{alternate_on}" \
        "send -t= Up" "copy-mode -et="'
bind -n WheelDownPane if-shell -Ft = '#{?pane_in_mode,1,#{mouse_any_flag}}' \
        'send -Mt=' 'if-shell -Ft= "#{alternate_on}" \
        "send -t= Down" "send -Mt="'

@lock
Copy link

lock bot commented Feb 16, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants