sumarsono.com
Take it with a grain of salt


Tmux Resurrect Workaround for Nvim App Image

Posted on

We will use simple go to wrap the nvim.appimage

mkdir $HOME/opt/nvim
cd $HOME/opt/nvim
wget https://github.com/neovim/neovim/releases/download/v0.9.4/nvim.appimage
chmod +x nvim.appimage
ln -s $(realpath nvim.appimage) /usr/local/bin/nvim.appimage
cat <<-'EOF'> nvim.go
package main

import (
	"os"
	"os/exec"
	"syscall"
)

func main() {
	cmd := exec.Command("nvim.appimage", os.Args[1:]...)

	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr

	err := cmd.Run()
	if err != nil {
		if exitError, ok := err.(*exec.ExitError); ok {
			waitStatus := exitError.Sys().(syscall.WaitStatus)
			os.Exit(waitStatus.ExitStatus())
		} else {
			os.Exit(1)
		}
	}
}
EOF

go build nvim.go
ln -s $(realpath nvim) /usr/local/bin/nvim

Now, following tmux resurrect config will work:

# for vim
set -g @resurrect-strategy-vim 'session'
# for neovim
set -g @resurrect-strategy-nvim 'session'

Thanks