fcsonline / tmux-thumbs

A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator
MIT License
910 stars 61 forks source link

tmux 3.1c support #83

Closed DanielRivasMD closed 3 years ago

DanielRivasMD commented 3 years ago

Hi. Love the idea of this plugin. I installed the standalone version and works great. I tried to install it within tmux but I am uncertain whether it is working. running version 3.1c. How could I check thumbs installation within tmux. Much appreciated.

fcsonline commented 3 years ago

Can you share your tmux configuration?

DanielRivasMD commented 3 years ago

Sure. It is a bit long, but the plugins are at the bottom.

# ==========================
# ===  General settings  ===
# ==========================

set -g default-terminal "screen-256color"
# set -g default-terminal "xterm-256color"
# set-option -ga terminal-overrides ",xterm*:Tc"
set -g history-limit 20000
set -g buffer-limit 20
set -sg escape-time 0
set -g display-time 1500
set -g remain-on-exit off
set -g repeat-time 300
setw -g allow-rename off
setw -g automatic-rename off
setw -g aggressive-resize on

# force xterm keys
setw -g xterm-keys on

# Change prefix key to C-q, easier to type. Used to be C-a, same to "screen"
unbind C-b
set -g prefix C-q

# Set parent terminal title to reflect current window in tmux session
set -g set-titles on
set -g set-titles-string "#I:#W"

# Start index of window/pane with 1, because we're humans, not computers
set -g base-index 1
setw -g pane-base-index 1

# Enable mouse support
set -g mouse on

# ==========================
# ===   Key bindings     ===
# ==========================

# Unbind default key bindings, we're going to override
unbind "\$"    # rename-session
unbind ,       # rename-window
unbind %       # split-window -h
unbind '"'     # split-window
unbind '}'     # swap-pane -D
unbind '{'     # swap-pane -U
unbind !       # break-pane
unbind Space
unbind [       # paste-buffer
unbind ]       # paste-buffer
unbind (       # switch to previous client
unbind )       # switch to next client
unbind "'"     # select-window
unbind n       # next-window
unbind p       # previous-window
unbind l       # last-window
unbind M-n     # next window with alert
unbind M-p     # previous window with alert
unbind E       # spread panes out evenly
unbind DC      # reset so the visible part of the window follows the cursor
unbind PPage   # enter copy mode and scroll up
unbind o       # focus thru panes
unbind &       # kill-window
unbind "#"     # list-buffer
unbind =       # choose-buffer
unbind M-Up    # resize 5 rows up
unbind M-Down  # resize 5 rows down
unbind M-Right # resize 5 rows right
unbind M-Left  # resize 5 rows left
unbind M-1     # Set the even-horizontal layout
unbind M-2     # Set the even-vertical layout
unbind M-3     # Set the main-horizontal layout
unbind M-4     # Set the main-vertical layout
unbind M-5     # Select the tiled layout
unbind M-o     # Rotate through the panes in reverse
unbind C-Up    # Resize the pane up
unbind C-Down  # Resize the pane down
unbind C-Left  # Resize the pane left
unbind C-Right # Resize the pane right
unbind S-Up    # Move the visible part of the window up
unbind S-Down  # Move the visible part of the window down
unbind S-Left  # Move the visible part of the window left
unbind S-Right # Move the visible part of the window right

# Edit configuration and reload
bind C-e new-window -n 'tmux.conf' "sh -c '\${EDITOR:-vim} ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display \"Config reloaded\"'"

# Reload tmux configuration
bind C-r source-file ~/.tmux.conf \; display "Config reloaded"

# New window and retain cwd
bind c new-window -c "#{pane_current_path}"
bind C new-window

# # NOTE: impractical for sessions
# # Prompt to rename window right after it's created
# set-hook -g after-new-window 'command-prompt -I "#{window_name}" "rename-window '%%'"'

# Rename session and window
bind r command-prompt -I "#{window_name}" "rename-window '%%'"
bind R command-prompt -I "#{session_name}" "rename-session '%%'"

# Split panes
bind -n C-\\ split-window -h -c "#{pane_current_path}"
bind -n C-_ split-window -v -c "#{pane_current_path}"

# Break panes
bind \\ break-pane

# Select pane
bind -n C-Left select-pane -L
bind -n C-Right select-pane -R
bind -n C-Down select-pane -D
bind -n C-Up select-pane -U

# Select pane & zoom
bind Left select-pane -L \; resize-pane -Z
bind Right select-pane -R \; resize-pane -Z
bind Down select-pane -D \; resize-pane -Z
bind Up select-pane -U \; resize-pane -Z
bind -n C-Space resize-pane -Z

# Select windows
bind -n C-M-Left previous-window
bind -n C-M-Right next-window

# Select other clients
bind C-q switch-client -l

# Swap windows
bind-key -n C-M-[ swap-window -t -1\; select-window -t -1
bind-key -n C-M-] swap-window -t +1\; select-window -t +1

# Kill pane/window/session shortcuts
bind x kill-pane
bind X kill-window
bind C-x confirm-before -p "kill other windows? (y/n)" "kill-window -a"
bind Q confirm-before -p "kill-session #S? (y/n)" kill-session

# Merge session with another one (e.g. move all windows)
# If you use adhoc 1-window sessions, and you want to preserve session upon exit
# but don't want to create a lot of small unnamed 1-window sessions around
# move all windows from current session to main named one (dev, work, etc)
bind C-u command-prompt -p "Session to merge with: " \
  "run-shell 'yes | head -n #{session_windows} | xargs -I {} -n 1 tmux movew -t %%'"

# Detach from session
bind d detach
bind D if -F '#{session_many_attached}' \
  'confirm-before -p "Detach other clients? (y/n)" "detach -a"' \
  'display "Session has only 1 client attached"'

# ================================================
# ===     Copy mode, scroll and clipboard      ===
# ================================================

set -g @copy_use_osc52_fallback on

# Prefer vi style key table
setw -g mode-keys vi

bind p paste-buffer
bind C-p choose-buffer

# trigger copy mode by
bind -n C-M-Up copy-mode

# Scroll up/down by 1 line, half screen, whole screen
bind -T copy-mode-vi k           send-keys -X halfpage-up
bind -T copy-mode-vi j           send-keys -X halfpage-down
bind -T copy-mode-vi K           send-keys -X page-up
bind -T copy-mode-vi J           send-keys -X page-down

# wrap default shell in reattach-to-user-namespace if available
# there is some hack with `exec & reattach`, credits to "https://github.com/gpakosz/.tmux"
# don't really understand how it works, but at least window are not renamed to "reattach-to-user-namespace"
if -b "command -v reattach-to-user-namespace > /dev/null 2>&1" \
  "run 'tmux set -g default-command \"exec $(tmux show -gv default-shell) 2>/dev/null & reattach-to-user-namespace -l $(tmux show -gv default-shell)\"'"

yank="~/.archive/ianus/tmux/yank.sh"

# Copy selected text
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "$yank"
bind -T copy-mode-vi y send-keys -X copy-line \; run "tmux save-buffer - | $yank"
bind-key -T copy-mode-vi d send-keys -X copy-end-of-line \; run "tmux save-buffer - | $yank"
bind-key -T copy-mode-vi a send-keys -X append-selection-and-cancel \; run "tmux save-buffer - | $yank"

# Copy selection on drag end event, but do not cancel copy mode and do not clear selection
# clear select on subsequence mouse click
bind -T copy-mode-vi MouseDragEnd1Pane \
  send-keys -X copy-pipe "$yank"
bind -T copy-mode-vi MouseDown1Pane select-pane \;\
  send-keys -X clear-selection

# iTerm2 works with clipboard out of the box, set-clipboard already set to "external"
# tmux show-options -g -s set-clipboard
# set-clipboard on|external

# =====================================
# ===        Renew environment      ===
# =====================================

set -g update-environment \
  "DISPLAY\
  SSH_ASKPASS\
  SSH_AUTH_SOCK\
  SSH_AGENT_PID\
  SSH_CONNECTION\
  SSH_TTY\
  WINDOWID\
  XAUTHORITY"

bind '$' run "~/.archive/ianus/tmux/renew_env.sh"

# =====================================
# ===           Theme               ===
# =====================================

# Feel free to NOT use this variables at all (remove, rename)
# this are named colors, just for convenience
color_darkgray="colour236"
color_teal="colour117"
color_green="colour73"
color_purple="colour171"
color_yellow="colour220"
color_red="colour160"
color_black="colour232"
color_white="white"

# This is a theme CONTRACT, you are required to define variables below
# Change values, but not remove/rename variables itself
color_dark="$color_black"
color_light="$color_white"
color_session_text="$color_purple"
color_status_text="colour245"
color_main="$color_darkgray"
color_secondary="$color_teal"
color_level_ok="$color_green"
color_level_warn="$color_yellow"
color_level_stress="$color_red"
color_window_off_indicator="colour088"
color_window_off_status_bg="colour238"
color_window_off_status_current_bg="colour254"

# =====================================
# ===    Appearence and status bar  ===
# ======================================

set -g mode-style "fg=default,bg=$color_main"

# command line style
set -g message-style "fg=$color_level_ok,bg=$color_dark"

# status line style
set -g status-style "fg=$color_status_text,bg=$color_dark"

# window segments in status line
set -g window-status-separator ""
separator_powerline_left=""
separator_powerline_right=""

# setw -g window-status-style "fg=$color_status_text,bg=$color_dark"
setw -g window-status-format " #I:#W "
setw -g window-status-current-style "fg=$color_secondary,bold,bg=$color_main"
setw -g window-status-current-format "#[fg=$color_dark,bg=$color_main]$separator_powerline_right#[default] #I:#W# #[fg=$color_main,bg=$color_dark]$separator_powerline_right#[default]"

# when window has monitoring notification
setw -g window-status-activity-style "fg=$color_main"

# outline for active pane
setw -g pane-active-border-style "fg=$color_main"

# general status bar settings
set -g status on
set -g status-interval 5
set -g status-position top
set -g status-justify left
set -g status-right-length 100

# define widgets we're going to use in status bar
# note, that this is not the complete list, some of them are loaded from plugins
wg_session="#[fg=$color_session_text] #S #[default]"
wg_battery="#{battery_status_fg} #{battery_icon} #{battery_percentage}"
wg_date="#[fg=$color_secondary]%a %d %h %H:%M#[default]"

wg_user_host="#[fg=$color_secondary]#(whoami)#[default]@#H"
wg_is_zoomed="#[fg=$color_dark,bg=$color_secondary]#{?window_zoomed_flag,[Z],}#[default]"
wg_is_keys_off="#[fg=$color_light,bg=$color_window_off_indicator]#([ $(tmux show-option -qv key-table) = 'off' ])#[default]"

set -g status-left "$wg_battery "
set -g status-right "#{prefix_highlight} $wg_is_zoomed | $wg_session | #{sysstat_cpu} | #{sysstat_mem} | $wg_user_host | $wg_date #{online_status} "

# DATE FORMAT
# %a = Short date, Sun
# %A = Long date, Sunday
# %b = Short Month, Feb
# %B = Long Month, February
# %d = Day of the month
# %D = Date such as %m/%d/%y
# %H = Hour in 24 hour format (00..23)
# %I = Hour in 12 hour format (01..12) (this can be used with %p to append Am or PM)
# %j = Day of the year
# %m = Month in number format (01..12)
# %M = Minute (00..59)
# %p = Locale either AM or PM
# %S = Second
# %u = Day of the week
# %V = Week number of year with Monday as first day of week (01..53)
# %Y = Year
# %z = Numeric timezone (e.g., -0400) or %Z with timezone abbreviation.

# online and offline icon for tmux-online-status
set -g @online_icon "#[fg=$color_level_ok]#[default]"
set -g @offline_icon "#[fg=$color_level_stress]#[default]"

# Configure view templates for tmux-plugin-sysstat "MEM" and "CPU" widget
set -g @sysstat_mem_view_tmpl 'MEM:#[fg=#{mem.color}]#{mem.pused}#[default] #{mem.used}'

# Configure colors for tmux-plugin-sysstat "MEM" and "CPU" widget
set -g @sysstat_cpu_color_low "$color_level_ok"
set -g @sysstat_cpu_color_medium "$color_level_warn"
set -g @sysstat_cpu_color_stress "$color_level_stress"

set -g @sysstat_mem_color_low "$color_level_ok"
set -g @sysstat_mem_color_medium "$color_level_warn"
set -g @sysstat_mem_color_stress "$color_level_stress"

set -g @sysstat_swap_color_low "$color_level_ok"
set -g @sysstat_swap_color_medium "$color_level_warn"
set -g @sysstat_swap_color_stress "$color_level_stress"

# Configure tmux-battery widget colors
set -g @batt_color_full_charge "#[fg=$color_level_ok]"
set -g @batt_color_high_charge "#[fg=$color_level_ok]"
set -g @batt_color_medium_charge "#[fg=$color_level_warn]"
set -g @batt_color_low_charge "#[fg=$color_level_stress]"

# Configure tmux-prefix-highlight colors
set -g @prefix_highlight_output_prefix '['
set -g @prefix_highlight_output_suffix ']'
set -g @prefix_highlight_fg "$color_dark"
set -g @prefix_highlight_bg "$color_secondary"
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_copy_mode_attr "fg=$color_dark,bg=$color_secondary"

# ============================
# ===       Plugins        ===
# ============================

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'tmux-plugins/tmux-sidebar'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'samoshkin/tmux-plugin-sysstat'
set -g @plugin 'danyim/tmux-remote'
set -g @plugin 'fcsonline/tmux-thumbs'

# Plugin properties
set -g @sidebar-tree 't'
set -g @sidebar-tree-focus 'T'
set -g @sidebar-tree-command 'tree -C'

bind-key v next-layout
bind-key -T copy-mode-vi v send-keys -X begin-selection

set -g @thumbs-key "Space"

set -g @remote-toggle-key C-M-Down

# ==============================================

# Run all plugins' scripts
run '~/.tmux/plugins/tpm/tpm'

run-shell ~/.tmux/plugins/tmux-thumbs/tmux-thumbs.tmux

# ==============================================
fcsonline commented 3 years ago

Sometimes to the compilation of the binary with Rust takes some time. Can you check if you have the binary in the plugin folder?

DanielRivasMD commented 3 years ago

There are two binaries at $HOME/.tmux/plugins/tmux-thumbs/target/release, thumbs and tmux-thumbs. I guess these are the ones supposed to be triggered.

DanielRivasMD commented 3 years ago

So I saw that tmux-thumbs.tmux at line 12 defines BINARY="${CURRENT_DIR}/target/release/thumbs" not tmux-thumbs. Could this be the problem? Not calling the correct binary?

DanielRivasMD commented 3 years ago

It seems it had something to do with my tmux session. I restarted the computer and worked fine. Sorry for bothering. Cheers

fcsonline commented 3 years ago

Nice! thumbs is the standalone binary. tmux-thumbs is the required binary that orchestrates the communication between tmux and thumbs.