Skip to content

Instantly share code, notes, and snippets.

@softwaredoug
Created August 8, 2023 14:29
Show Gist options
  • Save softwaredoug/c4895d6b3a450129d5b73f18e2a13152 to your computer and use it in GitHub Desktop.
Save softwaredoug/c4895d6b3a450129d5b73f18e2a13152 to your computer and use it in GitHub Desktop.
# Use a neovim session per working directory
#!/bin/bash
(which nvr > /dev/null) || pip3 install neovim-remote
working_dir_slug() {
CWD=$(pwd)
CWD=${CWD//\//_}
echo $CWD
}
SOCKET_FOR_WORKING_DIR="/tmp/$(working_dir_slug)_neovim_socket"
if [ -S "$SOCKET_FOR_WORKING_DIR" ]; then
echo "Socket found at $SOCKET_FOR_WORKING_DIR"
nvr -cc split --servername "$SOCKET_FOR_WORKING_DIR" --remote-wait +'set bufhidden=wipe' $1
else
echo "Start at $SOCKET_FOR_WORKING_DIR"
nvim --listen "$SOCKET_FOR_WORKING_DIR" $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment