Skip to content

Commit

Permalink
another rev on the tmux clear command
Browse files Browse the repository at this point in the history
still not working perfectly in all scenarios

Generated-by: aiautocommit
  • Loading branch information
iloveitaly committed Dec 26, 2024
1 parent 68d73bc commit 90beb70
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions .tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,24 @@ setw -g mode-keys vi
bind-key -T copy-mode-vi C-a send-keys -X start-of-line
bind-key -T copy-mode-vi C-e send-keys -X end-of-line

# TODO I think ctrl+opt+L may fix this and should be handled through zsh instead
# prefix-C to clear the terminal
# https://stackoverflow.com/questions/10543684/how-do-i-clear-the-scrollback-buffer-in-tmux#:~:text=Just%20type%20%2B%20%3A,question%20for%20the%20same%20effect.
# https://stackoverflow.com/questions/10543684/how-do-i-clear-the-scrollback-buffer-in-tmux
# NOTE this is normally bound to create a new window, but we don't do that via tmux
bind-key c {
send-keys -R
clear-history

# TODO this is dangerous because in ipython or other terminal it will not properly push line

# TODO we should really try executing the widget directly as this is brittle
bind -n C-M-l {
if-shell "[ '#{pane_current_command}' = 'zsh' ]" {
# this runs `push-line` in zsh

send-keys C-x C-p
send-keys "Enter"
# Send Ctrl+Opt+L to the terminal as well
send-keys C-M-l
} {
# TODO detect other shells
send-keys C-c
}
display-message "Cleared terminal"

# without this pause, clear-history doesn't clear the current terminal output, and you can still scroll up
run-shell "sleep 0.1"

clear-history

# this messes with ZLE and I'm fine keeping the current buffer on ZSH in place
# send-keys -R
}

# TODO may fix issues with nano https://github.com/mislav/dotfiles/blob/master/tmux.conf#L39C8-L39C19
Expand All @@ -95,6 +93,8 @@ set -s focus-events on
# TODO https://github.com/abhinav/tmux-fastcopy/issues/160
# set -g destroy-unattached on

# TODO this isn't working! Try -ga, maybe some other tricks?
# https://github.com/impactaky/dotfiles/blob/2913fc22de6df637b1b2cba88215d995f667b64f/tmux/.tmux.conf#L36
# pass VS Code variables from the shell to tmux
set update-environment "VSCODE_GIT_ASKPASS_EXTRA_ARGS VSCODE_GIT_ASKPASS_MAIN VSCODE_GIT_IPC_HANDLE VSCODE_INJECTION"

Expand Down Expand Up @@ -143,14 +143,19 @@ set -g @extrakto_editor "~/.open-file-path.sh"
set -g @extrakto_filter_order "all line"
set -g @extrakto_grab_area "recent"

###########################
# use pbpcopy for copy bindings
# trim training newlines from end-of-line copy
###########################
######################################################
#
# - Use pbpcopy for all default copy bindings
# - Trim trailing newlines from EOL copy & more
#
######################################################

# append selection to clipboard
bind-key -T copy-mode-vi A send-keys -X append-selection-and-cancel pbcopy

# copy selection without cancelling copy mode
bind-key -T copy-mode-vi c send-keys -X copy-selection pbcopy

# for `t` and `T` your cursor position matters, only content after cursor will be processed

# copy to EOL and trim trailing newline, but not leading/trailing whitespace
Expand Down Expand Up @@ -460,9 +465,9 @@ bind-key -n TripleClick1Pane {
# TODO create another binding which copies the last output, trims trailing newlines, and copies to clipboard

# TODO should replace the existing yank script
# copy line in prompt
# copy line in prompt, modified from tmux-yank
bind p {
# go to beginning of line, this respects whatever prompt header (zsh, py, etc) is present
# go to beginning of line, this respects whatever prompt header (zsh, ipy, etc) is present
send-key 'C-a'
run-shell "sleep 0.01"

Expand Down

0 comments on commit 90beb70

Please sign in to comment.