Skip to content

Commit a41861e

Browse files
committed
fix(nvim): handle herdr scrollback views
1 parent 1cdf084 commit a41861e

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

.config/nvim/plugin/30_autocmds.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ _G.Config.new_autocmd('TextYankPost', {
2424
pattern = '*',
2525
})
2626

27+
-- Herdr opens its captured scrollback in $EDITOR. Keep that disposable view
28+
-- anchored at the newest output and make either q key close it without saving.
29+
_G.Config.new_autocmd('VimEnter', {
30+
callback = function()
31+
local buffer = vim.api.nvim_get_current_buf()
32+
if vim.fn.fnamemodify(vim.api.nvim_buf_get_name(buffer), ':t'):match('^herdr%-scrollback%-') then
33+
vim.keymap.set('n', 'q', '<Cmd>quit!<CR>', { buffer = buffer, nowait = true })
34+
vim.keymap.set('n', 'Q', '<Cmd>quit!<CR>', { buffer = buffer, nowait = true })
35+
vim.cmd('normal! Gzb')
36+
end
37+
end,
38+
})
39+
2740
-- resize splits if window got resized
2841
_G.Config.new_autocmd({ "VimResized" }, {
2942
callback = function()

.local/bin/tmux-history

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ trap cleanup EXIT
77

88
if [[ $(tmux display-message -p '#{pane_in_mode}') == 1 ]]; then
99
tmux capture-pane -M -p | perl -0pe 's/(?:[ \t]*\n)+\z/\n/' >"$file"
10-
nvim_position='+normal! ggzt'
1110
else
1211
tmux capture-pane -pS - | perl -0pe 's/(?:[ \t]*\n)+\z/\n/' >"$file"
13-
nvim_position='+normal! Gzb'
1412
fi
1513

1614
printf -v window_command 'nvim %q %q %q; rm -f -- %q' \
17-
"$nvim_position" '+nnoremap <buffer> q :quit<CR>' "$file" "$file"
15+
'+normal! Gzb' '+nnoremap <buffer> <nowait> q <Cmd>quit!<CR> | nnoremap <buffer> <nowait> Q <Cmd>quit!<CR>' "$file" "$file"
1816
tmux new-window -n history "$window_command"
1917

2018
# keep the file for the tmux window; rely on the command above to clean up

0 commit comments

Comments
 (0)