From 90ac84a759bb3966c8418956de2dbe7bf4920735 Mon Sep 17 00:00:00 2001 From: Leonora Tindall Date: Sat, 31 Aug 2024 18:28:18 -0500 Subject: [PATCH] Set window title in Neovim, unset in Zsh preprompt --- rcfiles/neovim.lua | 21 +++++++++++++++++++++ zsh.nix | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/rcfiles/neovim.lua b/rcfiles/neovim.lua index 38b1134..9844bf0 100644 --- a/rcfiles/neovim.lua +++ b/rcfiles/neovim.lua @@ -36,6 +36,27 @@ vim.keymap.set('n', 'fb', tbuiltin.buffers, {}) vim.keymap.set('n', 'fh', tbuiltin.help_tags, {}) vim.keymap.set('n', 'fs', tbuiltin.spell_suggest, {}) +-- set terminal title +function _G.current_tab() + local curr_buf = vim.fn.bufnr() + local total = 0 + local curr_tab + + for i = 1, vim.fn.tabpagenr('$') do + total = total + 1 + for _, bufnr in ipairs(vim.fn.tabpagebuflist(i)) do + if bufnr == curr_buf then + curr_tab = i + end + end + end + + return string.format('(%d of %d)', curr_tab, total) +end + +vim.opt.title = true +vim.opt.titlestring = [[%f %h%m%r%w - %{v:progname} %{luaeval('current_tab()')}]] + -- vimsense (rich presence) options vim.g.vimsense_small_text = "NeoVim" vim.g.vimsense_small_image = "neovim" diff --git a/zsh.nix b/zsh.nix index ea815c0..ab3744e 100644 --- a/zsh.nix +++ b/zsh.nix @@ -21,6 +21,12 @@ fi export NOTESDIR="$HOME/Notes" export PATH="$HOME/.bin:$HOME/.local/bin:$NOTESDIR/bin:$PATH" + function set_win_title(){ + echo -ne "\033]0;\007" + } + + precmd_functions+=(set_win_title) + fortune ''; };