Skip to content

Commit

Permalink
tmux: Undo TERM hacking
Browse files Browse the repository at this point in the history
Undoes the hack introduced in 1136ef2
to fix the combination of Home/End keys, italics in Vim, and background
highlighting in Delta.

Fixes Home/End key regression in scratchpad terminal (#143).

"Just works" on Fedora, but on Ubuntu, it requires the ncurses-term
package to provide the tmux-256color termcap.
  • Loading branch information
Notgnoshi committed Nov 12, 2024
1 parent d2a14d7 commit db863fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
1 change: 1 addition & 0 deletions setup.d/000-base-packages-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if prompt_default_no "Install base system packages?"; then
iperf
make
moreutils
ncurses-term
net-tools
nmap
openssh-server
Expand Down
13 changes: 5 additions & 8 deletions stowdir/.tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,13 @@ bind-key C-a send-prefix
bind-key C-l send-keys C-l
bind-key l send-keys C-l

set -g default-terminal xterm-256color
# screen-256color and xterm-256color result in Vim italics shenanigans, as well as Home and End not
# working in the shell, scratchpad, and Vim without extra hacks. Using tmux-256color requires the
# ncurses-term package on Ubuntu.
set -g default-terminal tmux-256color
# Fix delta background colors
# See: https://dandavison.github.io/delta/tips-and-tricks/using-delta-with-tmux.html
set -ga terminal-overrides ",xterm-256color:Tc"
# Fix Home/End keys not working with xterm-256color
# Requires additional settings in my vimrc so that Vim doesn't insert an H or an F on the line above
# the cursor ಠ_ಠ
# See: https://stackoverflow.com/a/55616731
bind-key -n Home send Escape "OH"
bind-key -n End send Escape "OF"
set -ga terminal-overrides ",*-256color:Tc"

set -g set-titles on
# Forward the pane's title on to the terminal
Expand Down
9 changes: 0 additions & 9 deletions stowdir/.vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -632,15 +632,6 @@ let test#strategy = "dispatch"
" Keybinds
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Handle tmux $TERM quirks in vim
" See: https://stackoverflow.com/a/9674158
if $TERM =~ '^screen-256color'
map <Esc>OH <Home>
map! <Esc>OH <Home>
map <Esc>OF <End>
map! <Esc>OF <End>
endif

" Turn off search highlighting with enter
nnoremap <CR> :nohl<CR><CR>
Expand Down

0 comments on commit db863fb

Please sign in to comment.