Skip to content

Instantly share code, notes, and snippets.

@IanEdington
Last active May 8, 2022 18:38
Show Gist options
  • Save IanEdington/58bce865f5132ce805d31ddb838f7acf to your computer and use it in GitHub Desktop.
Save IanEdington/58bce865f5132ce805d31ddb838f7acf to your computer and use it in GitHub Desktop.
tmux config for iSH
#!/usr/bin/env bash
cat - > /dev/clipboard
#! /usr/bin/env bash
# If reattach-to-user-namespace is not available, just run the command.
if [[ -n "$(command -v reattach-to-user-namespace)" ]]; then
reattach-to-user-namespace $@
else
exec "$@"
fi
# set as a suggestion from neovim
# set-option -sg escape-time 10
# Open new windows and panes with the current working directory
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
# From @christoomey https://github.com/christoomey/dotfiles/blob/master/tmux/tmux.conf
# Ctrl-s prefix key. Default => C-b. Send C-s with repeat option via C-s C-s
unbind-key C-b
set -g prefix C-s
bind -r C-s send-prefix
# set -g default-command "safe-reattach-to-user-namespace -l zsh"
set -g renumber-windows on
set -g display-panes-time 350
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# improve colors
# set -g default-terminal 'tmux-256color-italic'
# set-option -ga terminal-overrides ",xterm-256color-italic:Tc"
# Keep plenty of history for scrollback
set -g history-limit 10000
# Use emacs / readline key-bindings at the tmux command prompt `<prefix>:`
set -g status-keys emacs
# address vim mode switching delay (http://superuser.com/a/252717/65504)
set -s escape-time 0
set -g mouse on
# Use vim keybindings in copy mode
setw -g mode-keys vi
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "safe-reattach-to-user-namespace pbcopy"
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "safe-reattach-to-user-namespace pbcopy"
unbind -T copy-mode-vi Space
bind -T copy-mode-vi Space send -X jump-again
bind-key -T copy-mode-vi 0 send -X back-to-indentation
bind y run 'tmux save-buffer - | safe-reattach-to-user-namespace pbcopy '
bind C-y run 'tmux save-buffer - | safe-reattach-to-user-namespace pbcopy '
# Simplify status bar display.
set -g status-left-length 40
set -g status-fg black
set -g status-bg green
set -g status-left '[#S] '
set -g status-right "#{?pane_synchronized,--SYNCED--,} #(is-online) #(battery -t -g black) #(date '+%a, %b %d - %I:%M') "
# Dismiss current pane to background window
bind b break-pane -d
bind C-b send-keys 'tat && exit' 'C-m'
bind-key ! run-shell '(tmux switch-client -l || tmux switch-client -n) && tmux kill-session -t "#S" || tmux kill-session'
bind-key J command-prompt -p "join pane from: " "join-pane -h -s '%%'"
bind c new-window -c "#{pane_current_path}"
bind C-d split-window -h -c ~/code/dotfiles/ "safe-reattach-to-user-namespace vim +Files"
bind g split-window -c "#{pane_current_path}" -h -p 50 'gitsh'
bind r split-window -h -c ~/ "rcup"
bind w split-window -h -c ~/wiki "safe-reattach-to-user-namespace vim +Files"
bind t split-window -h -c "#{pane_current_path}" "source ~/.zsh/configs/navigation.zsh && itree | less -R"
bind C-t split-window -v "source ~/.zsh/configs/navigation.zsh && tm-select-session"
# Make C-j display a selectable list of sessions
# bind C-j choose-tree
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
# Quick session switching back and forth. I never use the built in layouts
# (default mapping for Space), so I reclaimed the key for this
bind-key Space switch-client -l
# more intuitive keybindings for splitting
bind \\ split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Smart pane switching with awareness of vim splits
# See this blog post for additional detail:
# http://robots.thoughtbot.com/post/53022241323/seamlessly-navigate-vim-and-tmux-splits
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind -n C-\\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# Secondary binding for C-l to retain redraw
bind C-l send-keys 'C-l'
# Reload tmux.conf with prefix-r
bind C-r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
# bind resizing of panes to H,J,K,L (resizes by steps of 10 lines/columns)
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1
bind -n C-Left resize-pane -L 10
bind -n C-Right resize-pane -R 10
bind -n C-Down resize-pane -D 5
bind -n C-Up resize-pane -U 5
# allow attaching to group and expanding sizes
# tmux new-session -t ${session:=group}
setw -g aggressive-resize on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment