From d0fb7ead0449832443ad4de2c25d720d6231a29c Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sun, 6 Feb 2022 11:49:05 -0500 Subject: [PATCH] Update tmux copy and selection behavior + Enable vim copy selection mode + Add various copy actions for middle, double, triple-click, etc. + Add instructions to README to install required tmux plugins --- .bash_aliases | 9 ++++++--- .tmux.conf | 24 ++++++++++++++++++++++++ README.md | 8 +++++++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.bash_aliases b/.bash_aliases index ca20977..3e4fa7a 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,11 +1,14 @@ -# Alias to restart plasmashell for Kubuntu Plasma session -alias kapp-plasmashell='sudo pkill plasmashell && plasmashell --replace &> /dev/null &' - # Aliases to use the correct python version alias python3='python3.9' alias pip3='python3.9 -m pip' +# Alias to restart plasmashell for Kubuntu Plasma session +alias kapp-plasmashell='sudo pkill plasmashell && plasmashell --replace &> /dev/null &' +# Alias to clear swap +alias kapp-swap='sudo swapoff -a && sudo swapon -a' +# Alias to initialize github user alias kapp-git='git config --global user.name "Shaun Reed" && git config --global user.email "shaunrd0@gmail.com"' +# Alias to update and upgrade with useful flags set alias kapp-update='sudo apt update -y && sudo apt upgrade -y && sudo apt upgrade --fix-broken --fix-missing --auto-remove' # Alias / export customizations diff --git a/.tmux.conf b/.tmux.conf index e55823b..dd348c5 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -20,7 +20,28 @@ #+ Vim plugin 'Colorizer' does not reflect the actual 256colour values #+ See https://jonasjacek.github.io/colors/ for a full list of 256colours +# Settings for terminal text selection / copy options +# + Source: https://www.seanh.cc/2020/12/27/copy-and-paste-in-tmux/ +# + Depends: https://github.com/tmux-plugins/tmux-yank#linux set -g mouse on +# These bindings are for X Windows only. If you're using a different +# window system you have to replace the `xsel` commands with something +# else. See https://github.com/tmux/tmux/wiki/Clipboard#available-tools +bind -T copy-mode DoubleClick1Pane select-pane \; send -X select-word \; send -X copy-pipe-no-clear "xsel -i" +bind -T copy-mode-vi DoubleClick1Pane select-pane \; send -X select-word \; send -X copy-pipe-no-clear "xsel -i" +bind -n DoubleClick1Pane select-pane \; copy-mode -M \; send -X select-word \; send -X copy-pipe-no-clear "xsel -i" +bind -T copy-mode TripleClick1Pane select-pane \; send -X select-line \; send -X copy-pipe-no-clear "xsel -i" +bind -T copy-mode-vi TripleClick1Pane select-pane \; send -X select-line \; send -X copy-pipe-no-clear "xsel -i" +bind -n TripleClick1Pane select-pane \; copy-mode -M \; send -X select-line \; send -X copy-pipe-no-clear "xsel -i" +bind -n MouseDown2Pane run "tmux set-buffer -b primary_selection \"$(xsel -o)\"; tmux paste-buffer -b primary_selection; tmux delete-buffer -b primary_selection" +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-yank' +set -g @yank_action 'copy-pipe-no-clear' +bind -T copy-mode C-c send -X copy-pipe-no-clear "xsel -i --clipboard" +bind -T copy-mode-vi C-c send -X copy-pipe-no-clear "xsel -i --clipboard" + +set-option -s set-clipboard external +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i" # remap shortcut prefix from 'C-b' to 'C-z' unbind C-b @@ -143,3 +164,6 @@ set -g @scroll-speed-num-lines-per-scroll 2 # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run -b '~/.tmux/plugins/tpm/tpm' +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +#run '~/.tmux/plugins/tpm/tpm' + diff --git a/README.md b/README.md index 28dc6df..e3283b4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ These configs were created and tested on Kubuntu 20.04 using i3-gaps, and should First, grab some packages used for status bar and desktop overlay ```bash -sudo apt install conky golang-go inxi python3 python3-pip jq tmux xbindkeys xautolock pulsemixer +sudo apt install conky golang-go inxi python3 python3-pip jq tmux xbindkeys xautolock pulsemixer xsel sudo pip3 install powerline-shell go get -u github.com/arl/gitmux ``` @@ -55,6 +55,12 @@ cd ~/dot/ git submodule update --init ``` +*After* the dotfiles have been installed using `stow`, you should run `tpm` to ensure tmux plugins are all installed according to the `tmux.conf` settings provided. Assuming you don't want to face errors for dependencies related to tmux shortcuts defined in `.tmux.conf`, this is a required step to configure these dotfiles. Alternatively, you could provide your own `.tmux.conf` that does not use plugins to avoid this step, or just use the default `.tmux.conf` instead. + +```bash + ~/.tmux/plugins/tpm/bin/install_plugins +``` + ![desktop](Pictures/screenshots/dtop-code.png) #### Additional Configuration