Skip to content

Instantly share code, notes, and snippets.

@tchisama
Last active April 11, 2024 22:15
Show Gist options
  • Save tchisama/10b1a8127da6fc63e136bb15e64f434b to your computer and use it in GitHub Desktop.
Save tchisama/10b1a8127da6fc63e136bb15e64f434b to your computer and use it in GitHub Desktop.

Revisions

  1. tchisama revised this gist Apr 11, 2024. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -84,5 +84,3 @@ set -g @dracula-military-time true


    run '~/.tmux/plugins/tpm/tpm'


  2. tchisama created this gist Mar 28, 2024.
    88 changes: 88 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,88 @@
    unbind r
    bind r source-file ~/.tmux.conf

    set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.tmux/plugins/'

    set -g prefix C-s
    set -g mouse on


    bind-key h select-pane -L
    bind-key j select-pane -D
    bind-key l select-pane -R
    bind-key k select-pane -U


    unbind %
    bind / split-window -h

    unbind '"'
    bind - split-window -v
    set-window-option -g mode-keys vi

    bind-key -T copy-mode-vi 'v' send -X begin-selection # start selecting text with "v"
    bind-key -T copy-mode-vi 'y' send -X copy-selection # copy text with "y"

    unbind -T copy-mode-vi MouseDragEnd1Pane # don't exit copy mode when dragging with mouse

    # remove delay for exiting insert mode with ESC in Neovim
    set -sg escape-time 10

    # tpm plugin
    set -g @plugin 'tmux-plugins/tpm'

    # list of tmux plugins
    # set -g @plugin 'christoomey/vim-tmux-navigator'
    # THIS IS WHERE THE NEW CODE FOR NAVIGATION IS
    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 -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+'

    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
    bind-key -T copy-mode-vi 'C-Space' select-pane -t:.+










    # plugins
    set -g @tpm_plugins ' \
    tmux-plugins/tpm \
    tmux-plugins/tmux-sensible \
    dracula/tmux \
    '

    # dracula customizations
    set -g @plugin ''

    set -g @dracula-plugins "battery weather time"
    set -g @dracula-show-powerline true
    set -g @dracula-show-fahrenheit false
    set -g @dracula-military-time true


    run '~/.tmux/plugins/tpm/tpm'