Skip to content

Instantly share code, notes, and snippets.

@Neo-Oli
Created November 6, 2017 15:14
Show Gist options
  • Save Neo-Oli/68365b7f6cd3a58e2ba5cc5f38a7154e to your computer and use it in GitHub Desktop.
Save Neo-Oli/68365b7f6cd3a58e2ba5cc5f38a7154e to your computer and use it in GitHub Desktop.
# _ __
# | |_ _ __ ___ _ ___ __ ___ ___ _ __ / _|
# | __| '_ ` _ \| | | \ \/ / / __/ _ \| '_ \| |_
# | |_| | | | | | |_| |> < | (_| (_) | | | | _|
#(_)__|_| |_| |_|\__,_/_/\_(_)___\___/|_| |_|_|
# Number windows and panes starting at 1 so that we can jump to them easier.
set -g base-index 1
set -g pane-base-index 1
# Renumber the windows if one is destroyed, so there are no gaps
set-option -g renumber-windows on
# Set max scrollback size
set-option -g history-limit 10000
# Makes pressing ESC in Neovim happen without delay (https://github.com/neovim/neovim/wiki/FAQ#esc-in-tmux-or-gnu-screen-is-delayed)
set -g escape-time 10
# Settings related to automatic locking
set-option -g lock-after-time 0 #disabled
set-option -g lock-command "lock -np"
# Enable mouse mode
set-option -g mouse on
# Set the prefix to Ctrl+B
set-option -g prefix C-b
# Ctrl+g sends the prefix to a nested tmux session (like on a remote server)
bind-key -n C-g send-prefix
# Allow certain keybindings to be repeated. For example resizing with arrow keys is continous when key is held.
set-option -g repeat-time 500
# Settings related to the window title of the terminal emulator
set-option -g set-titles on
#set-option -g set-titles-string "#S:#I:#W - "#T" #{session_alerts}"
#set-option -g set-titles-string "鼠标是在世界上熊的最重要的事情。🐻熊爱鼠标了很多。🐭"
# Set the title to a space, so Mintty displays nothing
set-option -g set-titles-string " "
# Change to copy mode on Scroll wheel. Makes Swiping work in Termux
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
# Enable vi key bindings
set-option -g status-keys vi
set-option -g mode-keys vi
# Set the color of vi command mode
set-option -g message-command-style fg=yellow,bg=black
# Enable the status line
set-option -g status on
# Settings related to the status left string
# Set the status left string to display the session number only when it is not 0
set-option -g status-left "#{?#{!=:#S,0},#S ,}"
set-option -g status-left-length 10
set-option -g status-left-style default
# Settings related to the Status right string
#set-option -g status-right "%d. %b │ %H:%M:%S"
#set-option -g status-right " #(pet -q) | #(termux-battery-status|jq '.percentage')%% | %d. %b | %H:%M "
#set-option -g status-right " アホイ☺ | #(termux-battery-status|jq '.percentage')%% | %d.%m | %H:%M "
#set-option -g status-right " アホイ☺ | #(termux-battery-status|jq '.percentage')%% | %H:%M "
# Set Status right to empty, because I am setting it with a cron job
set-option -g status-right ""
set-option -g status-right-length 200
set-option -g status-right-style bg=colour0,fg=colour7
set-option -g status-style fg=colour7,bg=colour0
set-option -g status-attr none
set-option -g status-position top
# Set the interval to 60 seconds, because the cron job only runs once a minute. cronjob overwrites this setting when seconds are enabled
set-option -g status-interval 60
set-option -g status-justify left
# Settings related to to the window titles.
set-window-option -g window-status-fg colour7
set-window-option -g window-status-bg colour8
# Disable automatic renaming of windows
set-window-option -g automatic-rename off
set-window-option -g allow-rename off
# Only display the window title if it was set manually and isn't login
#set-window-option -g window-status-format " #I #{?#{!=:#W,"login"},#W ,}"
set-window-option -g window-status-format " #I "
# If the current window is the only one, don't display anything. Otherwise display the Number.
set-window-option -g window-status-current-format "#{?#{!=:#{session_windows},1}, #I ,}"
set-window-option -g window-status-attr none
set-window-option -g window-status-current-fg colour0
set-window-option -g window-status-current-bg colour7
set-window-option -g window-status-current-attr none
# Color of the command mode
set -g mode-bg colour0
set -g mode-bg colour1
# Update the Variables when a session is created or attached
set-option -g update-environment "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"
# Bell related settings
# Disable visual bell and emulate it with a hook, so that there is both a visual alert and a bell.
set-option -g visual-bell off
set-hook -g alert-bell "display-message -F 'Bell in window #{window_index}:#{window_name}'"
set-option -g bell-action any
set-window-option -g window-status-bell-fg colour0
set-window-option -g window-status-bell-bg colour1
set-window-option -g window-status-bell-attr none
# Change the color of messages like the visual bell
set-option -g message-style fg=white,bg=red
#Set the display time of any messages
set-option -g display-time 3000
# Set the color of the borders
set -g pane-border-style fg=colour9
set -g pane-active-border-style fg=colour11
# Disable the highlighting of activity
setw -g monitor-activity off
set-option -g visual-activity off
# If monitor-silence is enabled, prints a message after the interval has expired on a given window.
set-option -g visual-silence off
# Pass Certain Keybindings like Ctrl+Arrows to the programms
set-window-option -g xterm-keys on
# Makes attaching to windows in differnet sessions better
setw -g aggressive-resize on
# Set TERM to something sensible
set -g default-terminal "xterm-256color"
# ¯\_(ツ)_/¯
set-option -ga terminal-overrides ",xterm*:Tc"
# "Alt-Tab" with tmux using Alt+§ (May only be sensible on de-CH Keyboard
bind -n M-° previous-window
bind -n M-§ next-window
# Open split window with current path
#bind c new-window -c "#{pane_current_path}"
bind '"' split-window -vc "#{pane_current_path}"
bind % split-window -hc "#{pane_current_path}"
# Clear screen and scrollback
bind k send-keys C-l \; run-shell "sleep .3s" \; clear-history
# Move current window to position 1
bind § move-window -t 0
# Invert color of pane
bind i select-pane -P 'fg=black,bg=white'
bind I select-pane -P 'fg=white,bg=black'
# Move panes around
bind-key j command-prompt -p "send pane to:" "join-pane -t ':%%'"
bind-key m display-panes "swap-pane -s '.%%'"
#Time the indicators are shown
set-option -g display-panes-time 2000
# Color of the indicators
set-option -g display-panes-active-colour magenta
set-option -g display-panes-colour cyan
# resizing on termux because Alt+Arrow Keys doesn't work with swiftkey
bind-key -r Up resize-pane -U
bind-key -r Down resize-pane -D
bind-key -r Left resize-pane -L
bind-key -r Right resize-pane -R
# urlscan as context and url view
bind-key u capture-pane \; save-buffer $TMPDIR/tmux-buffer \; \
new-window -n "urlscan" '$SHELL -c "urlscan < $TMPDIR/tmux-buffer"'
# Save buffer to file
bind-key U capture-pane \; save-buffer $TMPDIR/tmux-buffer
# Control MPD from tmux
#bind > run-shell 'mpc next -q'
#bind < run-shell 'mpc prev -q'
#bind P run-shell 'mpc toggle -q'
# Use custom scripts which set MPD_HOST in case tmux is started outside of a login shell. ssh host -t tmux
bind > run-shell '~/.shortcuts/tasks/pressy-next'
bind < run-shell '~/.shortcuts/tasks/pressy-prev'
bind P run-shell '~/.shortcuts/tasks/pressy-music'
# Settings and Init for tmux-better-mouse-mode. Automatically sends arrow keys on programs like less, which don't support the scroll wheel.
set -g @scroll-without-changing-pane on
set -g @scroll-speed-num-lines-per-scroll 1
set -g @emulate-scroll-for-no-mouse-alternate-buffer on
run-shell ~/.tmux/plugins/tmux-better-mouse-mode/scroll_copy_mode.tmux
run-shell ~/.tmux/plugins/tmux-text-macros/tmux-text-macros.tmux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment