kitty-scrollback-neovim.sh 876 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. set -eu
  3. if [ "$#" -eq 3 ]; then
  4. INPUT_LINE_NUMBER=${1:-0}
  5. CURSOR_LINE=${2:-1}
  6. CURSOR_COLUMN=${3:-1}
  7. AUTOCMD_TERMCLOSE_CMD="call cursor(max([0,${INPUT_LINE_NUMBER}-1])+${CURSOR_LINE}, ${CURSOR_COLUMN})"
  8. else
  9. AUTOCMD_TERMCLOSE_CMD="normal G"
  10. fi
  11. exec nvim 63<&0 0</dev/null \
  12. -u NONE \
  13. -c 'packadd leap.nvim' \
  14. -c "lua require('leap').add_default_mappings()" \
  15. -c 'highlight link LeapBackdrop Comment' \
  16. -c "map <silent> q :qa!<CR>" \
  17. -c "set scrollback=100000 nonumber termguicolors laststatus=0 clipboard+=unnamedplus" \
  18. -c "autocmd TermEnter * stopinsert" \
  19. -c "autocmd TermClose * ${AUTOCMD_TERMCLOSE_CMD}" \
  20. -c 'terminal sed </dev/fd/63 -e "s/'$'\x1b'']8;;file:[^\]*[\]//g" && sleep 0.01 && printf "'$'\x1b'']2;"'
  21. # Source: https://github.com/kovidgoyal/kitty/issues/719#issuecomment-1179602324