aboutsummaryrefslogtreecommitdiff
path: root/.config/tmux
diff options
context:
space:
mode:
Diffstat (limited to '.config/tmux')
-rwxr-xr-x.config/tmux/left-status.sh25
-rwxr-xr-x.config/tmux/right-status.sh27
-rwxr-xr-x.config/tmux/tmux-toggle-option.sh27
-rw-r--r--.config/tmux/tmux.conf329
4 files changed, 408 insertions, 0 deletions
diff --git a/.config/tmux/left-status.sh b/.config/tmux/left-status.sh
new file mode 100755
index 0000000..e4a8c49
--- /dev/null
+++ b/.config/tmux/left-status.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+function ip-address() {
+ # Loop through the interfaces and check for the interface that is up.
+ for file in /sys/class/net/*; do
+ iface=$(basename $file);
+ read status < $file/operstate;
+ [ "$status" == "up" ] && ip addr show $iface | awk '/inet /{printf $2""}'
+ done
+}
+
+function vpn-connection() {
+ # Check for tun0 interface.
+ [ -d /sys/class/net/tun0 ] && printf "%s " 'VPN*'
+}
+
+function main() {
+ # Comment out any function you do not need.
+ ip-address
+ vpn-connection
+}
+
+# Calling the main function which will call the other functions.
+main
+
diff --git a/.config/tmux/right-status.sh b/.config/tmux/right-status.sh
new file mode 100755
index 0000000..a14bbe3
--- /dev/null
+++ b/.config/tmux/right-status.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# Get CPU average
+getCPU=$[100-$(vmstat 1 2|tail -1|awk '{print $15}')]
+
+# Grab the second line of the ouput produced by the command: free -g (displays output in Gb)
+getMem=$(free -h | sed -n '2p')
+getMemPct=$(free -g | sed -n '2p')
+
+# Split the string in secondLine into an array
+read -ra ADDR <<< "$getMem"
+read -ra ADDRPct <<< "$getMemPct"
+
+# Get the total RAM from arrays
+totalRam="${ADDR[1]//[^0-9.0-9]/}"
+totalRamPct="${ADDRPct[1]}"
+
+# Get the used RAM from arrays
+usedRam="${ADDR[2]//[^0-9.0-9]/}"
+usedRamPct="${ADDRPct[2]}"
+
+# Calculate and display the percentages
+pct="$(($usedRamPct*100/$totalRamPct))"
+usage="$usedRam/$totalRam"
+#echo "cpu:$getCPU% | mem:$pct% ($usage""G)"
+echo "Cpu:$getCPU% | Mem:$pct% |"
+
diff --git a/.config/tmux/tmux-toggle-option.sh b/.config/tmux/tmux-toggle-option.sh
new file mode 100755
index 0000000..52d5fdb
--- /dev/null
+++ b/.config/tmux/tmux-toggle-option.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/bash
+
+#USAGE="USAGE: $0 OPTION_NAME ON_STATE OFF_STATE"
+
+#OPTION_NAME=$1
+#ON_STATE=$2
+#OFF_STATE=$3
+#
+#if [[ "$#" != 3 ]]; then
+# echo $USAGE
+# exit 1
+#fi
+#
+#if [[ `tmux show-option -w | grep "$OPTION_NAME $ON_STATE"` ]]; then
+# OPTION_VALUE=$OFF_STATE
+#else
+# OPTION_VALUE=$ON_STATE
+#fi
+#
+#tmux display-message "monitor activity: $OPTION_NAME $OPTION_VALUE"
+#tmux set-option -w $OPTION_NAME $OPTION_VALUE > /dev/null
+
+if [ $(tmux show-option -A status-left) != 'status-left* "#[fg=#50fa7b,bg=default] #[bg=#50fa7b,fg=black]❐ #S #[fg=#50fa7b,bg=default]"' ]; then
+ tmux set -g status-left "#[fg=#50fa7b,bg=default] #[bg=#50fa7b,fg=black]❐ #S #[fg=#50fa7b,bg=default] ";
+else
+ tmux set -g status-left "#[fg=#50fa7b,bg=default]#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" && tmux set -g status-right "#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,}#[bg=default,fg=#50fa7b]#[bg=#50fa7b,fg=black] #( ~/.config/tmux/right-status.sh ) %d-%b-%y | %H:%M #[bg=default,fg=#50fa7b]";
+fi
diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf
new file mode 100644
index 0000000..afe696d
--- /dev/null
+++ b/.config/tmux/tmux.conf
@@ -0,0 +1,329 @@
+# ████████╗███╗ ███╗██╗ ██╗██╗ ██╗
+# ╚══██╔══╝████╗ ████║██║ ██║╚██╗██╔╝
+# ██║ ██╔████╔██║██║ ██║ ╚███╔╝
+# ██║ ██║╚██╔╝██║██║ ██║ ██╔██╗
+# ██║ ██║ ╚═╝ ██║╚██████╔╝██╔╝ ██╗
+# ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
+#――――――――――――――――――――――――――――――――――――――――――
+
+### Options ###
+
+# Setting the Prefix from Ctrl+b to Ctrl+s
+unbind C-b
+set -g prefix C-s
+#set -g prefix M-Space
+
+# Ensure that we can send Ctrl+s to other apps
+bind C-s send-prefix
+
+# Send the prefix to client inside window (nested tmux)
+bind-key -n C-a send-prefix
+
+# Disable local tmux keys (nested tmux)
+bind -T root F12 \
+ set prefix None \;\
+ set key-table off \;\
+ if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
+ refresh-client -S \;\
+
+bind -T off F12 \
+ set -u prefix \;\
+ set -u key-table \;\
+ refresh-client -S
+
+# Setting the delay between Prefix and Command
+set -sg escape-time 10
+#set-option -sg escape-time 10
+
+# Reload tmux with <Prefix>r
+#bind r source-file ~/.tmux.conf \; display "Reloaded!"
+bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!"
+
+# Use <Prefix>L to clear terminal
+bind -r L send-keys 'C-l'
+
+# Rename current window (Ctrl + A, A)
+bind R rename-window '' \; \
+ command-prompt -I "#W" "rename-window -- '%%'"
+
+# Mouse
+set -g mouse on
+#set -g mouse-select-pane on
+#set -g mouse-resize-pane on
+#set -g mouse-select-window on
+
+# Scrollback
+#set -g history-limit 10000
+
+# Sane scrolling
+set -g terminal-overrides 'xterm*:smcup@:rmcup@'
+
+# Shift up/down copy-mode without prefix
+bind-key -n S-Up copy-mode \; send-key Up
+bind-key -n S-Down copy-mode \; send-key Down
+bind-key -n Pageup copy-mode \; send-key Pageup
+bind-key -n Pagedown copy-mode \; send-key Pagedown
+is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
+ | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
+#bind -n M-k if-shell "$is_vim" "send-keys Pageup" "copy-mode -u"
+bind -n Pageup if-shell "$is_vim" "send-keys Pageup" "copy-mode -u"
+bind -n S-Pageup if-shell "$is_vim" "send-keys Pageup" "copy-mode -u"
+bind -n S-Pagedown send-keys Pagedown
+#bind -n M-j send-keys Pagedown
+
+# Focus events, allow supported requests from applications to passthrough/run in tmux
+set-option -g focus-events on
+
+# Update the TERM variable of terminal emulator when creating a new session or attaching a existing session
+set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM'
+
+
+#――――――――――――――――――――――――――――――――――――――――――
+
+### Window Movement/Control ###
+
+# Aggressive resizing, useful when using "grouped sessions" and multi-monitor setup
+setw -g aggressive-resize on
+
+# Popup scratch session
+#bind -n M-g display-popup -E "tmux new-session -A -s scratch"
+
+# Toggle popup scratch session
+bind-key -n M-g if-shell -F '#{==:#{session_name},note}' {
+detach-client
+} {
+display-popup -E "tmux new-session -A -s note"
+}
+
+# Non-popup
+#bind C-k new-window -n "session-switcher" "\
+# tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\
+# sed '/^$/d' |\
+# fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\
+# xargs tmux switch-client -t"
+
+# Popup
+bind -n M-f display-popup -E "\
+ tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\
+ sed '/^$/d' |\
+ fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\
+ xargs tmux switch-client -t"
+
+# Quick window select
+bind -n M-? list-keys
+bind -n M-1 select-window -t :=1
+bind -n M-2 select-window -t :=2
+bind -n M-3 select-window -t :=3
+bind -n M-4 select-window -t :=4
+bind -n M-5 select-window -t :=5
+bind -n M-6 select-window -t :=6
+bind -n M-7 select-window -t :=7
+bind -n M-8 select-window -t :=8
+bind -n M-9 select-window -t :=9
+bind -n M-0 select-window -t :=0
+
+
+#――――――――――――――――――――――――――――――――――――――――――
+
+### Pane Movement/Control ###
+
+# Smart pane switching with awareness of Vim splits.
+# See: https://github.com/christoomey/vim-tmux-navigator
+# Navigate across tmux-vim
+is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
+ | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
+
+# {{{ keybinds: select-pane
+bind -Tnav h select-pane -L
+bind h select-pane -L
+bind -Tnav C-h select-pane -L
+bind C-h select-pane -L
+bind -Tnav j select-pane -D
+bind j select-pane -D
+bind -Tnav C-j select-pane -D
+bind C-j select-pane -D
+bind -Tnav k select-pane -U
+bind k select-pane -U
+bind -Tnav C-k select-pane -U
+bind C-k select-pane -U
+bind -Tnav l select-pane -R
+bind l select-pane -R
+bind -Tnav C-l select-pane -R
+bind C-l select-pane -R
+bind -Tnav p select-pane -l
+bind p select-pane -l
+bind -Tnav C-p select-pane -l
+bind C-p select-pane -l
+# keybinds: select-pane }}}
+
+# {{{ keybinds: split-window
+bind -Tnav "\\" split-window -h -c "#{pane_current_path}" # vertical
+bind "\\" split-window -h -c "#{pane_current_path}" # vertical
+bind -Tnav "|" split-window -fh -c "#{pane_current_path}" # full vertical
+bind "|" split-window -fh -c "#{pane_current_path}" # full vertical
+bind -Tnav "-" split-window -v -c "#{pane_current_path}" # horizontal
+bind "-" split-window -v -c "#{pane_current_path}" # horizontal
+bind -Tnav "_" split-window -fv -c "#{pane_current_path}" # full horizontal
+bind "_" split-window -fv -c "#{pane_current_path}" # full horizontal
+# keybinds: split-window }}}
+
+# {{{ keybinds: resize-pane
+bind -r -Tnav M-h resize-pane -L 10
+bind -r M-h resize-pane -L 10
+bind -r -Tnav M-j resize-pane -D 5
+bind -r M-j resize-pane -D 5
+bind -r -Tnav M-k resize-pane -U 5
+bind -r M-k resize-pane -U 5
+bind -r -Tnav M-l resize-pane -R 10
+bind -r M-l resize-pane -R 10
+# keybinds: resize-pane }}}
+
+# Hide a pane and bring it back with <Prefix>! and <Prefix>@ respectively
+bind-key ! break-pane -d -n _hidden_pane
+bind-key @ join-pane -s $.0
+
+# Send Pane to another session/window
+bind-key = command-prompt -p "send pane to:" "join-pane -t '%%'"
+
+
+#――――――――――――――――――――――――――――――――――――――――――
+
+### Copy Mode (Copy/Paste) ###
+
+# Set Vi copy mode, use <prefix>[ to enter copy mode
+setw -g mode-keys vi # `<prefix>:list-keys -T copy-mode-vi` to confirm
+
+# Change selection <space> and enter to vi keybinding
+bind-key -T copy-mode-vi 'v' send -X begin-selection
+bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
+
+# Copy to system clipboard (requires xclip)
+if-shell -b 'echo $XDG_SESSION_TYPE | grep -q x11' "\
+ bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \
+ bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \
+ bind-key C-M-v run 'xclip -out -selection clipboard | tmux load-buffer - ; tmux paste-buffer'"
+
+# Wayland support
+if-shell -b 'echo $XDG_SESSION_TYPE | grep -q wayland' "\
+ bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'wl-copy'; \
+ bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'wl-copy'; \
+ bind-key C-p run 'wl-paste --no-newline | tmux load-buffer - ; tmux paste-buffer'" "\
+ \
+ bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \
+ bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \
+ bind-key C-M-v run 'cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer'"
+
+#
+
+### Colors ###
+
+# Set 256 color terminal
+set-option -sa terminal-overrides ",tmux-256color:Tc"
+#set-option -sa terminal-overrides ",xterm*:Tc,alacritty*:Tc"
+
+# Colors for pane borders(default)
+setw -g pane-border-style fg=white
+setw -g pane-active-border-style fg=green
+
+# Active pane normal, other shaded out
+setw -g window-style fg=colour240
+setw -g window-active-style fg=white
+
+
+#
+
+### Status ###
+
+set -g status-position bottom # [top, bottom]
+set -g status on
+#set -g status-interval 1
+set -g status-interval 500
+set -g status-style fg=#50fa7b,bg=default
+
+## Left
+#set -g status-left ""
+set -g status-left-length 60
+#set -g status-left "#[fg=#50fa7b,bg=default]#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]"
+set -g status-left "#(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=#39BAE6]#[bg=default]#[bg=#39BAE6,fg=black] ❐ #S #[fg=#39BAE6,bg=default]\"} /-- INSERT --/ {print \"#[fg=#50fa7b]#[bg=default]#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]\"}')"
+
+## Centre
+#set -g window-status-current-format "#[bg=default,fg=#50fa7b]#[fg=black,bg=#50fa7b] #I:#W #[bg=default,fg=#50fa7b]"
+set -g window-status-current-format "#(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=#39BAE6]#[bg=default]#[fg=black,bg=#39BAE6] #I:#W #[bg=default,fg=#39BAE6]\"} /-- INSERT --/ {print \"#[fg=#50fa7b]#[bg=default]#[fg=black,bg=#50fa7b] #I:#W #[bg=default,fg=#50fa7b]\"}')"
+set -g status-justify absolute-centre
+
+## Right
+set-option -g status-right ""
+set -g status-right-length 60
+#set -g status-right "#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[bg=default,fg=#50fa7b]#[bg=#50fa7b,fg=black] %H:%M #[bg=default,fg=#50fa7b]"
+local_keys_off="#[fg=#50fa7b,bg=default]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]"
+set -g status-right "$local_keys_off #(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[fg=#39BAE6]#[bg=default]#[bg=#39BAE6,fg=black] %H:%M #[bg=default,fg=#39BAE6]\"} /-- INSERT --/ {print \"#[fg=#39BAE6,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[fg=#50fa7b]#[bg=default]#[bg=#50fa7b,fg=black] %H:%M #[bg=default,fg=#50fa7b]\"}')"
+
+#set -g status-right "#[fg=white,bg=black]#(cat ~/.vi-mode)"
+#set -g status-right "#[fg=white,bg=black]#(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=blue]#[bg=black]-- NORMAL --\"} /-- INSERT --/ {print \"#[fg=green]#[bg=black]-- INSERT --\"}')"
+
+## Reload Status with IP addr, Cpu, Mem and Date
+bind a run-shell ~/.config/tmux/tmux-toggle-option.sh
+
+## Reload Config/Status silently
+bind b source-file ~/.config/tmux/tmux.conf
+
+set-option -g default-shell "/usr/bin/zsh"
+
+
+#――――――――――――――――――――――――――――――――――――――――――
+
+### Plugin Install ###
+
+set -g @plugin "tmux-plugins/tpm"
+#set -g @plugin "tmux-plugins/tmux-sensible"
+set -g @plugin "tmux-plugins/tmux-resurrect"
+set -g @plugin "tmux-plugins/tmux-continuum"
+set -g @plugin "christoomey/vim-tmux-navigator"
+#set -g @plugin "tmux-plugins/tmux-yank"
+#set -g @plugin 'srdusr/tmux-vi-mode'
+#set -g @plugin 'vi-mode ~/.config/tmux/plugins/vi-mode.sh'
+
+
+#――――――――――――――――――――――――――――――――――――――――――
+
+### Plugins Settings ###
+
+# Plugin to save and restore tmux sessions after restart
+# * Save with: <Prefix> + Ctrl-s
+# * Restore with: <Prefix> + Ctlr-r
+# Change default save and restore keybindings
+ set -g @resurrect-save "W" # <Prefix> + W
+ set -g @resurrect-restore "E" # <Prefix> + E
+
+# Restore vim and nvim sessions as well
+# For vim:
+ set -g @resurrect-strategy-vim "session"
+# For neovim:
+ set -g @resurrect-strategy-nvim "session"
+
+# Automatic restore
+ #set -g @continuum-restore "on"
+ #set -g @continuum-boot "on"
+
+# Restore Panes
+ set -g @resurrect-capture-pane-contents "on"
+
+# This is a hook for tmux-resurrect which tells it to kill session 0 before restoring the panels
+ set -g @resurrect-hook-pre-restore-pane-processes "tmux switch-client -n && tmux kill-session -t=0"
+
+# Plugin uninstall
+ # Delete or comment out the plugin in .tmux.conf.
+ # Press <prefix> + alt + u to remove the plugin.
+
+# TMUX plugin manager (keep at the bottom of tmux.conf)
+ #run "~/.config/tmux/plugins/tpm/tpm"
+ if "test ! -d ~/.config/tmux/plugins/tpm" \
+ "run 'git clone https://github.com/tmux-plugins/tpm ~/.config/tmux/plugins/tpm && ~/.config/tmux/plugins/tpm/bin/install_plugins'"
+run -b "~/.config/tmux/plugins/tpm/tpm"
+# Load the vi-mode plugin
+
+#run-shell '~/.config/tmux/plugins/tmux-vi-mode/tmux-vi-mode.tmux'
+#run-shell '~/.config/tmux/vi-mode'
+# Load the vi-mode plugin
+#run '~/.config/tmux/plugins/tpm/plugins/tmux-vi-mode/tmux-vi-mode.tmux'
+#――――――――――――――――――――――――――――――――――――――――――