Skip to content

Instantly share code, notes, and snippets.

@amitavaghosh1
Last active August 11, 2022 00:22
Show Gist options
  • Save amitavaghosh1/6a74296b33a98941b301bfbbabd2d59b to your computer and use it in GitHub Desktop.
Save amitavaghosh1/6a74296b33a98941b301bfbbabd2d59b to your computer and use it in GitHub Desktop.
function camelcase
perl -pe 's#(_|^)(.)#\u$2#g'
end
function snakecase
perl -pe 's#([A-Z])#_\L$1#g' | perl -pe 's#^_##'
end
unbind C-b
set -g prefix C-z
bind C-z send-prefix
set-option -g default-shell /usr/local/bin/fish
# toogle last window by hitting again C-f
bind-key C-z last-window
# if multiple clients are attached to the same window, maximize it to the
# bigger one
# set-window-option -g aggressive-resize
# Start windows and pane numbering with index 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
# re-number windows when one is closed
# set -g renumber-windows on
# word separators for automatic word selection
setw -g word-separators ' @"=()[]_-:,.'
setw -ag word-separators "'"
# Show times longer than supposed
# set -g display-panes-time 2000
# tmux messages are displayed for 4 seconds
# set -g display-time 4000
# {n}vim compability
set -g default-terminal "screen-256color"
# Split horiziontal and vertical splits, instead of % and "
# Also open them in the same directory
bind-key v split-window -h -c '#{pane_current_path}'
bind-key s split-window -v -c '#{pane_current_path}'
# Pressing Ctrl+Shift+Left (will move the current window to the left. Similarly
# right. No need to use the modifier (C-b).
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
bind-key -T root S-Left previous-window
bind-key -T root S-Right next-window
# Source file
unbind r
bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!"
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Update default binding of `Enter` and `Space to also use copy-pipe
unbind -T copy-mode-vi Enter
unbind -T copy-mode-vi Space
bind-key -T edit-mode-vi Up send-keys -X history-up
bind-key -T edit-mode-vi Down send-keys -X history-down
# setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
# copy text with `y` in copy mode
# bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel\; run "tmux save -|pbcopy >/dev/null 2>&1"
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# copy text with mouse selection without pressing any key
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel\; run "tmux save -|pbcopy >/dev/null 2>&1"
# bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel
# focus events enabled for terminals that support them
# set -g focus-events on
# Sync panes (Send input to all panes in the window). When enabled, pane
# borders become red as an indication.
bind C-s if -F '#{pane_synchronized}' \
'setw synchronize-panes off; \
setw pane-active-border-style fg=colour63,bg=default; \
setw pane-border-format " #P "' \
'setw synchronize-panes on; \
setw pane-active-border-style fg=red; \
setw pane-border-format " #P - Pane Synchronization ON "'
# Faster command sequence
set -s escape-time 0
# Have a very large history
set -g history-limit 10000
# Mouse mode on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set -g mouse on
# Set title
set -g set-titles on
set -g set-titles-string "#T"
# Equally resize all panes
bind-key = select-layout even-horizontal
bind-key | select-layout even-vertical
# Resize panes
bind-key J resize-pane -D 10
bind-key K resize-pane -U 10
bind-key H resize-pane -L 10
bind-key L resize-pane -R 10
# Select panes
# NOTE(arslan): See to prevent cycling https://github.com/tmux/tmux/issues/1158
bind-key j select-pane -D
bind-key k select-pane -U
bind-key h select-pane -L
bind-key l select-pane -R
# Disable confirm before killing
bind-key x kill-pane
# This tmux statusbar config was created by tmuxline.vim
# on Wed, 25 Nov 2015
set -g status "on"
set -g status-bg "colour236"
set -g status-justify "left"
set -g status-position "top"
set -g status-left-length "100"
set -g status-right-length "100"
set -g status-left "#{prefix_highlight}#[fg=colour22,bg=colour148,bold] #S #[fg=colour148,bg=colour236,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=colour240,bg=colour236,nobold,nounderscore,noitalics]#[fg=colour250,bg=colour240] %Y-%m-%d %H:%M #[fg=colour252,bg=colour240,nobold,nounderscore,noitalics]#[fg=colour241,bg=colour252] #h "
setw -g window-status-separator ""
setw -g window-status-format "#[fg=colour245,bg=colour236] #I #[fg=colour245,bg=colour236]#W "
setw -g window-status-current-format "#[fg=colour236,bg=colour240,nobold,nounderscore,noitalics]#[fg=colour231,bg=colour240] #I #[fg=colour231,bg=colour240]#{?window_zoomed_flag,#[fg=green][],}#W #[fg=colour240,bg=colour236,nobold,nounderscore,noitalics]"
# List of plugins
# see this https://github.com/tmux-plugins/tpm to installation
# set -g @plugin 'tmux-plugins/tpm'
# set -g @plugin 'tmux-plugins/tmux-open'
# set -g @plugin 'tmux-plugins/tmux-yank'
# set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
# run -b '~/.config/tmux/plugins/tpm/tpm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment